Skip to content

Latest commit

 

History

History
19 lines (11 loc) · 415 Bytes

File metadata and controls

19 lines (11 loc) · 415 Bytes

string-incrementer

This function increments a string, to create a new string.

If the string already ends with a number, the number should increment by 1. If the string does not end with a number. the number 1 should appended to the new string. If the number has leading zeros the amount of digits is considered.

Examples:

foo -> foo1

foobar23 -> foobar24

foo0042 -> foo0043

foo9 -> foo10

foo099 -> foo100