JavaScript MCQ Scripted Media Question #5040
Single Choice Easy

QWhat would the following JavaScript code produce?

<p id="demo"></p>
<script>
function myFunction() 
{
   var num = 13.3714;
   document.getElementById("demo").innerHTML = num.toPrecision(3);
}
</script>

ID: #5040 Scripted Media 144 views
Question Info
#5040Q ID
EasyDifficulty
Scripted MediaTopic

Choose the Best Option

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

  • A 13
  • B 13.3714
  • C 13.3
  • D 13.4
Correct Answer

Explanation

The toPrecision() method formats a number to a specified length by adding a decimal point and any necessary nulls.
The toPrecision() method formats a number by adding a decimal point and any required nulls, resulting in the specified length.
The toPrecision() method formats a number to the desired length by adding a decimal point and nulls (if necessary).
By adding a decimal point and nulls (if needed), the toPrecision()method formats a number to the specified length.

Share This Question

Challenge a friend or share with your study group.