Create html entities with replace overloaded

i tried this code block, it seems that only replacing qout causes problems
it returns same string as the test but maybe “”" is problem?

function convertHTML(str) {
  return str
    .replace(/&/g,'&')
    .replace(/</g,'&lt;')
    .replace(/>/g,'&gt;')
    .replace(/"/g,'&qout;')
    .replace(/'/g,'&apos;')
    .replace(/\\/g,'')
}

There’s a typo in the .replace(/"/g,'&qout;')

i tried adding \ to it ("\"") but still is the same

Shoud be quot, not qout

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.