+ 1

How to convert a string of many words to a string of letters ignoring the spacing between in javascript?

I think it's best to give an example: "I love this app". I want this string to be converted to "Ilovethisapp". Can anyone help please?

3rd Jan 2017, 9:57 PM
Mircea-Andrei Chițu
Mircea-Andrei Chițu - avatar
2 Respostas
+ 4
string = string.replace(/ /g, "") ; Jonas Fallmann, yours will not work since you forgot the "g" keyword.
3rd Jan 2017, 11:20 PM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
+ 3
var string = "I love this app"; string = string.replace(" ", ""); EDIT: cheeze's solution works. I just don't get it, why my solution only removes the first white-space.
3rd Jan 2017, 11:14 PM
Jonas Fallmann
Jonas Fallmann - avatar