Skip to content

Instantly share code, notes, and snippets.

@jamierocks
Last active August 29, 2015 14:23
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 jamierocks/359a3d288994b85ca910 to your computer and use it in GitHub Desktop.
Save jamierocks/359a3d288994b85ca910 to your computer and use it in GitHub Desktop.
var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
function cipher(input, shift) {
var result = '';
for (var i = 0; i < input.length; i++) {
var position = alphabet.indexOf(input[i].toUpperCase()) + Math.floor(shift);
if (position > 25) {
position -= 26;
}
result = result.concat(alphabet[position]);
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment