Skip to main content

Practice ยท 1 of 3

Shape Checker

Write hasShape(obj, spec) โ€” spec maps field names to expected typeof strings ("string", "number", "boolean"). RETURN true only when obj is a non-null object and every spec field exists with the exact typeof. Extra fields on obj are allowed (structural typing).

Difficulty: intermediate

Back to lesson: Practice: Shapes & Inference โ€” Practice