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) [4, 6]
D) Error
✅ Answer: B) [undefined, 4, 6]
Explanation:
map() always returns same length
For num = 1, nothing returned → undefined
3. What is the output?
let arr = [1, 2, 3];
let result = arr.filter(num => num > 5);
console.log(result);
Options:
A) [undefined]
B) []
C) null
D) Error
✅ Answer: B) []
Explanation:
No elements match → empty array
4. What is the output?
let result = [1, 2, 3].reduce((acc, val) => acc + val);
console.log(result);
Options:
A) 6
B) 0
C) undefined
D) Error
✅ Answer: A) 6
Explanation:
Default acc = first element = 1
→ 1+2=3 → 3+3=6
5. What is the output?
let arr = [1, 2, 3];
let result = arr.some(num => num > 2);
console.log(result);
Options:
A) true
B) false
✅ Answer: A) true
One element (3) satisfies condition
6. What is the output?
let arr = [2, 4, 6];
let result = arr.every(num => num % 2 === 0);
console.log(result);
Options:
A) true
B) false
✅ Answer: A) true
All elements satisfy condition
7. What is the output?
let arr = [1, 2, 3];
arr.map(num => num * 2);
console.log(arr);
Options:
A) [2, 4, 6]
B) [1, 2, 3]
C) undefined
D) Error
✅ Answer: B) [1, 2, 3]
map() does NOT modify original array
8. What is the output?
let arr = [1, 2, 3];
arr.forEach(num => num * 2);
console.log(arr);
Options:
A) [2, 4, 6]
B) [1, 2, 3]
✅ Answer: B) [1, 2, 3]
forEach doesn’t change array unless you modify directly
9. What is the output?
let arr = [1, [2, 3]];
console.log(arr.flat());
Options:
A) [1, 2, 3]
B) [1, [2,3]]
✅ Answer: A) [1, 2, 3]
10. What is the output?
let arr = [1, 2, 3];
let result = arr.reduce((acc, val) => acc + val, 5);
console.log(result);
Options:
A) 6
B) 11
C) 10
✅ Answer: B) 11
5 + 1 + 2 + 3 = 11
11. What is the output?
console.log([..."hello"]);
Options:
A) "hello"
B) ["h","e","l","l","o"]
✅ Answer: B
12. What is the output?
let arr = [10, 20, 30];
console.log(arr.at(-1));
Options:
A) 10
B) 30
C) undefined
✅ Answer: B) 30
United States
NORTH AMERICA
Related News
How Braze’s CTO is rethinking engineering for the agentic area
11h ago
Amazon Employees Are 'Tokenmaxxing' Due To Pressure To Use AI Tools
22h ago
KDE Receives $1.4 Million Investment From Sovereign Tech Fund
2h ago
Instagram’s new ‘Instants’ feature combines elements from Snapchat and BeReal
2h ago
Six Claude Code Skills That Close the AI Agent Feedback Loop
2h ago