This is wrong

Math.ceil(6 * Math.random());


This does not generate an random number between 1 and 6 as the text says.


It generates a number between 0 and 6 since Math.random() in rare cases returns 0 and 0 * 6 is 0 and Math.ceil(0) is 0.


Link to content: Learn to Code with JavaScript - Section 4

let randomNumber = Math.floor(Math.random() * 6) + 1;

console.log(randomNumber);

simple fix instead of 0 it will be 1 for the lower end. (Instead of Ceil use Math.floor)

1 Like

Thanks for pointing out the oversight. I have passed this on to HQ.

2 Likes