Strange Errors in Convert HTML Entities

Tell us what’s happening:
Help me, please!!!
My object is created

let entitiesHTML = {
    '&':'&​amp;',
    '<':'&​lt;',
    '>':'&gt;',
    '"':'&quot;',
    '\'':'&apos;'
  };

But it became {&: "&​amp;", <: "&​lt;", >: "&gt;", ": "&quot;", ': "&apos;"} as the following picture

Who can explain to me, please?

Your code so far


function convertHTML(str) {
  // &colon;&rpar;
  let entitiesHTML = {
    '&':'&​amp;',
    '<':'&​lt;',
    '>':'&gt;',
    '"':'&quot;',
    '\'':'&apos;'
  };

  return str.split('').map((entity) => entitiesHTML[entity] || entity).join('');
}

convertHTML("Dolce & Gabbana");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) coc_coc_browser/80.0.180 Chrome/74.0.3729.180 Safari/537.36.

Link to the challenge:

You have hidden characters in the first two entity strings (zero-width space). Type them out manually.

The hints are not always right. Review

Can you say more about hidden characters? And give me some examples, please!!!

I solved it without hints. But I tried using code in hints to solve. if I copy-paste, it will be done, however if I retype code myself, that error will be occurred.

You have Zero-width space characters most likely from copying the entities from the challenge page (this has been fixed on the master branch BTW).

You can check it by copy and pasting your code into the browser console, the characters will show up as red dots (and you can hover over them to see the code \u200b).

1 Like