Don't see the reason on adding one


#1


I don't get why we add the one to the math.random()5 + 1); if the math.random5 is already 0 - 5 range
wouldn't the plus one make it between 1 and 6?

First we use Math.random() to create a random number from 0 up to 1. For example, 0.5

Then we multiply by 5 to make the random number from 0 up to 5. For example, 0.5 * 5 = 2.5

Next we use Math.floor() to round down to a whole number. For example, Math.floor( 2.5 ) = 2

Finally we add 1 to change the range from between 0 and 4 to between 1 and 5 (up to and including 5)


var damageThisRound = Math.floor(Math.random()*5 + 1);


#2

because the damage you want to deal is one of the following: 1,2,3,4,5

If you don't add one, you can't get 5 and you could hit zero, but for this we already have youHIt


#3

So the Math.floor is going to round a 4.8 or a 4.9 down to 4?


#4

no, math floor will floor 4.8 or 4.9 to 4, if you would round 4.8 or 4.9 you would get 5.


#5

Okay thank you I get it! I used the wrong wording for the rounding