javascript - Incrementing letters in string - treating char as int without using .charCodeAt(0) -


here assignment:

replace every letter in string letter following in alphabet (ie. c becomes d, z becomes a).

now i've done type of thing in c lessons using fancy modulo 26 business , lot of subtraction , offsetting of ascii values.

is going take more lines in javascript (since instead of treating char int have use fromcharcode , charcodeat), or javascript have shortcuts task?

you can try using this:-

string.fromcharcode('a'.charcodeat(0) + 1) 

working jsfiddle


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -