marita
0
Q:

Javascript convert html entity to string

const htmlEntities = {
    "&": "&",
    "<": "&lt;",
    ">": "&gt;",
    '"': "&quot;",
    "'": "&apos;"
  };
return str.replace(/([&<>\"'])/g, match => htmlEntities[match]);
}
0

New to Communities?

Join the community