I have a JS function that creates an array based on the filters the user selects (this part works fine), and then I have another function (below) which loops through this array and should return true if the value is contained in the string and false if not.
var testString = "winter casual";
var valArray = ["winter", "casual"];
function filterArray(...values){
for (i=0; i<values.length; i++){
if (testString.includes(values[i])){
console.log(true);
} else {
console.log(false);
}
}
filterArray(valArray);
However, I click 1 filter button to add "winter" to the values array and it returns "true", but then I click another to add casual and it returns false, even though casual is included in the string as well. I have console logged values[] to ensure that both "winter" and "casual" are in my array, and they are.