Posts Tagged


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

For VS While Loop in Javascript

When we need to perform similar actions for certain number of times, that is when we get to “Looping”. For example, when we need to output goods from a list one after another. Or just run the same code for each number from 1 to 10. Loops are a way to repeat the same part…

Read More