I have an event-listener that adds a new item to an array every time I click an image. How can I check if the item newly-added to the array matches an item in the other array?
let a = ['a', 'b', 'c', 'd']
let b = []
grid.addEventListner('click', (e) =>{
let clicked = e.target
b.push(clicked)
// Here is where I want to check if the variable "clicked"
// which is pushed in to the b array matches
// the value on the same position in the a array. So for
// every click if its right I add a // green class and if
// its not I add a red class and finish the possibility
// to play.
})
Hope I was able to explain the problem :)