Skip to content

Latest commit

 

History

History
17 lines (13 loc) · 477 Bytes

File metadata and controls

17 lines (13 loc) · 477 Bytes

Array reduce() Method

The array reduce() method in JavaScript is used to reduce the array to a single value and executes a provided function for each value of the array (from left-to-right) and the return value of the function is stored in an accumulator.

    var  pokemon  = ["Squirtle", "Charmander", "Bulbasaur"];
    
    var  pokeLength  = pokemon.reduce(function(previous, current) {
        return  previous  +  current.length;
    }, 0);

Output

27