Hello guys,
I already passed this Challenge, but I’m wondering why my first solution shows me an error message, maybe you can enlight me. What’s wrong with it?
function rot13(str) { // LBH QVQ VG!
function allLetter(inputtxt)
{
var letters = /^[A-Za-z]+$/;
if(inputtxt.value.match(letters))
return true;
else
return false;
}
var newString=[];
for(i=0;i<str.length;i++){
if(allLetter(str[i]) !== true){
newString.push(str.charAt(i));
} else if(str.charCodeAt(i) > 77){
newString.push(String.fromCharCode(str.charCodeAt(i)-13));
} else {
newString.push(String.fromCharCode(str.charCodeAt(i)+13));
}
}
return newString.join("");
}
// Change the inputs below to test
rot13(“SERR PBQR PNZC”);
// Error message is the following: TypeError: Cannot read property ‘match’ of undefined