Skip to main content

Practice ยท 3 of 3

Result Wrapper

CHALLENGE
Difficulty: intermediate+25 XP

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.

Back to lesson: Practice: Generics โ€” Practice