Convert Html entities - matching criteria failing

Hi, there are a couple of test cases that do not pass with my current code:

  1. The case where there are multiple occurrences of the same entities in a given string
  2. Inner double quotes

Here is my code so far:

function convertHTML(str) {
  const strSplit = str.split('')
  var indexOf = ''
  var newStr = []
  for (let i=0; i<strSplit.length; i++) {
        if (strSplit[i] == '&') {
          indexOf = str.indexOf('&');
        if (strSplit[i].match('\'.*?')) {
          indexOf = str.indexOf(strSplit[i].match('\'.*?'));
        if (strSplit[i] == '<') {
          indexOf = str.indexOf('<');
        if (strSplit[i] == '>') {
          indexOf = str.indexOf('>');
        if (strSplit[i].match('\".*?')) {
          indexOf = str.indexOf(strSplit[i].match('\".*?'));
        else {
  return newStr.join('');

Test cases that fail:

  1. convertHTML("Hamburgers < Pizza < Tacos") results in Hamburgers &lt; Pizza < Tacos
  2. convertHTML('Stuff in "quotation marks"') outputs Stuff in quotation marks

The indexOf method as you have written it will only return the first index of str each time. However, the indexOf method does accept a second argument which indicates at what index to start searching that you might be able to use and salvage your existing approach here. See indexOf parameters for more information.

Thanks for the tip, I will check up on this.