Learn Intermediate OOP by Building a Platformer Game - Step 86

Tell us what’s happening:

It keeps telling me I should have an if statement that uses the every method to check if every rule in the collisionDetectionRules array is true. I’ve tried other ways, but I can’t see what I’m doing wrong. I’ve read through other posts about this step and still can’t figure it out.

Your code so far

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

/* file: styles.css */

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

if (platformDetectionRules.every((rule) => rule)) {player.velocity.y = 0; return true}

// 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 Edg/

Challenge Information:

Learn Intermediate OOP by Building a Platformer Game - Step 86

Hello there;

Lesson want control this array but your code check this;

Also, you don’t need to return any value or assign anything to a variable. However, the lesson requires a return statement inside the if statement to exit the current iteration of the forEach loop and it will continue to other platforms element. So this iteration check to each platform collisionDetectionRules and make some changes inside of if stamements. You will see more with different rules.

 platforms.forEach((platform) => {
    const collisionDetectionRules = [
      player.position.y + player.height <= platform.position.y,
      player.position.y + player.height + player.velocity.y >= platform.position.y,
      player.position.x >= platform.position.x - player.width / 2,
      player.position.x <=
        platform.position.x + platform.width - player.width / 3,
//Your if statement will be here
if( ... ){


Yeah I copied and pasted the wrong word there, but I was actually using collisionDetectionRules