typo in function name & in output |  topic Higher-order functions
pull/4/head
Shekh Aliul 5 years ago committed by GitHub
parent 267b063802
commit caf91f8d64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2995,10 +2995,10 @@ Let us see were we use call back functions.For instance the _forEach_ method use
```js ```js
const numbers = [1, 2, 3, 4] const numbers = [1, 2, 3, 4]
const sumArray = arr => { const sumArray = arr => {
let sum = 0 let sum = 0
const callBack = function(element) { const callback = function(element) {
sum += element sum += element
} }
numbers.forEach(callback) numbers.forEach(callback)
@ -3009,14 +3009,14 @@ console.log(sumArray(numbers))
``` ```
```sh ```sh
15 10
``` ```
The above example can be simplified as follows: The above example can be simplified as follows:
```js ```js
const numbers = [1, 2, 3, 4] const numbers = [1, 2, 3, 4]
const sumArray = arr => { const sumArray = arr => {
let sum = 0 let sum = 0
numbers.forEach(function(element) { numbers.forEach(function(element) {
@ -3029,7 +3029,7 @@ console.log(sumArray(numbers))
``` ```
```sh ```sh
15 10
``` ```
### setting time ### setting time

Loading…
Cancel
Save