-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask63.js
26 lines (21 loc) · 836 Bytes
/
task63.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
//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.
assert.strictEqual(lovefunc(1, 4), true);
assert.strictEqual(lovefunc(2, 2), false);
assert.strictEqual(lovefunc(0, 1), true);
assert.strictEqual(lovefunc(0, 0), false);
*/
function lovefunc(flower1, flower2) {
return flower1 % 2 !== flower2 % 2;
}
function lovefunc(flower1, flower2) {
if (
(flower1 % 2 == 0 && flower2 % 2 == 0) ||
(flower1 % 2 == 1 && flower2 % 2 == 1)
) {
return false;
} else {
return true;
}
}