for(let [key, value] of Object.entries(dropdownData)) {
if($.inArray(key, _.attr("class").split(" "))) {
console.log("key found class:"+key);;
break;
}
}
I have 40 or so elements. These elements can have a variety of classes on them. I am trying to loop over each of these elements to see if they have a class that matches one of these keys
const dropdownData = {
"elementary": "Elementary Schools",
"middle": "Middle Schools",
"high": "High Schools",
"center": "Centers"
};
Even though I have multiple elements with other classes, I ONLY get “elementary” returned in my console log. Where’s my logic going wrong here? I read the for loop
code as:
For loop will make it so I can loop over each key value Then I use the If statement to check whether my element _ has a class that matches my key
The first 20 or so have “elementary” but then the next several should be middle, then high, then center.