Learn Intermediate OOP by Building a Platformer Game - Step 79

Tell us what’s happening:

Hi, I know the correct answer to this step, I’m wondering why wrapping the callback function in keys is arbitrary. Is it just syntax being syntax or is it something necessary for this to work correctly?

Your code so far

    if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) {
      platforms.forEach((platform) => platform.position.x -= 5)
    }

Your browser information:

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

Challenge Information:

Learn Intermediate OOP by Building a Platformer Game - Step 79

If i understand you right, you are asking about the curly brackets { } around the callback function body although it’s just one line.

Short answer is no there is no difference in functionality here, It’s just what the test needs to pass.

It’s just what some developers prefer for consistency, readability or if there will be more lines of code in the future.

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.