Learn Intermediate OOP by Building a Platformer Game - Step 55

Tell us what’s happening:

The challenge reads:

Start by adding an addEventListener to the global window object. For the arguments, pass in the “keydown” event and an arrow function that uses the destructuring assignment to get the key property from the event object.

I don’t see how I’m not doing this. Any help is appreciated. Thank you!

Your code so far

window.addEventListener("keydown", (event) => {
  const {key} = event;
});

Your browser information:

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

Challenge Information:

Learn Intermediate OOP by Building a Platformer Game - Step 55

1 Like

It looks like you did it correctly.

Unfortunately, the test is looking for a specific solution.

I have created an issue to update the tests.
I posted the answer the test is looking for in that issue too

7 Likes

Thank you! I was driving myself insane trying to figure out how I was wrong.

1 Like

Thank you… I tried the same solution as PowerfulGhost and this:
window.addEventListener(“keydown”, ({key}) => key);
but neither passed.

Yet another case of a syntax example creating more headache confusion frustration than helping anyone learn. If fCC is going to provide examples of the code then don’t provide more than what is required because it turns learning into guessing into frustration. Whoever wrote the curriculum needs to remember we are students, this is literally the second language we are learning and if you really want people to grasp the concept and create a new career, remember who your audience is.

If anyone is here: the key property is a parameter just like target in the example. Unlike target though, this step doesn’t need property logged so the body of the callback is empty.

2 Likes

You’re a legend, mate.

I almost wept, as I backspace’d and hit check answer and I saw green, and it’s all thanks to you. Syntax is no joke