Math.random() in javascript is able to return 1, right? Which means if I would be to use it to get a random index on my array the following code could fail:
between 0 (inclusive) and 1 (exclusive) - cannot be 1
Your code is all right