Intermediate Algorithm Scripting: Convert HTML Entities (BUG?)

Tell us what’s happening:
So this code is not working on freeCodeCamp, although I get the right output on…

Your code so far

function convertHTML(str) {
  // :)

  let temp = str.split("");
  for (let i = 0; i < temp.length; i++) {

    switch(temp[i]) {
      case "&":
        temp[i] = "&​amp;";
      case "<":
        temp[i] = "&​lt;";
      case ">":
        temp[i] = "&​gt;";
      case '"':
        temp[i] = "&​quot;";
      case "'":
        temp[i] = "&​apos;";

  temp = temp.join("");
  return temp;

convertHTML("Dolce & Gabbana");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0.

Link to the challenge:

Your code contains hidden characters. Paste it here:

Then remove the dots that follow the & characters and repaste into FCC.


Thank you very much :wink: How did you figure this out?

I usually use the repl at to check code. When I pasted your code in, I noticed the extra ‘dot’ characters appearing, that’s all.

A post was split to a new topic: Not passing a test on convert html entities challenges

Dude, this works like a charm…Strange that these hidden characters are not caught by other editors.

omg thank you it worked!