Edit This Code:
<!DOCTYPE html>
<html>
<body>

<p>
In HTML, all global variables will become window variables.
</p>

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

<script>
myFunction();
document.getElementById("demo").innerHTML =
"I can display " + window.carName;

function myFunction() {
    carName = "Volvo";
}
</script>

</body>
</html>




Result:
Try it Yourself - © w3schools.com
Privacy Policy