Convert HTML Entities My code works but fails the test

Tell us what’s happening:

As far as i can tell this code is working, but it fails all the tests.
Sorry if it just a silly spelling mistake.

Your code so far


function convertHTML (str) {
  var replaceChars = {
    "<": "&​lt;",
    ">": "&​gt;",
    "'": "&​apos;",
    '"': "&​quot;",
    "&": "&​amp;"
  }
  return str.replace(/<|>|'|"|&/g, function (match) {
    return replaceChars[match]
  })
}

console.log(convertHTML("Dolce & Gabbana."))

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/convert-html-entities/

My guess is you copied/pasted the replacement values from the page somewhere? Try manually typing out the replacement values. Some users have had copied/pasted from sources which have hidden characters that would through off the tests.

Ok, so i rewrote the function witch passes all the test but, now the console output is wrong, i think there’s a bug on that page?

function convertHTML (str) {
  var htmlChars = {
    '<': '&lt;',
    '>': '&gt;',
    "'": '&apos;',
    '"': '&quot;',
    '&': '&amp;'
  }
  return str.replace(/<|>|'|"|&/g, function (match) {
    return htmlChars[match]
  })
}

console.log(convertHTML("Dolce & Gabbana"))

Not sure why the output panel doesn’t show the correct output, but the browser console prints the correct one.

Probably just needed to refresh the page or something, never mind. Thanks for your help anyway