Implement an HTML Entity Converter - Implement an HTML Entity Converter

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 = "&lt;";
    }
    else if(newChar === ">"){
      newChar = "&gt;";
    }
    else if(newChar === "\""){
      newChar = "&quot;";
    }
    else if(newChar === "\'"){
      newChar = "&apos;";
    }

    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

Hi @Mahoue

image

The output looks correct in developer tools.

Looks like this is a display issue with the editor.

Happy coding