$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · medium · #35

What is the output?

const nums: number[] = [1, 2, 3];
console.log(nums.map(x => x * 2));
  1. [2, 4, 6]
  2. [1, 2, 3]
  3. 6
  4. [1,4,9]
map doubles each element producing [2, 4, 6].
Play Problem Solving ▸