var textTitle = "this is a test"
var result = textTitle.replace(' ', '%20');
But the replace functions stop at the first instance of the " " and I get the
Result: "this%20is a test"
Any ideas on where I’m going wrong I’m sure it’s a simple fix.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need a
/gon there, like this:You can play with it here, the default
.replace()behavior is to replace only the first match, the/gmodifier (global) tells it to replace all occurrences.