From 7e1a233a0c4d14f43aa44dbc3771e49ea836dc67 Mon Sep 17 00:00:00 2001 From: Alagu Muthiah <57620699+alagumuthiah@users.noreply.github.com> Date: Tue, 30 Jan 2024 22:10:56 -0800 Subject: [PATCH] fix(curriculum): Updated the description of calorie counter- step 50 (#53462) Co-authored-by: Joy Shaheb Co-authored-by: Krzysztof G. <60067306+gikf@users.noreply.github.com> --- .../63c21dea919c8e4adb0df8e8.md | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c21dea919c8e4adb0df8e8.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c21dea919c8e4adb0df8e8.md index 2408cdb8d05..e7f1586cedc 100644 --- a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c21dea919c8e4adb0df8e8.md +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c21dea919c8e4adb0df8e8.md @@ -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 function reference) 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 + +``` + +```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 function reference) directly. # --hints--