Knowee
Questions
Features
Study Tools

28. What is the output of the following JavaScript code?*var fruits = [“apple”, “banana”, “cherry”];var result = fruits.join(” – “);console.log(result);

Question

  1. What is the output of the following JavaScript code?*var fruits = [“apple”, “banana”, “cherry”];var result = fruits.join(” – “);console.log(result);
🧐 Not the exact question you are looking for?Go ask a question

Solution

The output of the given JavaScript code will be:

"apple – banana – cherry"

Explanation:

  1. An array named 'fruits' is declared with three elements: "apple", "banana", and "cherry".

  2. The 'join()' method is used on the 'fruits' array with " – " as the separator. This method combines all the elements of the array into a single string, with each element separated by the specified separator.

  3. The 'console.log()' function is used to print the 'result' variable to the console.

So, the output will be the string "apple – banana – cherry".

This problem has been solved

Similar Questions

What is the output of following code?var a = 10;function test() { a = 20;}test();console.log(a);Options: Pick one correct answer from below1020

What will be the output of the following JavaScript code? var a=5 , b=11 var obj = { a : 10 } // with keyword in JavaScript with(obj) { alert(b) }Select one:a. 15b. 5c. Errord. 11

What will be the output of the following code snippet?`<script type="text/javascript" language="javascript">`  var a = "Synoverge";var result = a.substring(2, 4);document.write(result);  `</script>`noSelect one:a. Synovergeb. noc. noved. vergeClear my choice

What will be the output of the following code snippet?var a = 1; var b = 0;  while (a <= 3) {  a++;  b += a * 2;  print(b); }*4 10 181 2 3None of Above1 4 7

What will be the output of the following code snippet?(function(){  setTimeout(()=> console.log(1),2000); console.log(2); setTimeout(()=> console.log(3),0); console.log(4); })();*1 2 3 42 3 4 14 3 2 12 4 3 1

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.