I’m nearly there but need one more push over the mind hurdle.
I understand how:
Math.random() * (max - min + 1)
… creates the distance between the min and max.
What makes no sense to me is how adding min at the end of :
Math.floor(Math.random() * (max - min + 1)) + min
… lets the computer know that it needs to shift that distance down or increase the min value.
My thinking goes:
Math.random( ) * (6 - 2 + 1)
Math.random( ) * 5
= 1.5…(for example)
Math.floor(1.5) + 2
1 + 2
Where has my understanding of this gone wrong?