Next.js Discord

Discord Forum

Math.floor is undefined

Answered
Gecco posted this in #help-forum
Open in Discord
Whenever I try and use Math.floor it is undefined, if I print the function with console.log(Math.floor) it works fine but otherwise not.
Answered by Coffee Coke
try using Math.floor(Math.random() * this.poems.length - 1), I don't see any other problems with this information
View full answer

2 Replies

@Gecco Whenever I try and use Math.floor it is undefined, if I print the function with `console.log(Math.floor)` it works fine but otherwise not.
try using Math.floor(Math.random() * this.poems.length - 1), I don't see any other problems with this information
Answer
if poems lenght is 5 for example, poems[5] wouldn't exist and return undefined