windows - Best way to concatenate an address in Javascript? -


what want if enter address such

22-40 w 77th st, new york, ny 10024

i get

"w+77th+st,+new+york,+ny+10024/"

i feel on complicating this...

use split , join functions.

var straddress="22-40 w 77th st, new york, ny 10024";

straddress = straddress.split(' ').join('+');

this replace space + sign, , desired output.


Comments