Convert HTML Entities problem with creating strings with semicolon, but only in FCC

Tell us what’s happening:

When I try to create a string in an array with the HTML entities, when I put the semicolon at the end of the string it no longer interprets the string correctly.

The output for the code below is as described in the comments.

If I run the same code in CodePen, for the last line I get on the console:

(This is NOT what I posted – it got converted when I saved my post. When I look at it now when editing it looks right, after it’s posted it does not. I imagine it’s part of the same problem.)
[["&","&"],["<","<"],[">",">"],[""","""],["’","’"]]

which I think is what I’m going for.
(or would be, if it would show accurately here).

On the last line of my code below, there is supposed to be this comment:
// in FCC returns [["&","&"],[">","<"],[">",">"],[""","""],["’","’"]];
which shows when I’m editing but not in the posted version.

Your code so far


let subst;
subst = ["&", "&amp"]; // in FCC returns ["&","&amp"]
console.log(JSON.stringify(subst));
subst = ["&", "&amp;"]; // in FCC returns ["&","&"]
console.log(JSON.stringify(subst));
subst = ["&", "&am;"]; // in FCC returns ["&","&am;"]
console.log(JSON.stringify(subst));
subst = ["&", "&a;"];  // in FCC returns ["&","&a;"]
console.log(JSON.stringify(subst));
subst = [["&", "&amp;"], ["<", "&lt;"], [">", "&gt;"], ['"', "&quot;"], ["'", "&apos;"]] // in FCC returns [["&","&"],[">","<"],[">",">"],["\"","""],["'","'"]]; // in FCC returns [["&","&"],["<","<"],[">",">"],["\"","""],["'","'"]]
console.log(JSON.stringify(subst));

Your browser information:

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

Link to the challenge:
I’m not allowed to put in links, so had to take out the link that was automatically put here

In the browser console they will show up correctly. The fcc console is still on the webpage so it is going to convert those things

1 Like

Thanks for getting back to me so quickly! Yeah, that was the problem. Too bad the challenge doesn’t have a warning that you have to use the real console if you want to see what you’re doing. I don’t imagine I’m the only person who’s been confused by this. But now I’m through it. Thanks again!