U06L07P09 - Dice App

When setProperty(“dice”+i,“border-width”,1); is added to the code and you roll the dice many times, the dice seem to move to the left … WHY??? This bothers me soooo much and I can’t explain it to my kids. We need the border width so the white border only shows up for even numbers.

Thanks.

Did you look at the exemplar provided. I ran it and the dice don’t seem to be moving in that. Please share your code.

Absolutely! There’s a little difference in the code to the exemplar, but it shouldn’t make a difference … thanks for looking at it.

onEvent(“rollButton”, “click”, function( ) {
var odds = 0;
var evens = 0;
for(var i = 0; i < 20; i++){
var roll = randomNumber(1,6);
setProperty(“dice”+i,“text”,roll);
setProperty(“dice”+i,“border-width”,1);
if(roll == 1 || (roll == 3) || (roll == 5)){
odds++;
setProperty(“dice” + i, “border-color”, “black”);
} else {
evens++;
setProperty(“dice” + i, “border-color”, “white”);
}
setProperty(“informationLabel”,“text”,"Total Odds: " + odds + "\nTotal Evens: " + evens);
}
});

I’m sorry I still don’t see the dice moving left. Is it an illusion since the width of the numbers may be different.

shrug I have no idea! This is what I see.

This is not happening for me. I copy pasted your code into AppLab and ran it. Here is a link to my remixed project! Did you try different browsers?

I did try it at home last night and did not experience the drifting … Chrome was the browser I was using.

Then when I came to school (using Chrome), it was drifting. It happened with all of my students at school too. So it’s a weird thing, but not actually a coding problem. I can live with that. Strange tho.

1 Like

Did the same left moving phenomenon to two student in my class using Chrome browser. It does not do the same on Internet Explorer so it most likely is just a browser issue. Fun phenomenon though.

1 Like