I wrote a ROT13 cipher script forrotating uppercase letters only. Can this function be improved?
function rot13(str) {
var codeA = "A".charCodeAt(0);
var codeN = "N".charCodeAt(0);
var codeZ = "Z".charCodeAt(0);
var newArr = [];
for(var i =0; i<str.length; i++){
var code = str.charCodeAt(i);
if(code>=codeA && code<=codeZ){
if(code>=codeN)
newArr.push(String.fromCharCode(code-13));
else
newArr.push(String.fromCharCode(code+13));
}else{
newArr.push(str[i]);}
}
return newArr.join("");
}
I wrote a ROT13 cipher script for uppercase letters only. Can this function be improved?
function rot13(str) {
var codeA = "A".charCodeAt(0);
var codeN = "N".charCodeAt(0);
var codeZ = "Z".charCodeAt(0);
var newArr = [];
for(var i =0; i<str.length; i++){
var code = str.charCodeAt(i);
if(code>=codeA && code<=codeZ){
if(code>=codeN)
newArr.push(String.fromCharCode(code-13));
else
newArr.push(String.fromCharCode(code+13));
}else{
newArr.push(str[i]);}
}
return newArr.join("");
}
I wrote a ROT13 cipher script rotating uppercase letters only. Can this function be improved?
function rot13(str) {
var codeA = "A".charCodeAt(0);
var codeN = "N".charCodeAt(0);
var codeZ = "Z".charCodeAt(0);
var newArr = [];
for(var i =0; i<str.length; i++){
var code = str.charCodeAt(i);
if(code>=codeA && code<=codeZ){
if(code>=codeN)
newArr.push(String.fromCharCode(code-13));
else
newArr.push(String.fromCharCode(code+13));
}else{
newArr.push(str[i]);}
}
return newArr.join("");
}
I wrote a ROT13 cipher script for uppercase letters only. Can this function be improved?
function rot13(str) {
var codeA = "A".charCodeAt(0);
var codeN = "N".charCodeAt(0);
var codeZ = "Z".charCodeAt(0);
var newArr = [];
for(var i =0; i<str.length; i++){
var code = str.charCodeAt(i);
if(code>=codeA && code<=codeZ){
if(code>=codeN)
newArr.push(String.fromCharCode(code-13));
else
newArr.push(String.fromCharCode(code+13));
}else{
newArr.push(str[i]);}
}
return newArr.join("");
}
I wrote a ROT13 cipher script. Can this function be improved?
function rot13(str) {
var codeA = "A".charCodeAt(0);
var codeN = "N".charCodeAt(0);
var codeZ = "Z".charCodeAt(0);
var newArr = [];
for(var i =0; i<str.length; i++){
var code = str.charCodeAt(i);
if(code>=codeA && code<=codeZ){
if(code>=codeN)
newArr.push(String.fromCharCode(code-13));
else
newArr.push(String.fromCharCode(code+13));
}else{
newArr.push(str[i]);}
}
return newArr.join("");
}
I wrote a ROT13 cipher script for uppercase letters only. Can this function be improved?
function rot13(str) {
var codeA = "A".charCodeAt(0);
var codeN = "N".charCodeAt(0);
var codeZ = "Z".charCodeAt(0);
var newArr = [];
for(var i =0; i<str.length; i++){
var code = str.charCodeAt(i);
if(code>=codeA && code<=codeZ){
if(code>=codeN)
newArr.push(String.fromCharCode(code-13));
else
newArr.push(String.fromCharCode(code+13));
}else{
newArr.push(str[i]);}
}
return newArr.join("");
}
Rot13 ROT13 JavaScript
I wrote a ROT13 cipher script. Can this function be improved?
function rot13(str) {
var codeA = "A".charCodeAt(0);
var codeN = "N".charCodeAt(0);
var codeZ = "Z".charCodeAt(0);
var newArr = [];
for(var i =0; i<str.length; i++){
var code = str.charCodeAt(i);
if(code>=codeA && code<=codeZ){
if(code>=codeN)
newArr.push(String.fromCharCode(code-13));
else
newArr.push(String.fromCharCode(code+13));
}else{
newArr.push(str[i]);}
}
return newArr.join("");
}
Hi, I wrote a ROT13 cipher script, but can this function be improved?
Rot13 JavaScript
function rot13(str) {
var codeA = "A".charCodeAt(0);
var codeN = "N".charCodeAt(0);
var codeZ = "Z".charCodeAt(0);
var newArr = [];
for(var i =0; i<str.length; i++){
var code = str.charCodeAt(i);
if(code>=codeA && code<=codeZ){
if(code>=codeN)
newArr.push(String.fromCharCode(code-13));
else
newArr.push(String.fromCharCode(code+13));
}else{
newArr.push(str[i]);}
}
return newArr.join("");
}
Hi, I wrote a ROT13 cipher script, but can this function be improved?
ROT13 JavaScript
I wrote a ROT13 cipher script. Can this function be improved?
function rot13(str) {
var codeA = "A".charCodeAt(0);
var codeN = "N".charCodeAt(0);
var codeZ = "Z".charCodeAt(0);
var newArr = [];
for(var i =0; i<str.length; i++){
var code = str.charCodeAt(i);
if(code>=codeA && code<=codeZ){
if(code>=codeN)
newArr.push(String.fromCharCode(code-13));
else
newArr.push(String.fromCharCode(code+13));
}else{
newArr.push(str[i]);}
}
return newArr.join("");
}