Cannot seem to run Javascript code

This code will simply not display the string “Hello”.


script type="text/javascript" "Hello" /script


please help.

Well it’s a script tag, it’s for JavaScript code, it’s not going to display anything

It’s in an HTML file and I keep reading on the web that if I run it in a browser the Javascript code should work and hence print “Hello”.

It’s JS code, not HTML. If you write “Hello” in the context of JS, that’s just a string, it’s not going to do anything. Something like document.body.innerHTML("Hello") will replace everything in the body element with the string “Hello”, for example, or console.log("Hello") will print Hello to the developer console in the browser. You need to write executable code, “Hello” is not that, it’s just a string of characters, it doesn’t do anything. Anything in that script tag is a script, it’s not just for arbitrary stuff: there isn’t anything there to display. I’m not sure what you’re reading or where you’re reading it because it’s completely wrong, that isn’t going to do anything.

ok thanks, I am just on chapter 1 of Eloquent Javascript and I wanted to type some code out. Guess you need other code to make the strings display, function, whatever.

Yes, you have to tell it exactly what to do, and you have to be very specific — the JS engine has no idea what to do with that “Hello”, so it will just ignore it. It will make more sense as you get further into the book, I promise!