# Caesars Cipher Error

**URL:** <https://forum.freecodecamp.org/t/caesars-cipher-error/49180>\
**Category:** General\
**Created:** [October 26, 2016, 11:00pm UTC](https://forum.freecodecamp.org/t/caesars-cipher-error/49180 "2016-10-26T23:00:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexanderdierl](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@alexanderdierl](https://forum.freecodecamp.org/u/alexanderdierl)\
**Post date:** [October 26, 2016, 11:00pm UTC](https://forum.freecodecamp.org/t/caesars-cipher-error/49180/1 "2016-10-26T23:00:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kevcomedia](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevcomedia/32/125737_2.png) [@kevcomedia](https://forum.freecodecamp.org/u/kevcomedia)\
**Post date:** [October 27, 2016, 2:49am UTC](https://forum.freecodecamp.org/t/caesars-cipher-error/49180/2 "2016-10-27T02:49:17Z")

</div>

> [@alexanderdierl](#):
>
> `if(inputtxt.value.match(letters))`

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:

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

```

---

<div class="post-metadata">

**Author:** ![alexanderdierl](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@alexanderdierl](https://forum.freecodecamp.org/u/alexanderdierl)\
**Post date:** [October 30, 2016, 8:13pm UTC](https://forum.freecodecamp.org/t/caesars-cipher-error/49180/3 "2016-10-30T20:13:54Z")

</div>

> [@alexanderdierl](#):
>
> match

thx dude, that worked

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [January 16, 2021, 5:31am UTC](https://forum.freecodecamp.org/t/caesars-cipher-error/49180/4 "2021-01-16T05:31:05Z")

</div>

Closed on January 16, 2021, 5:31am UTC


