Single Choice Easy

QWhat would the following JavaScript code produce?


<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() 
{
   var str = "a,b,c,d,e,f";
   var arr = str.split(",");
   document.getElementById("demo").innerHTML = arr[3];
}
</script>


ID: #5136 Javascript DOM & Event Handling MCQ 112 views
Question Info
#5136Q ID
EasyDifficulty
Javascript DOM & Event Handling MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A d
  • B a
  • C b
  • D c
Correct Answer

Explanation

The string is divided using the argument supplied to the split method.
The output will be d because the array's third index will be initialised with that value.

Share This Question

Challenge a friend or share with your study group.