Having Trouble with Cipher

Hey all. I’m having trouble with the cipher challenge. Could someone please explain where I’m going wrong in this code (probably everywhere) and how I can make it better

the for loop is where I’m messing up I believe, tell me also if you think my filter function is constructed properly or not

function rot13(str) { // LBH QVQ VG! var answer = []; str.split(''); function cipher (letter) { if (letter === /[^0-9a-z]/gi) { return; } else if (letter.charCodeAt >= 77) { letter.toCharCode(65 + (13 - (50 - letter.charCodeAt))); } else{ letter.toCharCode(letter.charCodeAt + 13); } } for (i=0; i<str.length; i++) { i.filter(cipher); answer.push(i); } return answer.push(); } // Change the inputs below to test rot13("SERR PBQR PNZC");

there is so much wrong with this code that I’m not sure where to begin.
You really shouldn’t find yourself with this much broken code man.
You need write code in a way that you are constantly running your program after you add any bit of code. Your program should always run. When you add something and there is an error, you can then change whatever you added until your program works again. Rinse and repeat.

I suggest you reduce the code you have here back to whichever point you last had it working. and then if you find yourself not being able to implement something. come back and ask.