Practice ยท 3 of 3
Result Wrapper
Write attempt(fn) โ calls zero-argument fn. On success RETURN { ok: true, value }; on throw RETURN { ok: false, error: err.message }. The value keeps whatever shape fn returned (number, array, object โ anything), proving the wrapper is shape-agnostic.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Generics โ Practice