Create two variables. Assign the number 5 to x, and 6 to y. Then display the result of x + y: - Javascript Data Type

Javascript examples for Data Type:var

Description

Create two variables. Assign the number 5 to x, and 6 to y. Then display the result of x + y:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//  www  .  j  a  v a  2 s.  c  o m
    var x = 5;
    var y = 6;
    document.getElementById("demo").innerHTML = x + y;
}
</script>

</body>
</html>

Related Tutorials