Problem with Intermediate Algorithm Scripting: Convert HTML Entities

Hey there, good folks.
I can’t understand why this code doesn’t pass the check in this challenge. Output seems right though.
If you would be so kind to help me get it.

function convertHTML(str) {
  let map = {
    '&' : "&​amp;",
    '<' : "&​lt;",
    '>' : "&​gt;",
    "'" : "&​apos;",
    '"' : "&​quot;"
  return str.replace(/[&<>'"]/g, x => map[x]);

console.log(convertHTML('Stuff in "quotation marks"'));
1 Like

There is a hidden character between the & and the l/g/a in your first three entries (&quot seems fine). It’s present in the challenge description, so copy pasting has copied that across to your code (this has been fixed, but isn’t live on main FCC atm).

Either delete the hidden character or just delete and retype each entity code (rather than copy pasting)

Inspected the code with dev tool and found that &#8203 hidden char. Thank you, good sir!

1 Like