// this will output ‘hello world’ to the browser's console. console.log(‘hello world’); result = 3 + 7 // comments can also follow a statement like this
/* and asterisk followed by a forward-slash
*/. Below are some examples of multi-line comments.
/* Add two numbers and Store the output in a variable called result. Also, print the output to the browser’s console */ result = 6 * 5 console.log(‘Multiplication result is: ‘, result);
Using Code Comments to Prevent Execution
When testing your own code, adding two forward slashes
// in front of code lines will convert the code to a comment, rather than an executable line.
To prevent the execution of multiple lines, a comment block can be used.
Get hands-on experience writing code with interactive tutorials in our free online learning platform.
- Free and fun
- Designed for beginners
- No downloads or setup required