-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfunctions2.js
More file actions
40 lines (31 loc) · 1.03 KB
/
functions2.js
File metadata and controls
40 lines (31 loc) · 1.03 KB
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
// a funcion ais a block of code that can be reused
// - just perform an operation
// - sometimes have a return value/result
function greatPerson(name, time) {
console.log("Good " + time + " " + name);
return "Good " + time + " " + name;
}
let greeting = greatPerson("albert", "evening");
console.log(greeting);
const isBelowThreshold = (currentValue) => currentValue < 40;
function isAboveThreshold(currentValue) {
return currentValue > 40;
}
const array1 = [100, 30, 390, 29, 10, 153];
// console.log(array1.every(isBelowThreshold));
// console.log(array1.find(isBelowThreshold)); //
for (let index = 0; index < array1.length; index++) {
if (array1[index] < 40) {
console.log("Element " + array1[index] + " is below Threshold");
} else {
console.log("Element " + array1[index] + " is above Threshold");
}
}
array1.forEach(function (elem) {
if (elem < 40) {
console.log("Element " + elem + " is below Threshold");
} else {
console.log("Element " + elem + " is above Threshold");
}
});
console.log(array1);