💥Creating a variable in JavaScript is called "declaring" a variable.
- You declare a JavaScript variable with the var keyword
- Start the statement with var and separate the variables by comma
- you can do arithmetic with JavaScript variables
👊 <script>
var x = 2 + 3 + "5"
document.getElementById("demo").innerHTML = x;
</script>
output: 55
👊<script>
var x = 5 + 2 + 3;
document.getElementById("demo").innerHTML = x;
</script>
output: 10
👊<script>
x = "5" + 2 + 3;
document.getElementById("demo").innerHTML = x;
</script>
output: 523
👊 <script>
var x = 5;
var y = 2;
var z = x * y;
document.getElementById("demo").innerHTML = z;
</script>
outtput 10
No comments:
Post a Comment