I am struggling with looping through an array of items and applying some code to each item while excluding one specific item (the clicked-on item). I have experimented with using splice, but that method ends up removing the array item completely, whereas I just want to skip over it. Specifically, I am trying to remove a CSS class from each item in the array except for the excluded one.
I have attempted different approaches, such as using splice and also trying conditional statements like if (array[i] == 3 || (i - 1) = 2) { continue; else { .... }, but none of them seem to work successfully.
var array = ["item1", "item2", "item3"];
var i;
for (i = 0; i < items.length; i++) {
if(array[i] is the excluded one){
skip over}
else { $(items[i]).removeClass('class');
}
Although no error messages are being displayed, the code is not functioning as expected.