Hi all. I’m new to programming but enjoying the algorithm challenges so far in javascript. I’m not sure but I think I encountered a bug since my solution works on both Repl.it and Brackets but doesn’t seem to work here. So please let me know what I am doing wrong if this is not a bug. Thank you!
function convertHTML(str) {
// :)
return str = str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;');
}
console.log(convertHTML("Hamburgers < Pizza < Tacos"));
console.log(convertHTML("Dolce & Gabbana"));
console.log(convertHTML("Sixty > twelve"));
console.log(convertHTML('Stuff in "quotation marks"'));
console.log(convertHTML("Schindler's List"));
console.log(convertHTML("<>"));