Edit This Code:
See Result »
<!DOCTYPE html> <html> <body> <p> If you assign a value to a variable that has not been declared, it will automatically become a GLOBAL variable: </p> <p id="demo"></p> <script> myFunction(); document.getElementById("demo").innerHTML = "I can display " + carName; function myFunction() { carName = "Volvo"; } </script> </body> </html>
Result: