알고리즘 61 - I love you, a little , a lot, passionately ... not at all

tamagoyakii·2021년 10월 19일
0

알고리즘

목록 보기
61/89

Q.

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
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 for a flower of a given number of petals, where nb_petals > 0.

A)

function howMuchILoveYou(nbPetals) {
  let arr = [
    'I love you',
    'a little',
    'a lot',
    'passionately',
    'madly',
    'not at all'
  ]
  
  return arr[(nbPetals - 1) % 6]
}

0개의 댓글