Time to do some secret encoding! You never now, one day you might be a spy.
I won't bore you with a long story, but a famous encoding method is to swap the first 13 characters of the alphabet with their opposites.
For example, A would become N. A is the first of the first 13 letters, and n is the first of next set of 13 letters.
So, A would become N and N would beome A. B would be o and o would be b. C would be p, and p would be c.
M would be z and z would be m.
So, you can take a secret message like this: " The money is hidden in the blue pillow"
and output this :
gurzbarlvfuvqqravaguroyhrcvyybj
Thus, you can send your secret message without fear of someone figuring it out. I understand that emails are encrypted, but what if you send it by mail? What if you leave a note?
The same function will also decode the message when fed back to it.
The solution is in the comments.
var albmEncode = function(string){
ReplyDeletevar alpAM = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"];
var alpNZ = ["n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
var answer = [];
var array = string.toLowerCase().split("");
_.each(array, function(item){
if(_.indexOf(alpAM, item) === -1){
answer.push(alpAM[_.indexOf(alpNZ, item)]);
}
if(_.indexOf(alpNZ, item) === -1){
answer.push(alpNZ[_.indexOf(alpAM, item)]);
}
})
return answer.join("");
}