12. Using console.log


#1

What does console.log do?

It seems to display the output of script.js but sometimes, even without console.log, there is still a display.


#2

console.log displays a text, number or boolean in the console. You can access the console of your browser by pressing F12 and looking for it around there (changes from browser to browser). JavaScript is used for websites so probably console is used only for displaying an error, or stuff that the programmer considers useful. If you want to make a website and write something there are other ways. I must say I haven't learnt them all but you can find them easily. The syntax for console.log is the next.
Strings
console.log("The string you want to write");
Booleans
console.log(false); // you can also use true
Numbers
console.log(12345);
Variables
console.log(variable_name);
Functions (only if the function has a return in it)
console.log(function_name);

Remember to always put a ; at the end of it. Hope it helps