Learn-intermediate-oop-by-building-a-platformer-game - Step 55

Hi, I need help getting past this step. It keeps saying Sorry, your code does not pass. Hang in there.

You should assign isPressed to keys.leftKey.pressed.

  switch (key) {
  case "ArrowLeft":
  isPressed = keys.leftKey.pressed;
    if (xVelocity === 0) {
      xVelocity = player.velocity.x;
    }
}

So this is the best solution that I could come up with and I find. But I don’t understand what I am doing wrong or what the assignment specifically wants.

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-intermediate-oop-by-building-a-platformer-game/step-55

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

I have also edited your post to include the challenge link.

In the future, please use the help button in the challenge which provides all of the information. It will help people on the forum to better assist you :+1:

as to your issue, all of your assignments here are wrong

remember that assignment works by assigning what is on the right to what is on the left

re read through the directions again to fix the issues and pass the test

Inside the case clause, assign isPressed to keys.leftKey.pressed.

Below that, add an if statement that checks if xVelocity is equal to 0. If so, assign the xVelocity to player.velocity.x.

hope that helps

1 Like

Thanks, I figured it out shortly after I posted in the forum.