DEV Community
•
2026-04-18 13:42
MCQs on Array Methods
1. What is the output?
[1, 2, 3].forEach(num => num * 2);
Options:
A) [2, 4, 6]
B) undefined
C) [1, 2, 3]
D) Error
✅ Answer: B) undefined
Explanation:
forEach() does NOT return anything → returns undefined
2. What is the output?
let result = [1, 2, 3].map(num => {
if (num > 1) return num * 2;
});
console.log(result);
Options:
A) [2, 4, 6]
B) [undefined, 4, 6]
C) ...