Tell us what’s happening:
It’s funny : the tests all pass, but the logged string is not what i am supposed to have. Can someone explain ? Would the code really work ?
Your code so far
function convertHTML(str){
let newStr = "";
for(let char of str){
let newChar = char;
if(newChar === "&"){
newChar = "&";
}
else if(newChar === "<"){
newChar = "<";
}
else if(newChar === ">"){
newChar = ">";
}
else if(newChar === "\""){
newChar = """;
}
else if(newChar === "\'"){
newChar = "'";
}
newStr += newChar;
}
return newStr;
}
console.log(convertHTML("Dolce & Gabbana"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:148.0) Gecko/20100101 Firefox/148.0
Challenge Information:
Implement an HTML Entity Converter - Implement an HTML Entity Converter
