更新时间:2023-11-28 17:12:40
为什么要比较图像呢?这是很难确定相同的数字是否被选中3次。
由于每个图像与单个整数值直接相关,您只需比较整数值(randImg1,randImg2,randImg3)。图像与比较没有任何关系。它们只是所选值的直观表示。
您的代码检查所有3个值是否相互匹配,但您从未将它们与值进行比较0,这是草莓图像所代表的。
Why are you comparing images at all? That's the hard way to figure out if the same number was picked 3 times.
Since each image is directly related to a single integer value, you just compare the integer values (randImg1, randImg2, randImg3). The images will have nothing at all to do with the comparison. They are just a visual representation of the value that was picked.
Your code checks to see if all 3 values match each other, but you never compare them to the value 0, which is what is represented by the strawberry image.
试试这个
try this
if (randImg1 == randImg2 && randImg2 == randImg3 && images[randImg3] == "strawberry.jpg") {
alert('message')
}