If the number generated by getRandomInt(0, arrayRentadora.length)
is equal to arrayRentadora.length
, then arrayRentadora[index]
will be undefined
.
For example, if arrayRentadora = ["Banana", "Orange", "Apple", "Mango"]
, the length is 4, and arrayRentadora[4]
will be undefined
.
To ensure you always choose a value from the array, you want this instead:
var index = getRandomInt(0, arrayRentadora.length - 1);