Convert HTML Entities help!

Tell us what’s happening:
Hey guys,

My code is working in a browser console, but not in the FCC console. Is it a bug or something? Im getting the correct output when I run it elsewhere but im only passing half the tests on the FCC editor. Please help!

Your code so far

function convertHTML(str) {
  // :)
  let items = {
  var strArray = str.split('')
  for (let i=0;i<strArray.length;i++) {
    if(RegExp(/&|<|>|"|'/).test(strArray[i])) {
      strArray[i] = items[strArray[i]]
  let newString = strArray.join('')
  return newString;

convertHTML("Dolce & Gabbana");

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:

Mine, too. Works fine in browser console and under Node.js. In fCC console every other one fails. What is this &#8203; that it says I’m supposed to have?

My code:

function convertHTML(str) {
  let arr = str.split('');
  for (let i in arr) {
    if (arr[i] === '&') { arr[i] = '&amp;'; }
    if (arr[i] === '<') { arr[i] = '&​lt;'; }
    if (arr[i] === '>') { arr[i] = '&gt;'; }
    if (arr[i] === '"') { arr[i] = '&​quot;'; }
    if (arr[i] === "'") { arr[i] = '&apos;'; }
  return arr.join('');

fCC output:

// running test
convertHTML("Hamburgers < Pizza < Tacos") should return Hamburgers &&#8203;lt; Pizza &&#8203;lt; Tacos.
convertHTML(&apos;Stuff in "quotation marks"&apos;) should return Stuff in &&#8203;quot;quotation marks&&#8203;quot;.
convertHTML("<>") should return &&#8203;lt;&&#8203;gt;.
// tests completed

There looks to be a bug in the code. It should expect Hamburgers &​lt; Pizza &​lt; Tacos according to the requirements

Is there a fix coming? Do I need to request that somewhere? I’m working on the last JS Algorithms Cert project now, and this exercise is the only one I have in that track w/o a checkmark. Yeah, I know, it’s not a big deal. It just sticks out like a sore thumb on my curriculum map, as if it’s giving me the finger every time I see it. Know what I mean? LOL!

I think I may have figured this one out as it worked for me. You need to parse the return string and remove all \u200b “zero width characters”. This did the trick for me.


Ok! Passed it! I just manually typed the whole thing into fCC again from scratch. I think something screwy must have happened when copying code back and forth from fCC site to VSCode. Something similar may have been happening in this SO post. Weird. I do this all the time and this is the first time that has happened.
Anyway… thanks for the tip!