scrimba
Learn JavaScript
Practice part 3
let & const
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

To see this lesson you need to be logged in. Joining Scrimba is free and gives you access to 20+ courses.Sign up
AboutCommentsNotes
let & const
Expand for more info
index.js
run
preview
console
// SETTING THE STAGE
let player = "Per"
let opponent = "Nick"
let game = "AmazingFighter"
const points = 0
const hasWon = false

// PLAYING THE GAME
points += 100
hasWon = true

// ANNOUNCING THE WINNER
if (hasWon) {
console.log(player + " got " + points + " points and won the " + game + " game!")
} else {
console.log("The winner is " + opponent + "! " + player + " lost the game")
}

// Go through all variables and decide if they should be let or const
// Change the console logs to use template strings instead of double quotes
Console
TypeError: Assignment to constant variable. (/index.js:9)
,
/index.html
-3:12