You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
481 B
JavaScript

str = 'c';
var UPPER = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var LOWER = 'abcdefghijklmnopqrstuvwxyz';
var result = [];
for(var x=0; x<str.length; x++)
{
if(UPPER.indexOf(str[x]) !== -1)
{
result.push(str[x].toLowerCase());
}
else if(LOWER.indexOf(str[x]) !== -1)
{
result.push(str[x].toUpperCase());
}
else
{
result.push(str[x]);
}
}
console.log(result.join(''));