-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJS_roadtrip_part_3.html
80 lines (63 loc) · 1.69 KB
/
JS_roadtrip_part_3.html
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Passing Functions as Parameters</title>
</head>
<body>
<script>
// Exercise #1.2.1
var passengers = [ ["Thomas", "Meeks"],
["Gregg", "Pollack"],
["Christine", "Wong"],
["Dan", "McGaw"] ];
var modifiedNames = passengers.map(
function (arrayCell) {
var string = arrayCell[0] + " " + arrayCell[1];
return string;
});
console.log(modifiedNames);
// modifiedNames.map(
// function (arrayCell) {
// alert("Yo, " + arrayCell + "!");
// }
// );
// Exercise #1.2.3
var a = function (input) {
var a = (3 * input) - 8;
return a;
};
var b = function (input) {
var b = (input + 2)*(input + 2) * (input + 2);
return b;
};
var c = function (input) {
var c = (input * input) - 9;
return c;
};
var d = function (input) {
var d = input % 4;
return d;
};
var puzzlers = [a, b, c, d];
var newPuzzlers = puzzlers.map(
function (fun) {
return fun(5);
}
);
// Exercise #1.2.3
console.log(newPuzzlers);
// var puzzlers = [
// function(input){},
// function(input){},
// function(input){},
// function(input)]{};
// ]
var newPuzzlers = puzzlers.map(
function(fun) {
return fun(2);
}
);
</script>
</body>
</html>