Skip to main content

Practice ยท 3 of 3

Timeout Race

CHALLENGE
Difficulty: intermediate+25 XP

Write async function withDeadline(task, ms, onTimeout) where task is a promise. If task fulfills within ms, RETURN its value. Otherwise RETURN the result of calling onTimeout(). The underlying task is NOT cancelled (that comes later) โ€” you simply stop waiting.

Back to lesson: Practice: Promise Combinators โ€” Practice