JavaScript Rest Parameters — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Rest Parameters lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Add up any number of values
easy10 minUse a rest parameter to add 1, 2, 3 and 4.
- 2
Count the extras
easy10 minCount how many scores were passed after the title.
- 3
An empty rest parameter
easy10 minShow the length when no extra arguments are given.
- 4
Use an array method
easy10 minFind the largest of 5, 12, 8 and 44 using a rest parameter.
- 5
Spread into a rest parameter
medium10 minSpread an array of three items into a function that collects them, then show the count.
Find the bug(5)
- 1
Fix the missing dots
easy8 minWithout the three dots only the first argument is received.
- 2
Fix the rest parameter used first
easy8 minA rest parameter must be last, so the title is being swallowed.
- 3
Fix the undefined length
easy8 minReading length on a plain parameter that was never passed fails.
- 4
Fix the array passed whole
easy8 minMath.max needs separate numbers, not one array.
- 5
Fix the array passed as one argument
easy8 minWithout spreading, the function receives a single array.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace