Leaderboard Archive
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)
A n * 2 should be n + n
B console.log is after the return so it never runs
C .map should be .forEach
D The array name is wrong
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.

Ready for your shot?

Join thousands of developers solving one logic puzzle every morning.

Solve Today's Challenge →