Skip to content

Instantly share code, notes, and snippets.

@sophiabrandt
Last active March 29, 2016 10:31
Show Gist options
  • Save sophiabrandt/f4bf639d1a7c72612a3b to your computer and use it in GitHub Desktop.
Save sophiabrandt/f4bf639d1a7c72612a3b to your computer and use it in GitHub Desktop.
Free Code Camp Basic Algorithms
function rot13(str) {
var map = Array.prototype.map;
var a = map.call(str, function(x) {
return x.charCodeAt(0);
});
var b = a.map(function(y) {
if (y > 64) {
var z = y + 13;
if (z > 90) {
return z - 26;
}
return z;
}
return y;
});
return String.fromCharCode.apply(this, b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment