Posts Tagged

array

How To Use Reduce( ) in Javascript

[10,1000].reduce( (finalValue, whatToAddToFinalValue) => finalValue + whatToAddToFinalValue ); The array has 2 items [10, 1000], which means we run 2 iterations. On each iteration, reduces() takes 1 item ONLY! For the FIRST iteration, since we did not declare the finalValue starting value, so it will always be 0 : We have whatToAddToFinalValue variable, which will…

Read More