How to output in JavaScript?

To output in JavaScript, call the console.log function.

Just call console.log with the value that you want to output:

var myValue = 2;

console.log(myValue); // 2

console.log outputs to web browser's build-in console.

To see the output in Chrome web browser, click the three-dot menu in the top-right corner, then under More Tools click Developer Tools. In the opened panel, go to the Console tab to see your output.