The following code replaces only one single quote:
You can use a global qualifier (a trailing g) on a regular expression:
g
var b = a.replace(/'/g, '"');
Without the global qualifier, the regex (/'/) only matches the first instance of '.
/'/
'