Convert HTML Entities - stringSearch issue

Tell us what’s happening:
for the case i have 2 ‘>’ which need replacing it replaces the first one fine but then when i go over the loop again and search it still finds one at charecter 11 so does not find the second or change it, is this something to do with these codes for speical chars does the method read that as the same as > still hence it not updaing?

Your code so far

function convertHTML(str) {
let regex = /[&<>"']/g
let arr = [...str.matchAll(regex)];

for (let i = 0 ; i < arr.length ; i++){
let num =

switch(str.charAt(num)) {
  case '&':
str = str.replace('&', '&amp;')
  return str
  case '<':
  str = str.replace('<', '&​lt;')
  case '>':
  str = str.replace('>', '&​gt;')
  return str
  case '"':
  str = str.replace('"', '&​quot;')
    case "'":
  str = str.replace("'", '&​apos;')
    return str
} }
return str;

console.log(convertHTML("Hamburgers < Pizza < Tacos"));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0.

Link to the challenge:

  1. You have hidden characters in your html entity strings. Type them out manually.

  2. When you loop over the array the second time it finds the & in the entity string you did the replace with on the first loop iteration.