/* FILTER The filter() method helps you pick out specific items from a box of things (an array) based on certain criteria. Think of it like a filter or sieve that lets only certain items through. What it does: filter() goes through your array and checks each item using a special test (a function). If an item passes the test (the function returns true for that item), it goes into a new box (a new array). If it fails the test (the function returns false for that item), it's left out. */ const numbers = [1, 2, 3, 4, 5]; const evenNumbers = numbers.filter(function (num) { return num % 2 === 0; }); console.log(evenNumbers); // Output: [2, 4] /* map() Method: The map() method is like a magic wand for arrays in JavaScript. Imagine you have a box of numbers (an array), and you want to do something to each of these numbers, like doubling them, squaring them, or changing them in some way. The map() method helps you with this. What it does: map() creates a brand new box (a new array) and fills it with the results of applying a special rule (a function) to each number in your original box (array). */ const numbers = [1, 2, 3, 4, 5]; // Let's double each number using map() const doubledNumbers = numbers.map(function (number) { return number * 2; }); console.log(doubledNumbers); // Output: [2, 4, 6, 8, 10]