[Javascript] How can I trim a string?
I want to remove all whitespaces from the beginning and from the end of the string, How can I do that in JavaScript?
1 Answer
3 years ago by Jahaan
str.trim()
method is used to trim all whitespaces from the beginning and from the end of the string.
Check the below example for usage:
let str = " Hello, World! ";
console.log(str.trim());
3 years ago by Meera