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
and:
- Read
dangerousProcessβ it usesanyand can call methods unsafely - Implement
safeProcessso 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])
- string β uppercased (
- Export
safeProcessby name (you can leavedangerousProcessas 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