A function to return the next character. For example, given A, the next letter should be B.
say you wanted to name a list of items using letters ... you'd start with A, B ... Z. But after Z you want to start at AA, AB, AC ... AZ. Which would go in to BA, BB, BC ... BZ. When you get to ZZ you want to start at AAA
A -> B
B -> C
Z -> AA
AA -> AB
AB -> AC
AZ -> BA
BA -> BB
ZZ -> AAA
What I started with was a function to get the next character until Z
const nextLetter = (char) => {
return char === 'Z' ? 'A': String.fromCharCode(char.charCodeAt(0) + 1);
}
console.log(nextLetter('A'))
console.log(nextLetter('G'))
console.log(nextLetter('Z'))
But later I came up with a solution that I thought I'd share with the world, that can either be improved on or made more efficient.