Implement an HTML Entity Converter - Implement an HTML Entity Converter

Tell us what’s happening:

I’m having trouble getting my “replace” function working within this lab. I’ve checked the Chome Console through Dev Tools and I’m not seeing the right outputs there either. Am I missing some syntax, or am I approaching this problem the wrong way? Thanks!!

Your code so far

function convertHTML (string) {
  let result = string;
  result = result.replaceAll("&", ">&");
  result = result.replaceAll("<", "&lt;");
  result = result.replaceAll(">","&gt;");
  result = result.replaceAll("\"", "&quot;");
  result = result.replaceAll("\'", "&apos;");
  return result;
};

console.log(convertHTML("Dolce & Gabbana"));

// Output: Dolce & Gabbana

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.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

Hi @snaylspace,

You have a typo on this line.

Also, the replaceAll() method does not replace the original string in place. Instead, it creates a new string,
String.prototype.replaceAll() - JavaScript | MDN
JavaScript String replaceAll() Method

Open your browser’s console to see the changes made by your code (they will be parsed in the fCC console).

Happy coding

Thanks @dhess ! I was able to solve this problem. :slight_smile: