js var in html code example
Example 1: html use js variable as text
<h1>"My number: " <span id="myText"></span></h1>
<script>
//You can use an IIFE (Immediately Invoked Function Expression)
(() => {
var number = "123";
document.getElementById("myText").innerHTML = number;
})();
</script>
Example 2: var javascript
var is a keyword to define the varible in js but as of es-6 we, use let and const keywords for the same
Example 3: how to define variable in javascript
var <variable-name>;
var <variable-name> = <value>;