I'm making a Lotto game for school, I'm stuck at checking the matching numbers.
I've tried a nested for loop and although I can console.log out the matches, it gets overwritten in the next iteration of the loop and I don't understand how I can solve this.
These are my picked numbers, stored here.
myNumbers=[1,2,3,4,5,6,7]
These are the randomly drawn numbers
luckyNumbers=[35,3,17,26,21,9]
In this case there's a match for number 3. How do I check this so I can spit out my 2 different graphics, one for No match and one for Match?
for ( var i = 0; i < myNumbers.length; i++) {
for ( var e = 0; e < luckyNumbers.length; e++) {
if (myNumbers[i] == luckyNumbers[e]){
matchingPairs.push(myNumbers[i]);
document.getElementById("ball"+myCounter).src="img/ballCorrect"+myNumbers[i]+".svg";
}
else{
document.getElementById("ball"+myCounter).src="img/ballIncorrect"+luckyNumbers[myCounter-1]+".svg";
}
document.getElementById("ball"+myCounter).style.display="inline";
}
}