Assessment needed for "Test your Skills: Function 3"

When I saw the answer of this question,I have a little question.
The answer said:
The random() is const num = Math.floor(Math.random() * (max - min)) + min. And the function call is let choice = array[random(0, array.length)].
But this can’t have the max one of the number, so the last name in the array will never display.

I thought it should change the random() into const num = Math.floor(Math.random() * (max - min + 1) + min) or change the function call into let choice = array[random(0, array.length + 1)] can display the last name in the array.

Am I right? Or if I wrong, please tell me where, thank you very much.

ops you missed something
array.length return the number of elements
so for array of 4 element
math.random() * (4-0 ) + 0
so the max will be 3 in that case which will be right for the last index of the array
last index of array of 4 element is 3 as it has those indexs 0 1 2 3

Thank you! I checked this before, but still thank you very much!

ops i was mistaken i just updated my post
and you very welcome :slight_smile:

Ah! Now I get why the answer writes like that! And I was wrong. Thank you so much again!

you very welcome :slight_smile: