+ 6
[Solved] Why does always one image doesn't show up??
6 Antworten
+ 6
because you use ceil() on random number generator, while you must use floor(): Math.random return a float between 0 (inclusive) and 1(excluded), so ceil() return int between 1 to 6 (both inclusives) while you need 0 to 5 (zero based indexes)...
tips: using bitwise OR operator get almost the same result as floor() (for numbers lesser than 2 ^32)
num = Math.random()*6 | 0;
(precedence of operators allow to spare parenthesis)
+ 3
Looper🐼 🇮🇳 are you kiding?
you just use the tip I given in my post, without removing the ceil() function: its unuseful as equivalent to ceil() an int, or ceil() a floored value...
+ 3
Looper🐼 🇮🇳 what are you talking about man?
you said visph was a dumb programmer just because he said they work on his device?
he also suggested a solution to a problem that he didn't even exprience.
saying that he is dumb just because you didn't understand what he was talking about, is kinda ironic.
+ 2
visph Thank you so much sir for helping 🤗🤗
+ 2
Looper🐼 🇮🇳 all image links of OP code perfectly works on my side ^^ and if I have noticed problems I maybe (offtopic regarding the question) have suggested to not use images but draw dice faces with html... rather than using url of images wich fit less good than original ;P
anyway, I never claimed for "copyright patent tip", I just said that you doesn't give anything new, even more you let some unuseful stuff...
+ 2
visph thanks for your suggestion 🤗🤗