Is there a reason to use Math.floor instead of Math.ceil

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

vs.

`var damageThisRound = Math.ceil(Math.random()*5);`

It seems like this would be the simpler. Am I missing something?

Is there a reason to use Math.floor instead of Math.ceil

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

vs.

`var damageThisRound = Math.ceil(Math.random()*5);`

It seems like this would be the simpler. Am I missing something?

**Analyse**:

- Let
`n = Math.random()*5`

. So, range for`n`

is`0 <= n < 5`

. - We have expressions A)
`Math.floor(n+1)`

and B)`Math.ceil(n)`

- At any decimal value, say
`4.3`

, both A and B give same value - PASS! - At any decimal value, say
`4.7`

, both A and B give same value - PASS! - At any decimal value, say
`4.5`

, both A and B give same value - PASS! - At any decimal value, say
`4.0`

, both A and B give different value - ERROR!

Thus, both do not produce the same value for all values of `n`

, and hence it would not be advisable to blindly replace all occurrences of expression A with B.

In case this is exercise related, I cannot help much without knowing the exercise link first.