function trim() { var start, end; start = 0; end = this.length - 1; while(start <= end && this.charAt(start) == " " ) { start ++; } while(start <= end && this.charAt(end) == " " ) { end --; } return this.substring(start, end+1); } function reverse() { var str = ""; var end = this.length - 1; for(;end >= 0; end --) { str = str + this.charAt(end); } return str; } String.prototype.trim = trim; String.prototype.reverse = reverse;