I am trying to loop through an array and filter out all the items that do not match specific values.
For example I have this array:
const emails = ["nick@hotmail.com", "nick@yahoo.com", "nick@gmail.com", "bob@yahhoo.com", "bob@gmail.com", "boc@test.com"];
I would like to filter out emails that end in"
*@hotmail.com *@gmail.com
I have given it a go and got this but this doesn't work:
const filtered = emails.filter((email) => {
return !email.includes('@hotmail.com') || !email.includes('@gmail.com');
});
The preferred output from the example above would be:
["nick@yahoo.com", "bob@yahhoo.com", "boc@test.com"]