Command Palette

Search for a command to run...

Hectal
Phase 2: Functions
TypeScript · Exercise 2 of 6 PreviousNext
Beginner

Defaults and Rest

join should glue words together with a separator. Give separator the default ", " and collect all remaining arguments in a rest parameter words (an array of strings).

join(undefined, "a", "b", "c") must print a, b, c, and join(" - ", "x", "y") must print x - y.

What Check tests

  1. Your code has no type errors
  2. The console prints a, b, c and x - y
  3. A number among the words is rejected
  4. Calling join() with no words is allowed

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Console

Nothing printed yet.