(upbeat music) … - So I'm going to show you how I solve this now. … First of all the tricky part here is that we want this … function to be independent of the names that are actually … in the array. … As I mentioned before, we're not allowed to hard code … any of these names into the function. … So what I'm going to do for this function is use reduce. … So we're going to say return votes.reduce and remember … that reduce takes two arguments the accumulator, … which will be the votes that we've tallied so far … and the current element, which will be the name … of a certain candidate. … And now before we write out our function body we have … to think about what we want the starting value to be … for our reduce function. … What do we want it to start out with? … Well since our expected output is an object, it would … be a pretty good guess to say that we want our starting … value to be an object. … And in my case that's exactly what I'm going to do. … So now let's write the body of the function that we're …
- The goal of functional programming
- Declarative vs. imperative programming
- Ensuring immutability
- Arrow functions in ES6
- Passing functions as arguments
- Mapping, filtering, slicing, sorting, and reducing
- Advanced functional concepts, including recursion
Skill Level Intermediate
1. Introductory Functional Concepts
2. First-Class Functions
4. Advanced Functional Concepts
5. Code Conversion Challenges
Next steps1m 10s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.