Not that the pen I posted has very logical code, I didn’t go in too deep but wanted to show that a loop would be easiest and that the previous position of the car needed to be accounted for.
For throwing the dice this isn’t really accurate either – I think you could end up with a zero. Then again with the first fiddle you could both do that and you couldn’t throw a 6 (Math.floor rounds down). But with the shuffle function from the other topic you could do something like this :
var rolled = dice;
This was a quick fix by the way :
position = position || 0;
For some reason it doesn’t return a bottom position on the first click.
I updated the link in the previous post with the shuffle approach…