Check out a free preview of the full Functional-Lite JavaScript course:
The "Exercise 3" Lesson is part of the full, Functional-Lite JavaScript course featured in this preview video. Here's what you'd learn in this lesson:

In this exercise, you will turn the mult() function into a recursive function that can work on as many arguments as necessary.

Get Unlimited Access Now

Transcript from the "Exercise 3" Lesson

[00:00:00]
>> [MUSIC]

[00:00:03]
>> Kylel Simpson: Exercise 3. Let's pull up Exercise 3. Do a tad bit of experimentation with our understanding of recursion.
>> Kylel Simpson: Exercise 3. Take mult, which is already defined, turn it into a recursive function that can work on as many arguments as necessary. So what is mult, how is mult currently defined?

[00:00:35] It only works with three parameters x, y and z. Line seven would create a problem for us because it's still going to return 60 instead of 360 the way we expect. You could do this intuitively with for loop, and if that helps you turn it first into an intuitive solution.

[00:00:54] If that helps. But the exercise here is to ask yourself what is the multiplication of all these arguments? And by the way, it's going to look an awful lot like that last slide that we just looked at.