This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function nextBigger(number) { | |
| const digits = String(number).split(''); | |
| let swapToIndex = -1; | |
| // проходим цифры с конца и находим последовательность из двух цифр, | |
| // где старший разряд меньше младшего | |
| // индекс старшего разряда запоминаем в "to" | |
| for (let index = digits.length - 2; index >= 0; index -= 1) { | |
| if (digits[index] < digits[index + 1]) { |