let str = {"parts":[{name: 'John'}],"total":1,}
var str=`let str = {"parts":[{name: 'John'}],"total":1,}`; alert(str.replace(/.(.)$/i,'$1'));
var str=`let str = {"parts":[{name: 'John'}],"total":1,}`; alert(str.replace(/,?(.)$/,'$1'));
var str=`let str = {"parts":[{name: 'John'}],"total":1}`; alert(str.replace(/,?(.)$/,'$1'));