loading
open in
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function rot13(str) { 
  var arr = str.split(" ");
  var newArr = [];
  var temp = 0;
  for(var i = 0; i < arr.length; i++){
	  for(var j = 0; j < arr[i].length; j++){	
		if(arr[i].charCodeAt(j) >= 78 && arr[i].charCodeAt(j) <= 90){
			 temp = String.fromCharCode( arr[i].charCodeAt(j) - 13);
			newArr.push(temp);
		}
		else if(arr[i].charCodeAt(j) < 78 && arr[i].charCodeAt(j) >= 65){
			  temp = String.fromCharCode( arr[i].charCodeAt(j) + 13);
			newArr.push(temp);
		}
		else{
			  temp = String.fromCharCode( arr[i].charCodeAt(j));
			newArr.push(temp);
		}
	  }
	 newArr.push(" ");
  }
  var newStr = newArr.join("");
  return newStr;
}
rot13("SERR PBQR PNZC");
Native Browser JavaScript