Mark As Completed Discussion

One Pager Cheat Sheet

  • Using the built-in JavaScript methodreduce()you can create a single value from the elements in an array by running a user-supplied "reducer" callback function on each element, optionally passing an initial value first.
  • We created a custom function, myReduce, that takes a callback function and an optional initialValue as arguments, and loops through the array elements by calling the callback with the adequate parameters, returning the final result value.

This is our final solution.

To visualize the solution and step through the below code, click Visualize the Solution on the right-side menu or the VISUALIZE button in Interactive Mode.

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment

You're doing a wonderful job. Keep going!

If you had any problems with this tutorial, check out the main forum thread here.