Beat The Previous

Beat The Previous

Given a string of digits guaranteed to only contain ordinary integer digit characters 0 to 9, create and return the array of increasing integers acquired from reading these digits in order from left to right. The first integer in the result list is made up from the first digit of the string. After that, each element is an integer that consists of as many following consecutive digits as are needed to make that integer strictly larger than the previous integer. The leftover digits at the end of the digit string that do not form a sufficiently large integer are ignored.

This mission is quite easy, but we also have got a harder version - Staircase. Try it!

Input: String (string).

Output: Array of integers (number).

Examples:

assert.deepStrictEqual(beatPrevious("600005"), [6]);
assert.deepStrictEqual(beatPrevious("6000050"), [6, 50]);
assert.deepStrictEqual(beatPrevious("045349"), [0, 4, 5, 34]);
assert.deepStrictEqual(
    beatPrevious("77777777777777777777777"),
    [7, 77, 777, 7777, 77777, 777777]
);

The mission was taken from Python CCPS 109. It is taught for Ryerson Chang School of Continuing Education by Ilkka Kokkarinen