Reputation: 5806
I would like to modify my strings so i can replace the character ' ' with '_' using JS,for example "new zeland"=>"new_zeland" how can i do that?
Upvotes: -1
Views: 284
Reputation: 6878
You could use Rob's code, but it uses a regular expression to find the space, while it would be faster to just search for a literal space:
var string = 'new zealand';
var newString = string.replace(' ', '_');
Upvotes: 1