javascript remove space from two side of string

Solutions on MaxInterview for javascript remove space from two side of string by the best coders in the world

showing results for - "javascript remove space from two side of string"
Albany
07 Feb 2020
1const string = " this contains   spaces ";    
2string.replace(/\s{2,}/g, '').trim() 
3