Allow Two Kinds of Value

Write the code, see it run, pass the checks.

The problem

  • easy
  • Code

Order ids arrive either as numbers (42) or as strings ("42"). Write formatId(id), which accepts either and returns "#" followed by the id padded with zeros to 5 digits, like "#00042". Anything else, like a boolean, should be a type error.

Your code must pass

  • Formats a number id
  • Formats a string id
  • Has no type errors
  • Takes a string or a number
  • Rejects a boolean