String.prototype.trimbeginner' hello '.trim() // β 'hello'
'
text '.trim() // β 'text'
'no spaces'.trim() // β 'no spaces'Use trim() to remove all leading and trailing whitespace characters from a string.
.trim() strips whitespace from both the start and end simultaneously.
Challenge: Implement trimBoth(str) that removes whitespace from both ends.
trimBoth(' hello ') // β 'hello'