What I want to do is use an array.each
to turn each letter into its corresponding letter in the alphabet plus nine. I know it's possible to put it against a case
going through all 26 letters, but that seems unnecessary.
For example. Say the array is:
["N", "O", "T", "H", "I", "N", "G"]
I want the array to become
["23", "24", "29", "17", "19", "24", "17"]
Here's one way:
arr.map {|ch| ch.ord - 'A'.ord + 10}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With