Javascript String toUpperCase() method

Description

Javascript String toUpperCase() method


String.prototype.toUpperCase = function() {
  var s = "";
  for (var i = 0, len = this.length; i < len; i++) {
    var char = this.charCodeAt(i);
    if (char >= 97 && char <= 122) {
      s += String.fromCharCode(char - 32);
    } else {/* w  w w.jav  a2 s.c  om*/
      s += this[i];
    }
  }
  
  return s;
};



PreviousNext

Related