You cannot add a JavaScript variable to HTML code.
To do this, you need to do the following.
<html> <head> <script type="text/javscript"> var number = 123; document.addEventListener('DOMContentLoaded', function() { document.getElementByTagName("h1").innerHTML("the value for number is: " + number); }); </script> </head> <body> <h1></h1> </body> </html>
source share