Convert HTML Entities Problem

Tell us what’s happening:
Hello, I’m not sure why my code is not passing all of the tests. It fails the second, fourth, and sixth test, but it passes the rest of the tests. I am aware that there is a bug regarding zero-width characters and I have already removed them (via JSFiddle).

Your code so far


function convertHTML(str) {
  let regex = /[&<>"']/gi;
  let char = str.match(regex);

  if (char == "&") {
    str = str.replace(regex, "&amp;");
  }
  else if (char == "<") {
    str = str.replace(regex, "&lt;");
  }
  else if (char == ">") {
    str = str.replace(regex, "&gt;");
  }
  else if (char == '"') {
    str = str.replace(regex, "&quot;")
  }
  else {
    str = str.replace(regex, "&apos;")
  }
  console.log(char);
  console.log(str);
  return str;
}

convertHTML(">");

Your browser information:

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

Link to the challenge:

In your code, char is an array. ´char´ isn’t a string. Then, this sentence if (char == "&") is not appropiate.

Thank you for your help