JavaScript Function Parameters — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Function 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
Use two parameters
easy10 minWrite a function that joins a name and a city with the word from.
- 2
Order matters
easy10 minCall a divide function so it works out 20 divided by 4.
- 3
Handle a missing argument
easy10 minShow the word missing when the second argument is left out.
- 4
Parameters are local
easy10 minShow that changing a parameter does not change the outside variable.
- 5
Objects are shared
medium10 minChange a property inside a function and show the object was really changed.
Find the bug(5)
- 1
Fix the swapped arguments
easy8 minThe two values are passed in the wrong order.
- 2
Fix the reversed division
easy8 minThe parameters are divided the wrong way round.
- 3
Fix the wrong emptiness check
easy8 minComparing with null does not catch a missing argument.
- 4
Fix the parameter name typo
easy8 minThe body uses a name that does not exist.
- 5
Fix the object that was replaced
easy8 minReplacing the parameter does not change the original object.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace