Repaso
Español

What is the result of [1, 2, 3].map(x => x * 10)?

Options

  1. undefined
  2. [10, 20, 30] (Correct option)
  3. 60
  4. [1, 2, 3]

Answer

[10, 20, 30]

Why

map calls the function on each element and returns a NEW array with the results; the original is unchanged.

forEach also calls the function on each element, but returns undefined; use it only for side effects like logging.

Related: filter keeps elements where the function returns true; reduce combines everything into one value.

Remember

map → new array of results. forEach → nothing returned.

Key terms

Practice this question in Repaso