Skip to content

Commit fe60906

Browse files
committed
npx prettier -w
1 parent 3d7b81a commit fe60906

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

concepts/callbacks/about.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ It is also useful to use _callback functions_ because they may reference variabl
1515
_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.
1616

1717
```javascript
18-
document.addEventListener('onload', () => alert('The webpage has now been loaded'))
18+
document.addEventListener('onload', function () {
19+
alert('The webpage has now been loaded');
20+
});
1921
```
2022

2123
### Node.js Convention

exercises/concept/fruit-picker/.docs/instructions.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ You are creating a new online portal for your patrons to order their fruit fresh
44

55
## 1. Create a callback to be called when the order is successful
66

7-
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.
7+
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.
88

99
```javascript
1010
onSuccess();
11-
// => `nofify` called with `{ message: 'SUCCESS' }`
11+
// => `notify` called with `{ message: 'SUCCESS' }`
1212
```
1313

1414
## 2. Create a callback to be called when the order fails with an error
1515

16-
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.
16+
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.
1717

1818
```javascript
1919
onError();
20-
// => `nofify` called with `{ message: 'ERROR' }`
20+
// => `notify` called with `{ message: 'ERROR' }`
2121
```
2222

2323
## 3. Create a wrapper to wrap the external api function
@@ -34,7 +34,11 @@ const query = {
3434
```
3535

3636
```javascript
37-
orderFromGrocer({variety: 'pear', quantity: 12}, exampleSuccessCallback, exampleErrorCallback)
37+
orderFromGrocer(
38+
{ variety: 'pear', quantity: 12 },
39+
exampleSuccessCallback,
40+
exampleErrorCallback
41+
);
3842
// => `order` was called with the query and the callbacks
3943
```
4044

@@ -43,6 +47,6 @@ orderFromGrocer({variety: 'pear', quantity: 12}, exampleSuccessCallback, example
4347
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.
4448

4549
```javascript
46-
postOrder('peach', 100)
50+
postOrder('peach', 100);
4751
// => order submitted for 100 peaches
4852
```

0 commit comments

Comments
 (0)