Tell us what’s happening:
The code is not showing the HTML entities it’s converting them to special characters
Your code so far
function convertHTML(string){
let array=[["&","&"],["<","<"],[">",">"],['"',"""],["'","'"]];
for(let [specialChar,entities] of array){
console.log(array)
if(string.indexOf(specialChar)!==-1){
string=string.split("");
string.splice(string.indexOf(specialChar),1,entities)
string=string.join("")
}
}
return string
}
console.log(convertHTML("Dolce & Gabbana"))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
Challenge Information:
Implement an HTML Entity Converter - Implement an HTML Entity Converter
