Your Python solution will not work in JavaScript. Your problems are caused exactly by the thing which works in Python, but not in JS. arr[-1] works differently in JS and Python.
Your code does not correctly calculate the position in the phrases array because the operator precedence is wrong. As a result, the selected index is outside the valid range, causing your function to return undefined instead of a phrase from the list.
Your Python solution will not work in JavaScript. Your problems are caused exactly by the thing which works in Python, but not in JS.
arr[-1]
works differently in JS and Python.With your updated code it is:
nbPetals % phrasess.length - 1
does not do what you think it does, but you need to take it from here.When you ask for help, please ask for help and not just post code. Refer to this documentation to debug your code and ask for help efficiently: https://docs.codewars.com/training/troubleshooting/
Don't post solutions in discourse and use the spoiler flag when you post code somewhere.
https://www.codewars.com/kata/52685f7382004e774f0001f7 is this your challenge? you can also try going to "view profile" > "Kata" > "Unfinished"