array.filter()
- Takes an array
- A callback function filters the array
- Filter is applied to each array item
- If the value matches the filter (truthy), it's added to a new array
- If it doesn't match (falsy), ignore it
- Returns a new array
var fruits = ['pear', 'banana', 'plum'];
const result = fruits.filter(fruit => fruit.length < 5);
console.log(result);
// output: Array ['pear', 'plum']
Code inside the conditional block will execute if the first statement is true
// The 'true' value // can be replaced // with another conditional if (true) { // inner code executes // if the conditional // is evaluates to true }