Jezyk Danzowki Jezyk Danzowki - 2 months ago 18x
TypeScript Question

Angular2 Typescript how to increment alphabet index

I know how to do this in Php, as it is a simple, but i am struggling to get a version working.

for ($i = 'A'; $i < 'Z'; $i++) {
$k = $i;
echo "$i->$k, ";

Basically i want to pass a letter into a function and get the next letter in the alphabet. Is there any easy ways or directions that i could be pointed in.


This should do what you want:

getNextLetter(char: String): String {
    code: Number = char.charCodeAt(0);
    return String.fromCharCode(code);