The solution given in the Community Input removes all the whitespace from the string. That isn't trimming exactly. The correct way to do it should be...
let str = " Samantha Ming "
let trimmedStr = str.replace(/^\s+ | \s+$/g , '')
console.log(trimmedStr) // "Samantha Ming"
OH good call! let me add your point to the code notes! Thanks for info 👏
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.