Search This Blog

Tuesday, 2 August 2016

How to divide two number in javascript?

Html page:

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

Javascript page:

<script>
    function myFunction() {
        var y = 5;
        var x = y / 2;
        document.getElementById("demo").innerHTML = x;
    }
</script>

Output:

2.5

No comments:

Post a Comment