javascript array filter

JavaScript
var words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];

const result = words.filter(word => word.length > 6);

console.log(result);const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];

const result = words.filter(word => word.length > 6);

console.log(result);
// expected output: Array ["exuberant", "destruction", "present"]var numbers = [1, 3, 6, 8, 11];

var lucky = numbers.filter(function(number) {
  return number > 7;
});

// [ 8, 11 ]const filterThisArray = ["a","b","c","d","e"] 
console.log(filterThisArray) // Array(5) [ "a","b","c","d","e" ]

const filteredThatArray = filterThisArray.filter((item) => item!=="e")
console.log(filteredThatArray) // Array(4) [ "a","b","c","d" ]
var newArray = array.filter(function(item) {
  return condition;
});  run.addEventListener("click", function () {
    let array = [];
    people.forEach((elem) => {
      // elem before age to target
      if (elem.age > 18) {
        array.push(elem); // each array elem > 18 is "pushed" inside the new array
        // console.log(array); nope : messes things up
      } else {
        (""); // no need to declare this through console.log
      }
    });
    console.log(array); //and there you have it : filtered array
  });
Source

Also in JavaScript: