-
Notifications
You must be signed in to change notification settings - Fork 0
/
Petals_game.js
25 lines (18 loc) · 1 KB
/
Petals_game.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
/* description */
// Who remembers back to their time in the schoolyard, when girls would take a flower and tear its petals, saying each of the following phrases each time a petal was torn:
// "I love you"
// "a little"
// "a lot"
// "passionately"
// "madly"
// "not at all"
// If there are more than 6 petals, you start over with "I love you" for 7 petals, "a little" for 8 petals and so on.
// When the last petal was torn there were cries of excitement, dreams, surging thoughts and emotions.
// Your goal in this kata is to determine which phrase the girls would say at the last petal for a flower of a given number of petals. The number of petals is always greater than 0.
/* ----------------------------------------------------------- */
const howMuchILoveYou = (nbPetals) => {
const phrases = ["I love you", "a little", "a lot", "passionately", "madly", "not at all"];
const lastPetalIndex = (nbPetals - 1) % phrases.length;
return phrases[lastPetalIndex];
}
console.log('result', howMuchILoveYou(10))