JSFiddle - React, Tailwind, and code Playground

HTML

<input type="submit" name="Submit" onclick="ver();" value="Submit"><br>

CSS

img {
	width: 100px;
}

JavaScript

function ver() {
	
	var imagenes = document.getElementsByTagName('IMG');
	var cuantos = [], indices = [];
	
	for(x = 0; x < imagenes.length; x++) {
	
		name = imagenes[x].name;
		
		if(name in cuantos)
			++cuantos[name];
		else {
			cuantos[name] = 1;
			indices.push(name);
		}
		
	}
	
	var msg = [], buenosDias = false;
	
	for(m = 0; m < indices.length; ++m) {
		
		indice = indices[m];
		
		if(cuantos[indice] > 1) {
			buenosDias = true;
		}
		
		msg.push("hay "+cuantos[indice]+" imagenes de tipo "+indice);
		
	}
	
	if(msg.length > 2) {
		lastmsg = msg.pop();
		msg = msg.join(", ");
		msg += " y " + lastmsg;
	} else {
		msg = msg.join(" y ");
	}
	
	alert(msg);
	if(buenosDias) alert("Buenos dias");
	
} 

var indice = 0;
enlace = new Array();
enlace[0] = '<img name="1" src="http://www.psdgraphics.com/file/red-number-0.jpg"/ >';
enlace[1] = '<img name="2" src="http://www.psdgraphics.com/file/red-number-1.jpg"/ >';
enlace[2] = '<img name="1" src="http://www.psdgraphics.com/file/red-number-2.jpg"/ >';
enlace[3] = '<img name="2" src="http://www.psdgraphics.com/file/red-number-3.jpg"/ >';
enlace[4] = '<img name="1" src="http://www.psdgraphics.com/file/red-number-4.jpg"/ >';
enlace[5] = '<img name="2" src="http://www.psdgraphics.com/file/red-number-5.jpg"/ >';
enlace[6] = '<img name="1" src="http://www.psdgraphics.com/file/red-number-6.jpg"/ >';
enlace[7] = '<img name="2" src="http://www.psdgraphics.com/file/red-number-7.jpg"/ >';
enlace[8] = '<img name="1" src="http://www.psdgraphics.com/file/red-number-8.jpg"/ >';
enlace[9] = '<img name="2" src="http://www.psdgraphics.com/file/red-number-9.jpg"/ >';

indice = Math.random() * enlace.length;
indice = Math.floor(indice);

window.addEventListener("load", function() {

	for(i = 1 ; i <= 3; i++) {
		if(indice == enlace.length) indice = 0;
		document.body.innerHTML += enlace[indice];
		indice++;
	}
	
});