Last active
March 29, 2016 10:31
-
-
Save sophiabrandt/f4bf639d1a7c72612a3b to your computer and use it in GitHub Desktop.
Free Code Camp Basic Algorithms
This file contains 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 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