JavaScript: Flattening (array)

Last update: 10 Dec 23:20
0
Students

flatten.js

Implement and export as default a function that makes a nested array flat.

To solve the task, you cannot use built-in array flattening methods.

Examples

const list = [1, 2, [3, 5], [[4, 3], 2]];

flatten(list); // [1, 2, 3, 5, 4, 3, 2]

Tips

  • Array.isArray method checks if data is array

For full access to the challenge you need a professional subscription.

A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.

Get access
130
courses
1000
exercises
2000+
hours of theory
3200
tests