-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathodds.js
More file actions
38 lines (22 loc) · 704 Bytes
/
odds.js
File metadata and controls
38 lines (22 loc) · 704 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
// Create an array of the numbers provided
// create another variable called "odds"
// in the "odds" part divide the number "n" by 2
// dividing the numbers by two will help you figure out which numbers are even
// mark out all of the even numbers and console.log all odd numbers.
// do the same for all 4 problems.
// 1
let arr = [2,4,6,8,11,20,15,22]
let odds = arr.filter(n => n%2)
console.log(odds)
// 2
let arr2 = [1,2,3,4,5,6,7,8,9,10]
let odds2 = arr2.filter(n => n%2)
console.log(odds2)
// 3
let arr3 = [70, 42, 55, 81, 21, 91, 34]
let odds3 = arr3.filter(n => n%2)
console.log(odds3)
// 4
let arr4 = [2, 4, 6, 8, 10, 11, 12]
let odds4 = arr4.filter(n => n%2)
console.log(odds4)