DEV Community

Cover image for Day 2 Challenge
Hello Dev World Blog
Hello Dev World Blog

Posted on • Originally published at hellodevworld.com

Day 2 Challenge

Hope your new year was wonderful! Day 2!

The Problem

Write a function that accepts an array of numbers, this can be an array with any number of nested arrays. Flatten the array (make all one level), put it in numerical order of distinct numbers from the original array

Examples:

    flatten([1, 1, 5, 9])  //[1, 6, 9]   
    flatten([20, [3, 5], 10])  //[3, 5, 10, 20]   
    flatten([[1,2,3],[[4,5],6,[7,8,9], 19, 21, [0, 1], ]])  //[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 19, 21]
Enter fullscreen mode Exit fullscreen mode

If you would like the challenges emailed to you every morning subscribe here. I will post the challenges on my blog and send out an email at 7am every morning and will post the solution and send an email for the solution at 6pm every night. I will also be posting a video on my YouTube channel for each challenge so subscribe there so you don't miss one!

I can't turn off commenting so please do not comment your solution on this post I will post a solution later tonight and you can post it there. If people cannot follow this I will not post the challenge on this platform and will only post the solutions.

Top comments (0)