Implement an HTML Entity Converter - Implement an HTML Entity Converter

Tell us what’s happening:

Hi. If i remove i pass the lab but the console don’t display what the lab want. With this code, i display what the lab want but don’t pass the lab. How can i display correctly “&” instead of “&”?

Your code so far

function convertHTML(str) {
  let empty = "";
  for (const i of str) {
    
    if (i === "&") {
      empty += "&<ZWNJ>amp;";

    }else if (i === "<") {
      empty += "&<ZWNJ>lt;";

    }else if (i === ">") {
      empty += "&<ZWNJ>gt;";

    }else if (i === '"') {
      empty += "&<ZWNJ>quot;";

    }else if (i === "'") {
      empty += "&<ZWNJ>apos;";

    } else {
      empty += i;
    }
  }
  return empty;
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36

Challenge Information:

Implement an HTML Entity Converter - Implement an HTML Entity Converter

Hi. If i remove <Z_W_N_J_> i pass the lab but the console don’t display what the lab want. With this code, i display what the lab want but don’t pass the lab. How can i display correctly “&_amp_;” instead of “&”?

you can’t display the html entitiies in the editor console, it’s HTML too, so the html entities are displayed as the symbol, but you need to use them. If you open the browser console you can see them

1 Like