Intermediate Algorithm Scripting: Convert HTML Entities

My way makes more sense to me than the ones in the Hints section, but I’d sure like some critique:

function convertHTML(str) {
  const arr = [["&","&amp;"],['>','&gt;'],['<','&lt;'],["'",'&apos;'],['"','&quot;']];
  for (let i=0; i < arr.length; i++)  {
    str = str.replace(new RegExp(arr[i][0],"g"),arr[i][1]);
  }
return str;
}

Edited to fix the bad copy/paste that made it fail the tests.

OK, thanks. Sorry for posting the wrong version.

Thanks, this procedure helped me a lot:

function convertHTML(str) {
  // &colon;&rpar;
  const mapa = {
    "&": "&amp;",
    "<": "&lt;",
    ">": "&gt;",
    '"': "&quot;",
    "'": "&apos;"
  };

  console.log("Texto original:", str);
  for(let myKey in mapa) {
     str = str.replace(RegExp(myKey, 'g'), mapa[myKey]);
}
  return str;
}