I have two arrays with exact same values and index
const colors = ["#da9f64", "#f67dd1", "red", "gray"];
const colorsff = ["#da9f64", "#f67dd1", "red", "gray"];
I want to create a function that will do something particular IF either values or index of arrays match
something like this
function colorsMatch(){
if(colors.indexof() === colorsff.indexof()){
someHtmlElement.classList.remove('d-none')
}
}
I tried everything i was able to look up
2
Answers
You’ll need a loop of some kind:
If your goal is to execute an action if all elements of two arrays match up, and you’re sure they have the same length, you could do something like this.