fix(curriculum): Updated the description of calorie counter- step 50 (#53462)

Co-authored-by: Joy Shaheb <khondokoralam@gmail.com>
Co-authored-by: Krzysztof G. <60067306+gikf@users.noreply.github.com>
This commit is contained in:
Alagu Muthiah
2024-01-30 22:10:56 -08:00
committed by GitHub
parent 51dab9b64b
commit 7e1a233a0c

View File

@@ -9,7 +9,25 @@ dashedName: step-50
In the Role Playing Game project, you learned how to set a button's behavior by editing its `onclick` property. You can also edit an element's behavior by adding an event listener.
Call the `.addEventListener()` method of the `addEntryButton`. It takes two arguments. The first is the event to listen to you should pass the string `click`. The second is the callback function, or the function that runs when the event is triggered. Pass the `addEntry` function as the second argument. Note that you should not *call* `addEntry`, but pass the variable (or <dfn>function reference</dfn>) directly.
The following example uses the `addEventListener` method to add a click event to a button. When the button is clicked, the `printName` function is called.
```html
<button class="btn">Print name</button>
```
```js
const button = document.querySelector('.btn');
function printName() {
console.log("Jessica");
}
button.addEventListener('click', printName);
```
The `addEventListener` method takes two arguments. The first is the event to listen to. (Ex. `'click'`) The second is the callback function, or the function that runs when the event is triggered.
Call the `.addEventListener()` method on the `addEntryButton`. Pass in the string `click` for the first argument and the `addEntry` function for the second argument.
Note that you should not *call* `addEntry`, but pass the variable (or <dfn>function reference</dfn>) directly.
# --hints--