Predict Array push Output
Predict Output Easy
Question
What does this code print?
Code
let nums = [1, 2];
nums.push(3);
console.log(nums);
Hint
push adds an element to the end of the array.
Explanation
The array starts as [1, 2]. push(3) adds 3 to the end, making it [1, 2, 3]. console.log prints the full array: [1, 2, 3]
Related Resources
Related Lessons
- Arrays
Learn how arrays store ordered lists of values.
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.