Skip to main content

Practice ยท 3 of 3

Failure Messages That Help

Write fmt(v) producing readable failure output: strings render with quotes, undefined/null render as their names, arrays render as [a, b, c] with fmt applied to items, plain objects render as {k: v, ...} with fmt values, functions render "function", everything else String(v).

Difficulty: intermediate

Back to lesson: Practice: Build Your Own Assertions โ€” Practice