Implement an HTML Entity Converter - Implement an HTML Entity Converter

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, "&amp;lt;")
     }else if(string === ">"){
      let index = newStr.indexOf(string)
       newStr.splice(index, 1, "&amp;gt;")
     }else if(string === "\""){
      let index = newStr.indexOf(string)
       newStr.splice(index, 1, "&amp;quot;")
     }else if(string === "\'"){
      let index = newStr.indexOf(string)
       newStr.splice(index, 1, "&amp;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

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-html-entitiy-converter/a6b0bb188d873cb2c8729495.md at main · freeCodeCamp/freeCodeCamp · GitHub

why are you also escaping the & in the html entity? it’s not going to be that html entity if you do that

Thanks for the advice. It passed the test :blush::blush: