DEV Community

Discussion on: Daily Challenge #177 - Supersize Me

Collapse
 
savagepixie profile image
SavagePixie

JavaScript oneliners for the win!

const superSize = n => +n.toString().split('').sort((a, b) => b - a).join('')
Collapse
 
georgewl profile image
George WL

Had a feeling it was this simple.

Why the plus though?

Collapse
 
craigmc08 profile image
Craig McIlwrath

The argument to the unary plus operator is a string. The + is a very concise method of converting a string to a number, in this situation.

Thread Thread
 
georgewl profile image
George WL

Ah, I totes prefer the readability over conciseness approach