In the console
we can output any processed data without directly affecting the program - we access the console
by
right-clicking on our browser
clicking on "inspect"
finding the "console" tab
We could use console.log
as a calculator:
const aVariable = 2 + 3
// an assignment to a variable
console.log(aVariable)
// 5
We could also create variables made up of other variables:
const firstNumber = 2
// this could come from user input
const secondNumber = 3
// this could come from an external file
const aVariable = firstNumber + secondNumber
// adding the above two together
console.log(aVariable)
// outputs 5
We can see how console.log
enables us to see outputs of calculations without showing them directly on the webpage!