*Tell us what’s happening:
My output string has a dash between the words. The unicode for the space between the words are being counted as well?Would I have to use the replace method to get rid of the dash?
Your code so far
function rot13(str) { // LBH QVQ VG!
var charNum = [];
var numHolder = [];
var asciiValues = [];
str = str.toUpperCase();//changes the string to upper case so the ascii code will work with the same value.
for( i = 0; i < str.length; i++)// for loop goes through the string and checks the ascii value. If the ascii value is greater than or equal to 78 it will subtract 13, else will add 13.
{
charNum.push(str.charCodeAt(i));//pushing the values into the charNum array.
if(charNum[i] >= 78)// condition statement to check if the value is greater than or equal to 78. if so subtract 13
{
charNum[i] -= 13;
}
else// if not then add 13
{
charNum[i] += 13;
}
asciiValues.push(String.fromCharCode(charNum[i]));//pushing the new ascii values into a new array
}
return asciiValues.join("");// prints out FREE-CODE-CAMP, how do I ignore the space value? because the space value is 32, which would add 13 making it 45 and unicode 45 is the dash.
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:56.0) Gecko/20100101 Firefox/56.0
.
Link to the challenge: