The following code replaces only one single quote:
Add the g modifier: var b = a.replace(/'/g, '"');
g
var b = a.replace(/'/g, '"');