My logic is that I want to take the numbers in an array, change them to the correct numbers (to match the unicode), then convert the correct number to the letters, and reattach as a string.
I keep getting a bunch of “\u0000” populated in my Array. Any suggestions?
Thanks,
Mitch
So far this is my code:
function rot13(str) { // LBH QVQ VG!
var letters = "";
var convert = "";
function numberConvert(number) {
var abs = 0;
if (number === 32 ) {
return 32;
} else if (number > 77) {
return number - 90 + 65;
} else {
return number;
}
}
var newArray = [];
var split = str.split('');
var ccode = "";
for (var i = 0; i < split.length; i++) {
ccode = split[i].charCodeAt(0);
newArray.push(ccode);
}
for (var j = 0; j < split.length; j++) {
newArray.unshift(String.fromCharCode(split[j]));
newArray.pop(ccode);
}
return newArray;
}
// Change the inputs below to test
rot13("SERR PBQR PNZA");