DEV Community

Discussion on: Frontend interview - Questions I was asked

Collapse
faiwer profile image
Stepan Zubashev
result.reduce((acc, item) => acc + item.x, 0)

people.reduce((acc, item) => {
  if (item.gender === 'male') acc.male.push(item);
  else acc.female.push(item);
  return acc;
}, { male: [], female: [] });

eval(value.split('=')[0])
Enter fullscreen mode Exit fullscreen mode
Collapse
diogo405 profile image
Diogo Goncalves

people.reduce(...) answer is a masterpiece 👏🏻

Collapse
rajeshroyal profile image
Rajesh Royal Author • Edited on

Masterpiece.