I am trying to select all the elements in an Array that contain the word "Orange", independently of the number before.
I tried with this code, but it is only working when I write the exact element name like "02orange".
var DWArray = ["apple", "apple", "02orange", "03orange", "04orange", "potato"];
function checkOrange(orange) {
return orange == "02orange";
}
var OrangeArray = DWArray.filter(checkOrange);
return OrangeArray.join(", ");
My desired result is:
["02orange", "03orange", "04orange"];