Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String.prototype.removeUnnecessarySpaces = function() {
- return this.split(/ +/).join(" ").trim()
- }
- // example
- // code | expected output
- " t e s t i n g ".removeUnnecessarySpaces() // "t e s t i n g"
- "".removeUnnecessarySpaces() // ""
- "testing".removeUnnecessarySpaces() // "testing"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement