Below is my JavaScript code snippet:
let x = Math.floor(Math.random() * 6) + 1);
if (x == 1){
do this
} else if (x == 2){
do that
} else if.... and so on.
Every time I run this code in a browser, only actions related to the {do this} section seem to be executed. The value of x appears to always be stuck at 1, even though it should simulate a fair 6-sided die. Can anyone explain why this behavior is occurring and suggest a solution?