forked from truecodersio/JavaScript_HOF
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
45 lines (33 loc) · 892 Bytes
/
script.js
File metadata and controls
45 lines (33 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function makeSandwich(ingredients) {
//get the bread
//get a knife
//for every ingredient, do the following
//grab that ingredient
//open ingredient's packaging
//put it on the sandwich
//cut sandwich in half
//return sandwich
}
makeSandwich(["peanut butter","jelly"]);
makeSandwich();
// Pythagorean Theorem
// a squared + b squared = c squared
function add( a , b){
return a + b;
}
function square(a){
return a * a;
}
function calcPythag(a , b){
return add( square(a), square (b));
}
console.log(calcPythag(3, 4));
//custom for each function
// this takes an array of things and performs some action on everything in that list
function forEvery (list, action){
// loop (iterate) over everything in the list
for(let i=0; i < list.length; i++){
console.log(list[i]);
}
}
forEvery([3, 15, 2, -4, 4, 14]);