remove items from two indexes javascript code example

Example 1: javascript removing items looping through array

var colors=["red","green","blue","yellow"];
//loop back-words through array when removing items like so:
for (var i = colors.length - 1; i >= 0; i--) {
    if (colors[i] === "green" || colors[i] === "blue") { 
        colors.splice(i, 1);
    }
}
//colors is now  ["red", "yellow"]

Example 2: lodash remove multiple items from array

var colors = ["red","blue","green","yellow"];
var removedColors = _.remove(colors, function(c) {
    //remove if color is green or yellow
    return (c === "green" || c === "yellow"); 
});
//colors is now ["red","blue"]
//removedColors is now ["green","yellow"]