Javascript examples for String Operation:String Case
String case swap function
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w w w . j a v a 2s . c om*/ function swapCase(str) { var out = ''; for (var i=0; i<str.length; i++) { if (str[i].toLowerCase() == str[i]) { out += str[i].toUpperCase(); } else { out += str[i].toLowerCase(); } } return out; } console.log(swapCase('Hello World This Is a TEST!')) } </script> </head> <body> </body> </html>