Skip to content

Commit d53ee2e

Browse files
committed
Remove White Spaces in Array
1 parent b2b4c96 commit d53ee2e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

RemoveWhiteSpacesString.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Ways to remove white spaces from a string:
3+
*/
4+
const removeWhiteSpaces = (x) => {
5+
return x.replace(/\s+/g, '')
6+
}
7+
8+
const newString = "This is a string."
9+
10+
console.log(removeWhiteSpaces(newString))
11+
/**
12+
* Thisisastring.
13+
*/
14+
15+
console.log(newString.split(' ').join(''))
16+
/**
17+
* Thisisastring.
18+
*/

0 commit comments

Comments
 (0)