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 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); str = str.setCharAt(i, str.charAt(j)); str = str.setCharAt(j, t); }/*from w ww .ja v a 2 s.c o m*/ return str; } var str = 'webmaster'; console.log(str); console.log(sortLetter(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 convert(str){ str = ' ' + str; var i = 0; while (i < str.length){ 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);