Blurred employer
Cover image for Meta
Logo
See All Photos

Meta

Engaged Employer

Meta

Add an Interview

Interview Question

Front End Engineer Interview

-

Meta

Flatten Array, Create Emitter

Interview Answers

2 Answers

1

Shortest way to flatten an array I could come up with: function flatten(a) { return Array.isArray(a) ? [].concat(...a.map(flatten)) : a; }

Anonymous on

1

to flatten nested arrays : const flatten = array => { return array.reduce((elem, acc) => { return elem.concat(Array.isArray(acc) ? flatten(acc) : acc); }, []); }

Sonia on

Add Answers or Comments

To comment on this, Sign In or Sign Up.

Meta Careers

Cover image for Meta

Bring the world closer together with Meta Meta builds technologies that help people connect, find communities and grow businesses. When...More

  • Our Technologies
  • The Metaverse
  • Meta and You
This is the employer's chance to tell you why you should work for them. The information provided is from their perspective.