1

Looking to replace spaces in a variable to "%20". Only the first space is being replaced. I would like to replace all of them.

var Answer30Address = answer30.toString().replace(" ", "%20");

Brudze
  • 11
  • 3
  • look at the highest score answer here : http://stackoverflow.com/questions/1144783/how-to-replace-all-occurrences-of-a-string-in-javascript – Serge insas Dec 13 '16 at 22:53

1 Answers1

0

If you use regex it will replace all, this should do.

var Answer30Address = answer30.toString().replace(/ /g, "%20");
Mullenb
  • 651
  • 6
  • 20