String Tricks

Using ord

Let's say we want to make an array from 0 to 25 consisting of either the alphabet in lower case or upper case.

ord("a") - ord("a") 
>> 0

ord("b") - ord("a")
>> 1

...

ord("A") - ord("A")
>> 0

ord("B") - ord("A")
>> 1

...

Last updated