Learn Intermediate OOP by Building a Platformer Game - Step 117

Tell us what’s happening:

I am quite stack here with this step, please help.

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

      if (index === checkpoints.length - 1) {
        isCheckpointCollisionDetectionActive = false;
        showCheckpointScreen("You reached the final checkpoint!");
        movePlayer("ArrowRight", 0, false);
      } else if (player.position.x >= checkpoint.position.x <= checkpoint.position.x + 40) {
        showCheckpointScreen("You reached a checkpoint!");

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge Information:

Learn Intermediate OOP by Building a Platformer Game - Step 117

1 Like

Your error lies in the if condition, You need to know that no programming language is capable of evaluating such expression player.position.x >= checkpoint.position.x <= checkpoint.position.x + 40
Let’s say you want to make sure a variable called a is great than or equal than a variable called b & at the same time less than or equal to a variable called c, well in JS, in order to do this, you need to use the and logical operator &&, this operator will evaluate to true if the expressions on the left & on the right are true

if(a >= b && a <=c)

Thanks . The explanation was very helpful. :pray: once again

1 Like