It does not work with this code answer: function convertHTML(str) { let result = str .replaceAll('>', '>') .replaceAll('<', '<') .replaceAll("&", '&') .replaceAll("'", ''') .replaceAll('"', '"e;'); return result; } convertHTML('Dolce & Gabbana');