Skip to content

Instantly share code, notes, and snippets.

@boolpath
Created December 1, 2013 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boolpath/7727486 to your computer and use it in GitHub Desktop.
Save boolpath/7727486 to your computer and use it in GitHub Desktop.
BogotaJS Ronda 2 - Jorge Zaccaro
function cifradoCesar(string) {
var a = [],
stringLength = string.length,
letter;
for (var i = 0; i < stringLength; i++) {
letter = string.charAt(i);
if (letter == ' ') {
a.push(' ');
} else if (letter == 'z') {
a.push('a');
} else {
a.push(String.fromCharCode(string.charCodeAt(i) + 1));
}
}
return a.join('');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment