filtering items javascript code example
Example 1: javascript array filter
var numbers = [1, 3, 6, 8, 11];
var lucky = numbers.filter(function(number) {
return number > 7;
});
Example 2: filter out arrays js
let newArray = array.filter(function(item) {
return condition;
});
Example 3: javascript array filter
var newArray = array.filter(function(item) {
return condition;
});
Example 4: javascript array filter
run.addEventListener("click", function () {
let array = [];
people.forEach((elem) => {
if (elem.age > 18) {
array.push(elem);
} else {
("");
}
});
console.log(array);
});