I have this simple loop:
for (i = 0; i < menuitem.length; i += 1) {
if (menuitem[i].href == window.location) {
menuitem[i].className = "current"
} else {
if (menuitem[i].nodeType !== 3) {
menuitem[1].className = "current";
}
};
how could I replace the else statement by “If all results of menuitem[i] are false”? because now for each single one that is false the else statement gets executed and I want to only execute it when the entire loop is false.
I hope I made myself clear.
Thanks for your help guys
To see if the whole array contains false values, you would do this:
To see if the whole array fails your condition, you can do this: