The following code replaces only one single quote:
You can use a RegExp with the global flag g and all quotes will replaced:
g
var b = a.replace(/'/g, '"');