Javascript character replace all
You're almost there.
the thing you saw in SO is regex replace :
document.write(test.replace(/\?/g,"&"))
( I thought you wanted to change & to ? , but you want the opposite.)
with the G flag - it will replace all the matches in the string
without it - it will replace only the first match.
You need to escape the ? character like so:
test.replace(/\?/g,"&")