Convert HTML Entities // Why is my code not working?

Tell us what’s happening:


Can you guys take a look at the code below and help me find out why fcc refuses to accept it?
I belive it’s correct. What am I missing?

Your code so far

function convertHTML(str) {
  // :)
  let textArray = Array.of('&',"<",'>','"',"'");
  let htmlArray = Array.of('&​amp;','&​lt;', '&​gt;', '&​quot;', '&​apos;');
  let conversion = [];
  for (let ch in str) {
    let index = textArray.indexOf(str[ch]);
    if (index > -1) {
    } else {
  return conversion.join('');


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Safari/605.1.15.

Link to the challenge:

That’s pretty crazy but your ampersand is different, not sure how you’ve typed it or what keyboard are you using but the code won’t accept it.

You can see the difference in this site, when you type your ampersand we got this:


And a normal ampersand:


If you change all of your ampersands for the normal one, which you can copy here if you can’t find a way to type it: &, then your code works.

EDIT: actually it looks like there’s more problems with your keyboard, I had to type both following lines manually to make it work.

let textArray = Array.of('&', '<', '>', '"', "'");
let htmlArray = Array.of('&amp;', '&lt;', '&gt;', '&quot;', '&apos;');

In any case, the problem is not with your code per si :+1:

1 Like

Hmm, it’s a stock Macbook Air keyboard.
I’ll look around, see if I can fix it somehow. Maybe changing the language to us or something like that.
Thanks for your help, I would’ve spent ages not knowing what was going on.