Javascript functions

    // .filter()
    const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present', 'happy'];
    let longWords = words.filter(word => word.length > 6);
    console.log('longWords', longWords);
    // longWords (3) ["exuberant", "destruction", "present"]
    console.log('words', words);
    //(7) ["spray", "limit", "elite", "exuberant", "destruction", "present", "happy"]

    // .map()
    const numbers = [1,4,9];
    const roots = numbers.map(Math.sqrt);
    console.log(roots);
    // (3) [1, 2, 3]
    console.log(numbers);
    // (3) [1, 4, 9]

    // .reduce()
    let arr = [0,1,2,3,4];
    const reduceFunc = arr.reduce(function(accumulator, currentValue, currentIndex, array){
        return accumulator + currentValue; 
    }, 0);

    console.log(reduceFunc);
    // 10

    // .forEach()
    const items = ['item1', 'item2', 'item3'];
    const copy = [];
    items.forEach(function (item) {
        copy.push(item);
    });
    console.log(copy);
    // (3) ["item1", "item2", "item3"]

    // .some()
    const isBiggerThan10 = function (element, index, array) {
        return element > 10;
    }

    let someArr1 = [2,5,8,1,4];
    let someArr2 = [12,5,8,1,4];

    console.log(someArr1.some(isBiggerThan10)); // false
    console.log(someArr2.some(isBiggerThan10)); // true

    // .Object.value(), .Object.keys(), .Object.entries()
    const obj = {0: 'a', 1: 'b', 2: 'c'};
    console.log(Object.keys(obj));      // ["0", "1", "2"]
    console.log(Object.values(obj));    // ["a", "b", "c"]
    console.log(Object.entries(obj));   // ["0", "a"], ["1", "b"], ["2", "c"]