← Back to challenges

Rotate for Max Number

JavaScriptHardlanguage_fundamentalslogicmathnumbers

Instructions

Create a function which takes a number and returns the maximum value by rearranging its digits.

Examples

rotateMaxNumber(123) ➞ 321

rotateMaxNumber("001") ➞ 100

rotateMaxNumber(999) ➞ 999

Notes

The input number can be a digit or a string.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Find the Area of a (Regular) Hexagon