<!DOCTYPE html> <html> <body> <script type="text/javascript">
var images = ["strawberry.jpg", "apple.jpg", "cherry.jpg", "orange.jpg", "pear.jpg"];
var length = images.length;
var randImg1 = Math.round(Math.random() * (length - 1));
document.write('<img src="' + images[randImg1] + '" >');
var randImg2 = Math.round(Math.random() * (length - 1));
document.write('<img src="' + images[randImg2] + '" >');
var randImg3 = Math.round(Math.random() * (length - 1));
document.write('<img src="' + images[randImg3] + '" >');
if (randImg1 == randImg2 && randImg2 == randImg3 && randImg3 == "strawberry.jpg") {
}
</script> </body> </html>
I want to compare the images of the arrays, if 3 images are strawberry there should be an alert box like "congrats you won" how can I do that ?