var arrayOne = ["green", "blue", "yellow", "red"];
var arrayTwo = ["blue", "red", "blue", "yellow"];
Does anyone know how I would go about telling the user that arrayOne contains three colors from arrayTwo? These colors can not be at the same index. For example, if "green" is at index 0 at both arrayOne and arrayTwo, then it does not count as a color. I only need colors that are in both arrays that are not at the same index.
I know there's .indexOf() but I don't need the index of the occurrence. For example, if I did indexOf for blue in arrayTwo, I would get "0" returned (index of first occurrence) but I'd have no idea blue was also there again at index 2.
I was hoping the output to be something such as "alert("Three colors have matched but not at the same position");
Any advice would be appreciated!