Advertisement
pulusatapathy

reduce method

Oct 23rd, 2020 (edited)
1,802
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let xx = [1,2,3,4,5,6,7,8,9,10]
  2. let rslt = xx.reduce((a,c) => a+c)
  3.  
  4. OR
  5.  
  6. let rslt = xx.reduce((a,c) => a+c,0) // here 0 is initial cond
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement