Convert HTML Entities

@camperextraordinaire I tried using this code instead but it still doesn’t work:

function convertHTML(str) {
  const symbols = {
    "&": "&",
    "<": "&lt;",
    ">": "&gt;",
    "\"": "&quot;",
    "'": "&apos;"
  }
  let newStr = str
  for (const symbol in symbols) {
    if (str.indexOf(symbol) >= 0) {
      newStr = str.replaceAll(symbol, symbols[symbol])
    }
  }
   return newStr;
}

I moved the return keyword outside of the loop and declared the newStr variable outside of the loop as well. I had to make it equal to str at first so the string would stay the same if no symbols are present. I tried it again but instead I get the second arrow replaced instead of the first (<&gt;).

I just want to keep trying my own solutions before I use one of the hints.