DEV Community

Javascript array sort with Reducer

D\sTro on November 20, 2020

This has been the most tricky/confusing javascript interview question for starters specially πŸ˜€ And this was my answer once which made interviewe...
Collapse
 
tiagojpdias profile image
Tiago Dias

What??

[6,3,-1,2].sort() // [ -1, 2, 3, 6 ]
Enter fullscreen mode Exit fullscreen mode

Which is completely fine. I think you missed the point here...

Array.prototype.sort accepts a callback as a custom sorter.

What a convoluted piece of "code". Awful use case to make your point across.

Collapse
 
orgimeno profile image
Oscar Rodriguez Gimeno

They asked me how to center a div. I told them 'margin 0 auto' although I don't know if it works in iexplorer

Collapse
 
slimdestro profile image
D\sTro

πŸ˜€πŸ‘Œ

Collapse
 
alfredosalzillo profile image
Alfredo Salzillo

Please ad the javascript tag to the code block.

Collapse
 
slimdestro profile image
D\sTro

thanks