I can’t figure out this problem
if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) {
platforms.forEach(platform.x -= 5)
}
Challenge Information:
Learn Intermediate OOP by Building a Platformer Game - Step 79
I can’t figure out this problem
if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) {
platforms.forEach(platform.x -= 5)
}
Learn Intermediate OOP by Building a Platformer Game - Step 79
Please talk to us about how the instructions or error message is confusing. Thanks
the error says: You should have a forEach
loop that iterates through the platforms
array.
platforms.forEach(platform.x -= [5])
from my understanding the loop is the parenthesis so I added an array around [5] but still doesn’t work
The forEach
loop takes a callback function. This here isn’t a function though. Look at the code from previous steps to see examples of arrow functions being used as callbacks for forEach
ok thank you got the answer
I still don’t get what the solution is.
I am putting this and it is showing as wrong:
if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) {
platforms.forEach((platform) => {
platform.x -= 5;
})
}
If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.
The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.
Thank you.