Javascript String swapCase()

Description

Javascript String swapCase()


String.prototype.swapCase = function(){
 var swapped = "";
 for (var i = 0; i < this.length; i++) {
  var l = this.charAt(i);
  if(l == l.toUpperCase())
   swapped += l.toLowerCase();//from  w w w. j a v a 2 s . c  om
  else
   swapped += l.toUpperCase();
 }
 return swapped;
}



PreviousNext

Related