Escape Hatches

Escape Hatches
πŸ‘¨β€πŸ’Ό Sometimes you need to work with data whose type you don't know. Let's see how any and unknown differ.
🐨 Open
index.ts
and:
  1. Read dangerousProcess β€” it uses any and can call methods unsafely
  2. Implement safeProcess so unknown input is handled safely. Required outputs:
    • string β†’ uppercased (hello β†’ HELLO)
    • number β†’ two decimal places (123 β†’ 123.00, 3.14159 β†’ 3.14)
    • boolean β†’ true / false
    • other values β†’ their usual string conversion (null β†’ null, undefined β†’ undefined, and {} β†’ [object Object])
  3. Export safeProcess by name (you can leave dangerousProcess as the contrast example)

Completion criteria

  • Named export: safeProcess
  • Matches the string / number / boolean outputs above
  • Matches the listed outputs for null, undefined, and plain objects without throwing

Please set the playground first

Loading "Escape Hatches"
Loading "Escape Hatches"
Login to get access to the exclusive discord channel.
Loading Discord Posts