Convert HTML Entities - Chrome console shows right answers

Tell us what’s happening:
I can’t get three checks though Chrome console shows right answers

Your code so far


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

convertHTML('Stuff in "quotation marks"');

Your browser information:

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

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

1 Like

This was quite the pickle. Eventually figured it out though. Looks like there is an extra unseen character after the &. I’m not sure if it’s a UTF-8 artifact or something caused by your keyboard, but retyping them made the non-passing tests pass for me.

3 Likes

It is really turned out a pickle =) Only when i retyped it by on-screen keyboard i passed the task. Thanks a lot!