str = 'he)llo)';
wantedStr --> 'he\)llo\)';
Attempting to achieve this result, I used:
var wantedStr = str.replace(')', '\\)');
Unfortunately, the output for wantedStr remains as 'he)llo)'
Is there a way to obtain the desired value for wantedStr
as indicated in the second line?