If I understand:
Code:decodeTheseCharacters.map(String.fromCharCode).join("");
Although browser support isn't fully fleshed out there's also TextDecoder: https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder
Javascript also supplies some tools for working directly with binary data, you can store in ArrayBuffers and read/write with DataViews.
Yeah, that's not what I'm going for now that I've looked and seen.
This is what I have:
Code:
function rot13(str) { // LBH QVQ VG!
// Create empty array to hold character codes
var characterCodes = [];
// Push character codes into array
for (var i = 0; i < str.length; i++) {
characterCodes.push(str.charCodeAt(i));
}
debugger;
// Create an empty container array to hold decoded characters
var decodedCharacters = [];
debugger;
// For each character code in the array:
for (var n = 0; n < characterCodes.length; n++) {
// If it's less than 65 or more than 90...
if (characterCodes[n] > 65 || characterCodes[n] < 90) {
// Convert code to string and push to container array
decodedCharacters.push(characterCodes[n]);
debugger;
}
// Otherwise
else {
// Shift it by 13
decodedCharacters.push(characterCodes[n] - 13);
// If necessary, wrap it. If you're adding 13, wrap around 90. If subtracting, wrap around 65.
// Convert code to string and push to container array
}
debugger;
}
// Return the contents of container array as a string
}
rot13 ("SERR PBQR PNZC");
"debugger;" will throw up Chrome's built-in debugger. So far so good.
Array1->characterCodes will say it has 14 values (counting by 0, so 15 characters including spaces), okay. So far so good.
BUT it won't show me the values' it's pushing from ".getCharCode()" It just continues to say it's 14 values.
Then when I run the loop, it'll iterate through the loop and show me i (or n) counting up. GREAT because it means my loop is working.
THEN it returns the value of the second array (decodedCharacters). Which is great, but I want the original values as well to make sure it's working.
Why isn't Chrome giving me the two array's values in different areas/steps?
If I console.log, the arrays match to where I'm thinking decodedCharacters is throwing at characterCodes array the values it's calculating. Which isn't what I want/need. I want both of them to have their own values with originalCharacter being the before and decodedCharacters being the after so then I can breakpoint/debugger; the decoding step.