Single Choice Easy

QWhat would the following JavaScript code produce?

<p id="demo"></p>
<script>
var pos = str.indexOf("locate");
document.getElementById("demo").innerHTML = pos;
</script>

ID: #5133 Javascript DOM & Event Handling MCQ 133 views
Question Info
#5133Q ID
EasyDifficulty
Javascript DOM & Event Handling MCQTopic

Choose the Best Option

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

  • A 5
  • B 7
  • C 0
  • D Error
Correct Answer

Explanation

The position of the first occurrence of a given text is returned by the indexOf() method. locate initially appears at 7 places.

Share This Question

Challenge a friend or share with your study group.