var x = 5; var y = 10; var sum = x + y; document.write(sum); // Prints variable value
You will learn what each of these statements means in upcoming chapters.
For example, the variable
myVar must be typed
myvar. Similarly, the method name
getElementById() must be typed with the exact case not as
var myVar = "Hello World!"; console.log(myVar); console.log(MyVar); console.log(myvar);
If you checkout the browser console by pressing the
f12 key on the keyboard, you'll see a line something like this: "Uncaught ReferenceError: MyVar is not defined".
//), followed by the comment text. Here's an example:
Whereas, a multi-line comment begins with a slash and an asterisk (
/*) and ends with an asterisk and slash (
*/). Here's an example of a multi-line comment.