Hi I’ve been having so trouble with this project I need to change colors or matching numbers in 2 arrays, but have the remaining numbers stay there natural color.
for(d = 0; d < lotteryNums.length; d++) {
for(x = 0; x < quickDrawNums.length; x++) {
if(lotteryNums[d] == quickDrawNums[x]) {
quickDrawNums[x] = "<span class='winner'>" + quickDrawNums[x] + "</span>";
winCounter++;
} else {
quickDrawNums[x] = "<span class='number'>" + quickDrawNums[x] + "</span>";
}
}
}
When I have this display it gives me 5 empty boxes and 1 box with the number in it. It also stops my match if from working I was just wondering if anybody could help me sort this out. Thanks for the help in Advance 🙂
You need to remove the “else” because you are re-writing all the quickDrawNums every time the next lotteryNums is selected. This would result in only on class =’winner’ on the last lotteryNums item. Not sure why the empty boxes appear. Verify the original “else” has correct spelling and case for objects, etc.