Skip to main content

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. 1

    Use two parameters

    easy10 min

    Write a function that joins a name and a city with the word from.

  2. 2

    Order matters

    easy10 min

    Call a divide function so it works out 20 divided by 4.

  3. 3

    Handle a missing argument

    easy10 min

    Show the word missing when the second argument is left out.

  4. 4

    Parameters are local

    easy10 min

    Show that changing a parameter does not change the outside variable.

  5. 5

    Objects are shared

    medium10 min

    Change a property inside a function and show the object was really changed.

Find the bug(5)

  1. 1

    Fix the swapped arguments

    easy8 min

    The two values are passed in the wrong order.

  2. 2

    Fix the reversed division

    easy8 min

    The parameters are divided the wrong way round.

  3. 3

    Fix the wrong emptiness check

    easy8 min

    Comparing with null does not catch a missing argument.

  4. 4

    Fix the parameter name typo

    easy8 min

    The body uses a name that does not exist.

  5. 5

    Fix the object that was replaced

    easy8 min

    Replacing 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