需求:把一个字符串中的大写字母转为小写,小写字母转大写
function parseStr (str){
var result = '';
for(var i= 0;i<str.length;i++){
var temp = str.charAt(i);
var code = temp.charCodeAt();
if('a' <= temp && temp <= 'z'){
temp= String.fromCharCode(code-32);
} else if('A' <= temp && temp <= 'Z'){
temp= String.fromCharCode(code+32);
}
result += temp;
}
return result;
}