Advertisement
BojidarDosev

.reduce() func

Mar 11th, 2024
696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  const newNumbers = [1, 3, 5, 7];
  2.  
  3. const newSum = newNumbers.reduce((accumulator,currentValue) =>
  4.   {
  5.       console.log('The value of accumulator: ', accumulator);
  6.       console.log('The value of currentValue: ', currentValue);
  7.       return currentValue+ accumulator;
  8. //second arg  
  9. },10);
  10.  
  11. console.log(newSum);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement