Convert HTML Entities - Please help

Tell us what’s happening:
Can you please tell me what’s wrong in my code. Thanks

Your code so far


function convertHTML(str) {
  // :)
  let resultArr = str.split("");
  resultArr.forEach( (x,i,a) => {
    switch(x){
      case "&":
        a[i] = '&​amp;';  
        break;
      case "<":
        a[i] = "&​lt;";
        break;
      case ">":
        a[i]= "&​gt;";
        break;
        case "'":
        a[i] = "&​apos;";
        break;
        case'"':
        a[i] = "&​quot;";
        break;
    }
  })
 
  resultArr = resultArr.join("");
  console.log(resultArr);
  return resultArr;
}
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/74.0.3729.131 Safari/537.36.

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

Make sure to manually type out your conversion value, because if you copy/pasted from somewhere, it appears you picked up a hidden character in the string which is throwing off the tests.

1 Like

Thank you so much,you’re right
Test passes now