Struggling with my project

My code for the random number looks correct but it keeps failing
https://codepen.io/coderkoji/pen/NWRyKMx
can you tell me whats wrong with the Math.random

Can you describe how your current results differ from your desired results?

the users supposed to enter how many sides yourdie have. for ex if user enters 48 the random num is from 48 to 1

I would recommend starting by removing the loop from the equation for now. What you currently have is causing an infinite loop which will be annoying to work with (the browser will eventually detect the stall and ask if you want to wait or not).

Then I would say validate what you think you’re getting back from `prompt`. Is it the data and type you expect? If so, continue by using it to generate the random number, verify the statement you have is generating numbers as you expect. Once that looks good then go on to adding the loop back in.

As said, you have an infinite loop. You can initialize `sides` to 0 before the prompt, or create a function for the while loop that doesn’t run until after the prompt and variable declarations.

You are using the same variable for the while loop condition and snake eyes count. You can use a while (true) loop and `break` when the condition is met.

You need to count the number of times the loop runs and the number of times the random number is 1. You need to print the number of times the loop ran when the random number has produced the number 1 two times.

You are using an assignment operator where an equality operator is expected.

``````if(i = 2) {
printToScreen("It took" + i + " times to roll snake eyes")
}
``````

my loop is infinite but i dont understand how it is
https://codepen.io/coderkoji/pen/NWRyKMx
can you tell me how to fix it

It looks like you are working on the code right now which makes it a little hard to comment on it, if it keeps changing.

Do note that you will reinitialize the `x` variable on each while loop iteration.

``````let x = 1;
console.log(x) // always 1
x++;
``````

You can move the variable out of the while loop to the top with the other variables.