-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforEach.js
32 lines (20 loc) · 829 Bytes
/
forEach.js
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
// Write a function that uses forEach to print each element of an array to the console.
var a = [12, 33, 54, 4, 6, 64];
a.forEach(function(chacha){
console.log(chacha);
});
// Double the value of each element in an array using forEach.
var a = [12, 33, 54, 4, 6, 64];
a.forEach(function(chacha){
console.log(chacha + chacha);
});
// Calculate and return the sum of all elements in an array using forEach.
var a = [12, 33, 54, 4, 6, 64];
a.forEach(function(chacha){
console.log(chacha);
});
// Implement a function that finds the maximum value in an array of numbers using forEach.
var a = [12, 33, 54, 4, 6, 64];
a.forEach(function(chacha){
console.log(chacha);
});