Convert HTML Entities working but not

Tell us what’s happening:
Hi guys, I don’t know why my solution is not working being that in the console I’m printing the correct result.

Your code so far

function convertHTML(str) {
  let keys = [
        ['&', '&'],
        ['<', '&​lt;'],
        ['>', '&​gt;'],
        ['"', '&​quot;'],
        ["'", '&​apos']
    ] m => str = str.replace(new RegExp(m[0], 'g'), m[1]))
    return str;

convertHTML("Dolce & Gabbana");

Your browser information:

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

Link to the challenge:

Looks like you’re missing the semi colon after &apos but even fixing that doesn’t seem to pass the tests. Interestingly enough, the only one marked correct seems to be the one that doesn’t print the correct result (even though the browser console does print the correct result).

I’m wondering if it may be an issue with how the interpreter used handles RegExp. I retried my old solution without regex and it works.

1 Like

You should use forEach, not map for a thing like this - I don’t think is related to why it doesn’t pass but it is about using methods in the right way