19
19
![ Day 5] ( ../images/banners/day_1_9.png )
20
20
21
21
- [ Day 9] ( #day-9 )
22
- - [ Higher Order Function] ( #higher-order-function )
23
- - [ Callback] ( #callback )
24
- - [ Returning function] ( #returning-function )
25
- - [ setting time] ( #setting-time )
26
- - [ setInterval] ( #setinterval )
27
- - [ setTimeout] ( #settimeout )
28
- - [ Functional Programming] ( #functional-programming )
29
- - [ forEach] ( #foreach )
30
- - [ map] ( #map )
31
- - [ filter] ( #filter )
32
- - [ reduce] ( #reduce )
33
- - [ every] ( #every )
34
- - [ find] ( #find )
35
- - [ findIndex] ( #findindex )
36
- - [ some] ( #some )
37
- - [ sort] ( #sort )
38
- - [ Sorting string values] ( #sorting-string-values )
39
- - [ Sorting Numeric values] ( #sorting-numeric-values )
40
- - [ Sorting Object Arrays] ( #sorting-object-arrays )
41
- - [ 💻 Exercises] ( #-exercises )
42
- - [ Exercises: Level 1] ( #exercises-level-1 )
43
- - [ Exercises: Level 2] ( #exercises-level-2 )
44
- - [ Exercises: Level 3] ( #exercises-level-3 )
22
+ - [Higher Order Function](#higher-order-function)
23
+ - [Callback](#callback)
24
+ - [Returning function](#returning-function)
25
+ - [Setting time](#setting-time)
26
+ - [Setting Interaval using a setInterval function ](#setting-interaval-using-a- setinterval-function )
27
+ - [Setting a time using a setTimeout](#setting-a-time-using-a- settimeout)
28
+ - [Functional Programming](#functional-programming)
29
+ - [forEach](#foreach)
30
+ - [map](#map)
31
+ - [filter](#filter)
32
+ - [reduce](#reduce)
33
+ - [every](#every)
34
+ - [find](#find)
35
+ - [findIndex](#findindex)
36
+ - [some](#some)
37
+ - [sort](#sort)
38
+ - [Sorting string values](#sorting-string-values)
39
+ - [Sorting Numeric values](#sorting-numeric-values)
40
+ - [Sorting Object Arrays](#sorting-object-arrays)
41
+ - [💻 Exercises](#-exercises)
42
+ - [Exercises: Level 1](#exercises-level-1)
43
+ - [Exercises: Level 2](#exercises-level-2)
44
+ - [Exercises: Level 3](#exercises-level-3)
45
45
46
46
# Day 9
47
47
@@ -54,12 +54,12 @@ Higher order functions are functions which take other function as a parameter or
54
54
A callback is a function which can be passed as parameter to other function. See the example below.
55
55
56
56
``` js
57
- // a callback function, the function could be any name
57
+ // a callback function, the name of the function could be any name
58
58
const callback = (n ) => {
59
59
return n ** 2
60
60
}
61
61
62
- // function take other function as a callback
62
+ // function that takes other function as a callback
63
63
function cube (callback , n ) {
64
64
return callback (n) * n
65
65
}
@@ -71,7 +71,6 @@ console.log(cube(callback, 3))
71
71
72
72
Higher order functions return function as a value
73
73
74
-
75
74
``` js
76
75
// Higher order function returning an other function
77
76
const higherOrder = n => {
@@ -90,7 +89,6 @@ Let us see were we use call back functions. For instance the _forEach_ method us
90
89
91
90
``` js
92
91
const numbers = [1 , 2 , 3 , 4 ]
93
-
94
92
const sumArray = arr => {
95
93
let sum = 0
96
94
const callback = function (element ) {
@@ -354,8 +352,8 @@ const scores = [
354
352
{ name: ' John' , score: 100 },
355
353
]
356
354
357
- const scoresGreaterEight = scores .filter ((score ) => score .score > 80 )
358
- console .log (scoresGreaterEight )
355
+ const scoresGreaterEighty = scores .filter ((score ) => score .score > 80 )
356
+ console .log (scoresGreaterEighty )
359
357
```
360
358
361
359
``` sh
0 commit comments