Learn to code JavaScript

Log to the Console

console.log() is used to log a variable into the console. Whatever is inside the parentheses is logged to the console.

Examples:

• console.log("Shawn")

• console.log(2 * 5)

• console.log(10 / 2)

Create a variable called sum and set it equal to 5 + 5. If you get stuck, head to the previous lesson to learn how to make a variable.

console.log() the variable you just created. Once you press submit, the sum of 5 + 5 will appear in the console.

Console: