Here you can find the source of setCharAt(index, ch)
String.prototype.setCharAt = function (index, ch){ if (index > this.length || index < 0) return this; return this.substring(0, index) + ch + this.substring(index+1); } function convert(str){ str = ' ' + str; var i = 0;// w w w . j a va 2 s. c om while (i < str.length){ i++; if (str.charAt(i) !== ' '.charAt(0) && str.charAt(i-1) === ' '.charAt(0)) if (str.charCodeAt(i) > 96 && str.charCodeAt(i) < 123) str = str.setCharAt(i, String.fromCharCode(str.charCodeAt(i) - 32)); } return str.substring(1); } var str = 'the quick brown fox'; console.log(str); console.log(convert(str));
String.prototype.setCharAt = function (index, ch){ if (index > this.length || index < 0) return this; return this.substring(0, index) + ch + this.substring(index+1); function sortLetter(str){ for (var i = 0; i < str.length; i++) for (var j = i+1; j < str.length; j++) if (str.charCodeAt(i) > str.charCodeAt(j)){ var t = str.charAt(i); ...
String.prototype.setCharAt = function (index, newValue) { return this.substring(0, index) + newValue + this.substring(index+1, this.length); };
String.prototype.setCharAt = function(index,chr) { if(index > this.length-1) return str; return this.substr(0,index) + chr + this.substr(index+1);
String.prototype.setCharAt = function(index,chr) { if(index > this.length-1) return this; return this.substr(0,index) + chr + this.substr(index+1);