Mixed Message Project: Random Lyric Generator

Hey everyone,
I ended up doing a random lyric generator. Wasn’t too hard but took me a couple hours with breaks. I started with a method similar to the codecademy example but decided to change it.

keep going!
Just a small hint:
you need to multiply Math.random() with the full length not length - 1.

Math.floor(Math.random()*6);// returns a random integer from 0 to 5

so change line 21 from getRandomNum(arr.length - 1) to getRandomNum(arr.length) or you will miss the last element. Also remove - 1 at line 37.

Ahh thank you I was wondering why it seemed to work but I was randomly getting undefined in the lyric section when I would run it. I was using Math.round( ) in getRandomNum( ) rather than Math.floor() and your fix helped.

1 Like