Skip to main content
All interview theory questions
array-methodseasy

When would you use map, filter and reduce?

Answer

map transforms every item and returns a new array of the same length. filter keeps the items that pass a test, so the result is the same or shorter. reduce folds the array into a single accumulated value — a total, a grouping, or even a rebuilt object. All three return new values rather than mutating, which is what makes them safe to chain.

Points an interviewer listens for

  • map: same length, transformed items
  • filter: subset, same items
  • reduce: many values folded into one
  • None mutate the source array

Reported at

Similar questions have been reported by candidates at Deloitte, Desun Technology, Digiflux Technologies Private Limited, Easework AI, FactWise, Gaian Solutions India.

Now try answering it out loud

Interview practice mode times your spoken answer and checks it against the points above.

Practise this question

More array-methods questions