Small issue - Intermediate Algorithm Scripting: Convert HTML Entities


I am currently with this challenge, where I wrote this easy code to solve it:
function convertHTML(str) {
  if(str.indexOf("&") > -1){
    str = str.split("&");
    str = str.join("&");
  }else if(str.indexOf("<") > -1){
    str = str.split("<");
    str = str.join("&lt;");
  }else if(str.indexOf(">") > -1){
    str = str.split(">");
    str = str.join("&gt;");
  }else if(str.indexOf("'") > -1){
    str = str.split("'");
    str = str.join("&apos;");
  }else if(str.indexOf('"') > -1){
    str = str.split('"');
    str = str.join("&quot;");
  return str;


And this is the answer I get when ask to the console

I can solve it in another way, but still, I would like to understand why this is happening, and why that “>” is not converting, probably I am missing something, but what? :face_with_monocle:

Thank you!

remember that only one condition in an if/else if chain is executed, only the first one that is true

1 Like

Oh wow :man_facepalming:
I do not know how I did not realice about it. Thank you so much!