String.prototype.trimEndbeginner' hello '.trimEnd() // β ' hello'
'text '.trimEnd() // β 'text'
'hi'.trimEnd() // β 'hi'Use trimEnd() to remove only trailing whitespace from the end of a string, leaving leading whitespace intact.
trimEnd() also removes trailing newlines and tabs.
Challenge: Implement stripNewline(str) that removes a trailing newline.
stripNewline('hello\n') // β 'hello'