# Asking for feed back on Caesar's Cipher Challange solution

Asking for feed back on Caesar's Cipher Challange solution
0

#1

Hi, i just completed caesarâ€™s cipher challenge and i want to ask for your feedback whether my solution had programming best practice or not and what can i improve on it?

i apologize for my english, it is not my first language

(SPOILER)

``````function rot13(str) {
var arrS = str.toUpperCase().split("");
for (var x = 0; x < arrS.length; x++){
if (arrS[x].match(/[A-M]/g) !== null){
arrS[x] = String.fromCharCode(arrS[x].charCodeAt(0)+13);
} else if (arrS[x].match(/[N-Z]/g) !== null) {
arrS[x] = String.fromCharCode(arrS[x].charCodeAt(0)-13);
}
}
return arrS.join("");
}``````

#2

The only improvement I can see is to use a more explicit name for your array variable arrS, like arrStr. I know itâ€™s a tiny difference! lol thatâ€™s because the code is good!

Good luck with the rest of the algorithms!

#3

thanks for your feedback! i appreciate it! iâ€™ll pay more attention to variable name from now on

#4

Your algo solution is better than mine to be honest.
Iâ€™m potentially going to have to repeat myself because everyone does this.

`//**Bad:**`
var i;
for (i = 0; i < arr.length; i++) {
`// **Better Code:**`
var i;
var len = arr.length;
for (i = 0; i < len; i++) {

Suggested by:
http://www.w3schools.com/js/js_performance.asp