6 lines
266 B
JavaScript
6 lines
266 B
JavaScript
|
swapcase = function swapcase(str) {
|
||
|
return str.replace(/([a-z]+)|([A-Z]+)/g, function(match, chr) {
|
||
|
return chr ? match.toUpperCase() : match.toLowerCase();
|
||
|
});
|
||
|
}
|
||
|
console.log(swapcase('AaBbc'));
|