Search This Blog

Tuesday, 2 August 2016

How to convert the variable number to string in javascript?

Html page:

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

Javascript page:

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

Output:

15

No comments:

Post a Comment