mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-09-24 23:01:18 +08:00
fix(curriculum): add example for arrow functions in Platformer Game (#54982)
Co-authored-by: Naomi <accounts+github@nhcarrigan.com> Co-authored-by: Lasse Jørgensen <28780271+lasjorg@users.noreply.github.com>
This commit is contained in:
co-authored by
Naomi
Lasse Jørgensen
parent
b234cf8097
commit
680b319cea
+8
@@ -13,6 +13,14 @@ 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 in the event listener parameter.
|
||||
|
||||
Here is the syntax for using the destructuring assignment in the parameter list of the arrow function:
|
||||
|
||||
```js
|
||||
btn.addEventListener('click', ({ target }) => {
|
||||
console.log(target);
|
||||
});
|
||||
```
|
||||
|
||||
# --hints--
|
||||
|
||||
You need to add an `addEventListener` to the global `window` object.
|
||||
|
||||
Reference in New Issue
Block a user