-
Notifications
You must be signed in to change notification settings - Fork 0
/
25-05-2022.js
60 lines (29 loc) · 1.25 KB
/
25-05-2022.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
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
/* 8 Kyu - Reverse List Order
In this kata you will create a function that takes in a list and returns a list with the reverse order.
Examples (Input -> Output)
* [1, 2, 3, 4] -> [4, 3, 2, 1]
* [9, 2, 0, 7] -> [7, 0, 2, 9]
*/
//SOLUTION
function reverseList(list) {
return list.reverse()
}
/* 8 Kyu - Opposites Attract
Timmy & Sarah think they are in love, but around where they live, they will only know once they pick a flower each. If one of the flowers has an even number of petals and the other has an odd number of petals it means they are in love.
Write a function that will take the number of petals of each flower and return true if they are in love and false if they aren't.
*/
//SOLUTION
function lovefunc(flower1, flower2){
return (flower1 % 2 === 0 && flower2 % 2 !== 0 ) || (flower2 % 2 === 0 && flower1 % 2 !== 0 )
}
/* 8 Kyu - Is it even?
In this Kata we are passing a number (n) into a function.
Your code will determine if the number passed is even (or not).
The function needs to return either a true or false.
Numbers may be positive or negative, integers or floats.
Floats with decimal part non equal to zero are considered UNeven for this kata.
*/
//SOLUTION
function testEven(n) {
return n % 2 === 0
}