I have a loop that looks like this:
var selectionList = document.querySelectorAll(".product");
selectionList.forEach(selectionItem => {
var selectionItemTitle = selectionItem.querySelector(".product-title");
}
Inside of my loop I want to ad a condition that says "If this title is not equal to NONE, add this to an array with all the others. See below my note in the code:
selectionList.forEach(selectionItem => {
var selectionItemTitle = selectionItem.querySelector(".product-title");
if(selectionItemTitle.textContent != 'None'){
// this is where I am stuck (I don't know what to add inside of my condition)
}
}
Basically what I want to do is, all the "selectionItemTitle" that passes the conditon needs to be added to an array so I can use that array some place else.
Is this even possible?
Quick note: The reason why I am using a loop, is because I have lots of other code in it (the above is just an example). So I really want to stick to the loop.
forEachand then usepushif theifcondition is true.