Find: Missing Readonly
Find the Mistake Medium
Question
This code has a type error. Find the mistake:
Code
const arr: readonly number[] = [1, 2, 3];
arr.push(4);
Hint
Readonly arrays cannot be mutated. What method is being called?
Explanation
The array is declared as readonly number[], which means it cannot be mutated. The push method is not available on readonly arrays. TypeScript errors: Property 'push' does not exist. Fix: create a new array instead: const newArr = [...arr, 4]; or remove the readonly modifier if mutation is intended.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.