Doubt regarding java script variables

I type the Manipulating HTML content using Java script code.But in the browser it not showing the variable name. I were not getting the output as “Bolt IoT” variable.


and the output is getting like this
Capture2

hai there,
it is not showing because you are pointing to a javascript file which you might not have declared variables in it or you are confusing the browser to either run the “my-javascript.js” file or the script tag you have written in your html file.
You can use either of this methods to use scripts.
use <script src="my-javascript.js"> </script> to import the my-javascript.js file which has all your variables or all code.
use <script > var myVariable = "Bolt IoT"; document.getElementById("demo").innerHTML=myVariable; </script> to declare a script inside the html file itself.
Solution:
In your case you have used both,
so, remove scr="my-javascript.js" from script tag and that should work fine
Code
click here and hit run button
hope this helps
thank you

1 Like