Search This Blog

Monday, 1 August 2016

How to display the exponential notation of aa specified number in javascript?

Html page:

<button onclick="myFunction()">Try it</button>
<p id="P9"></p>

Javascript page:

<script>
    function myFunction() {
        var num = 5.56789;
        var n = num.toExponential();
        document.getElementById("demo").innerHTML = n;
    }
</script>

Output:
5.56789e+0


No comments:

Post a Comment