Javascript
May 2, 2026
Spot the bug: This should double every number in the array.
const numbers = [1, 2, 3, 4]
const doubled = numbers.map(n => {
return n * 2
console.log(n)
})
console.log(doubled)
Explanation
Anything written after a return statement never executes — the function exits immediately when it hits return. So console.log(n) is dead code. This is called "unreachable code." Move console.log before return if you want to see the values.
📝
Reviewed by CodeShot Editorial
Every challenge is code-reviewed by senior developers to ensure accuracy and real-world relevance. Learn more.