Mole unearther can not get it to unpause

Hi! for the last step in Mole Unearther I need to make the space button unpause the game.

" Now that we can successfully pause the game, we should let the user unpause the game. In the togglePause() function, when the if condition fails, then the value of isPaused should be toggled to false .

Add an else condition and set the isPaused variable to false . Then add this call: this.removePauseScreen();

this.removePauseScreen() removes the paused overlay on the screen."

This is the code that I made, but it doesn’t work. it keeps pausing and the the screens keeps fading instead of starting again. Looking at where it went wrong for 30 minutes already but cant find my mistake.

const togglePause = () => {
if (isPaused === false){
isPaused === true
}else {
isPaused === false

What is the difference between:

isPaused === true


isPaused = true?


I couldn’t sleep because of it yesterday and suddenly I realized I made a mistake with mixing up the === and = signs :smiley:

=== is used to check if 2 values are the same
= is used to assign a new value

if I am correct this time.

Thank you for your help!

1 Like

Well actually === is used to check both value and type. Whilst == only check for value.

var a = 1
var b = '1'

a === b // false
a == b // true

I think the lessons so far didn’t tell me about the == sign or I must have forgotten.

So your first statement is wrong because value is the same, but type is different? (value is 1 both times but type is number/int and the other one is string? So for === both value AND type need to be the same?

As for the 2nd statement, does Javascript see the number 1 and the string “1” as the same value? That surprises me a bit.

Thanks for explaining, really helpful!

1 Like

Using the equality operator (==), JavaScript will convert the operands to the same type prior to making the comparison. See
If you explore the page at the link a bit, you can read about all of the comparison operators including (===).

1 Like