Hacker News new | ask | show | jobs
by Neist 2772 days ago
They sure make it sound more complicated than it really is... I'm a self taught developer too, so I get where you're coming from :-)

In javascript I would solve it like so: "HELLO".replace(/./g, character => String.fromCharCode(character.charCodeAt() + 1))

This would result in "IFMMP".

Basically it's just a matter of shifting charcodes.

1 comments

Your solution would not work for all cases. For example, shifting "JAZZ" up by 1 should result in "KBAA" but your program would output "KB[[". You also need to handle wraparound at the ends of the alphabet.
Hi! Yeah, you're right! This was a 1-minute quick'n'dirty solution :-)