Javascript question not able to solve it can anyone help me

Clean the room function: given an input of [1,2,4,591,392,391,2,5,10,2,1,1,1,20,20] , make a function that organizes these into individual array that is ordered. For example answer(ArrayFromAbove) should return: [[1,1,1,1],[2,2,2], 4,5,10,[20,20], 391, 392,591] . Bonus: Make it so it organizes strings differently from number types. i.e. [1, "2", "3", 2] should return [[1,2], ["2", "3"]]

Have a look at the JavaScript sort() method you can use with arrays.
After that, you could cycle through the elements in the array pushing items into temporary array (which could later be pushed onto a final array), if they meet a certain condition (think: if statement).
For the bonus section you could use the strict equality operator (===)
I hope this helps :slight_smile:

1 Like

still not able to solve the question…I think i need some more indepth help

before the code, think of how you would solve it on pen and paper
create an algorithm that you can use to check manually number by number and do something with each number to obtain the desired result

if you are able to do that, then coding it will be a question of knowing things or researching things

1 Like