Tell us what’s happening:
my console output are correct but i’m not passing 2 - 7
Your code so far
function convertHTML(str){
let newStr = str.split("")
for(let string of newStr){
if(string === "&"){
let index = newStr.indexOf(string)
newStr.splice(index, 1, "&")
}else if(string === "<"){
let index = newStr.indexOf(string)
newStr.splice(index, 1, "&lt;")
}else if(string === ">"){
let index = newStr.indexOf(string)
newStr.splice(index, 1, "&gt;")
}else if(string === "\""){
let index = newStr.indexOf(string)
newStr.splice(index, 1, "&quot;")
}else if(string === "\'"){
let index = newStr.indexOf(string)
newStr.splice(index, 1, "&apos;")
}
}
let string = newStr.join("")
return string
}
console.log(convertHTML("<>"))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36
Challenge Information:
Implement an HTML Entity Converter - Implement an HTML Entity Converter