Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following JavaScript code?
<p id=”demo”></p>
<script>
function myFunction()
{
var num = 5.56789;
var n = num.toExponential();
document.getElementById(“demo”).innerHTML = n;
}
</script>

What will be the output of the following JavaScript code?
<p id=”demo”></p>
<script>
function myFunction()
{
var num = 5.56789;
var n = num.toExponential();
document.getElementById(“demo”).innerHTML = n;
}
</script>
a) 5.56789e+0
b) 5.57e+0
c) 5.568e+0
d) Error

Answer: a
Explanation: The toExponential() method converts a number into an exponential notation. It displays the number of digit according to the input passed to it.

Join The Discussion