Caesars Cipher Error

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. :slight_smile: What’s wrong with it?

function rot13(str) { // LBH QVQ VG!

function allLetter(inputtxt)
var letters = /^[A-Za-z]+$/;
return true;
return false;

var newString=[];
if(allLetter(str[i]) !== true){
} else if(str.charCodeAt(i) > 77){
} else {
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

This line is the culprit. Specifically the value part. inputtxt is already a string, and you could’ve just used inputtxt.match(letters).

I don’t know if you used this in your working solution, but you could simplify allLetter to this:

function allLetter(inputtxt) {
  var letters = /^[A-Za-z]+$/;
  return letters.test(inputtxt);
1 Like

thx dude, that worked