The filter() method creates a new array with all elements that pass the test implemented by the provided function.
var words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter(word => word.length > 6);
console.log(result);
// expected output: Array ["exuberant", "destruction", "present"]
//another example
// filter: creates a new array with elements that pass the test of the provided function
const mNames = names.filter(function(name) {
return name.startsWith("M");
});
console.log("m-names: ", mNames);