MCQ Single Best Answer Easy

QWhat would the following JavaScript code produce?

<p id="demo"></p>
<script>
 var x = 123e5;
 document.getElementById("demo").innerHTML = x ;
</script>

ID: #5023 Javascript Modules MCQ 171 views
Question Info
#5023Q ID
EasyDifficulty
Javascript Modules MCQTopic

Choose the Best Option

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

  • A 0.0123
  • B 12300
  • C Error
  • D Undefined
Correct Answer: Option B

Explanation

This script defines a variable x and assigns it the value 123e5, which is equivalent to 123 * 10^5, or 1230000.
Then, it selects the element with the ID "demo" and changes its inner HTML to the value of x. The result would be that the element with the ID "demo" displays the text "1230000".

Share This Question

Challenge a friend or share with your study group.