From fe60906af3a02eb03bf8a874df765ab80725a28b Mon Sep 17 00:00:00 2001 From: Tim Austin Date: Sun, 1 May 2022 21:17:57 -0600 Subject: [PATCH] `npx prettier -w` --- concepts/callbacks/about.md | 4 +++- .../concept/fruit-picker/.docs/instructions.md | 16 ++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/concepts/callbacks/about.md b/concepts/callbacks/about.md index 6733d56165..ddfa7382c1 100644 --- a/concepts/callbacks/about.md +++ b/concepts/callbacks/about.md @@ -15,7 +15,9 @@ It is also useful to use _callback functions_ because they may reference variabl _Event handlers_ are a common use-case for callbacks in JavaScript. Browser events like `'onload'` or `'onclick'` are signals which can trigger functions to be invoked. A DOM [[Document Object Model](mdn-dom) object's `addEventListener` method registers a callback function to be invoked when it "hears" that an event has occurred. ```javascript -document.addEventListener('onload', () => alert('The webpage has now been loaded')) +document.addEventListener('onload', function () { + alert('The webpage has now been loaded'); +}); ``` ### Node.js Convention diff --git a/exercises/concept/fruit-picker/.docs/instructions.md b/exercises/concept/fruit-picker/.docs/instructions.md index 6e572f8c07..9c41e710c7 100644 --- a/exercises/concept/fruit-picker/.docs/instructions.md +++ b/exercises/concept/fruit-picker/.docs/instructions.md @@ -4,20 +4,20 @@ You are creating a new online portal for your patrons to order their fruit fresh ## 1. Create a callback to be called when the order is successful -Write a callback function called `onSuccess` to be called when the order is successful. It should invoke the imported `notify` function passing a success message to it. +Write a callback function called `onSuccess` to be called when the order is successful. It should invoke the imported `notify` function passing a success message to it. ```javascript onSuccess(); -// => `nofify` called with `{ message: 'SUCCESS' }` +// => `notify` called with `{ message: 'SUCCESS' }` ``` ## 2. Create a callback to be called when the order fails with an error -Write a callback function called `onError` to be called when the order encounters an error. It should invoke the imported `notify` function passing an error message to it. +Write a callback function called `onError` to be called when the order encounters an error. It should invoke the imported `notify` function passing an error message to it. ```javascript onError(); -// => `nofify` called with `{ message: 'ERROR' }` +// => `notify` called with `{ message: 'ERROR' }` ``` ## 3. Create a wrapper to wrap the external api function @@ -34,7 +34,11 @@ const query = { ``` ```javascript -orderFromGrocer({variety: 'pear', quantity: 12}, exampleSuccessCallback, exampleErrorCallback) +orderFromGrocer( + { variety: 'pear', quantity: 12 }, + exampleSuccessCallback, + exampleErrorCallback +); // => `order` was called with the query and the callbacks ``` @@ -43,6 +47,6 @@ orderFromGrocer({variety: 'pear', quantity: 12}, exampleSuccessCallback, example You find that you are calling this function from many different places with the same functions. Seeing an opportunity to refactor your code, you want to create a function where you can supply the variety and quantity to order as arguments. ```javascript -postOrder('peach', 100) +postOrder('peach', 100); // => order submitted for 100 peaches ```