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

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
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