Created
April 18, 2018 18:15
-
-
Save allenhwkim/0f4976f511eebe1c28fb6345d59c9a5f to your computer and use it in GitHub Desktop.
Javascript Simple Encoding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function simpleEncoding(str, num=10) { | |
| return str.split('').map(c => String.fromCharCode(c.charCodeAt(0)+num)).join(''); | |
| } | |
| var encoded = simpleEncoding('hello world'); // 'rovvy*y|vn' | |
| simpleEncoding(encoded, -10); // 'hello world' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment