Rotate Max Number

Published by Deep Xavier in

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

Examples

rotateMaxNumber("1213") ➞ 3211

rotateMaxNumber("1217") ➞ 7211

rotateMaxNumber("123") ➞ 321

rotateMaxNumber("001") ➞ 100

rotateMaxNumber("999") ➞ 999

Notes

N/A

Watch a quick demo on how Edabit works.