function convertHTML(str) {
let newStr = str.split("");
for (let i = 0; i < newStr.length; i++) {
if (str.replace("&", "&"));
if (str.replace("<", "<"));
if (str.replace(">", ">"));
if (str.replace('"', """));
if (str.replace("'", "'"));
}
newStr = newStr.join("");
return newStr;
}
console.log(convertHTML("Dolce & Gabbana"));
Confused about how to go about replacing characters with new ones. Any help/guidance without giving away any answers would be greatly appreciated. Thanks!
Nice work! That’s a solid approach - I usually see campers chain .replace() calls for each symbol, but passing a callback function to replace is a much cleaner (and more advanced) approach.