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
MCQs on Array Methods
Kesavarthini·Dev.to··1 min read
D
Continue reading on Dev.to
This article was sourced from Dev.to's RSS feed. Visit the original for the complete story.