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--