Search and Replace challenge, my code is not working

right now your code returns A quick brown fox jumped over the lazy leaped A quick brown fox jumped over the lazy dog, it seems you messed up something in substituting stuff

you just haven’t completely made the changes you needed to do

for that, I really suggest you learn to use debuggin tools such console.log and pythontutor


please include challenge link for more help, you never did

Challenge link

have you fixed something else? how is it going?

Finally I passed


function myReplace(str, before, after) {
  
      var args = [before, after];
      var arr = str.split(" ");
      for (var i = 0; i < arr.length; i++) {

        if (arr[i].charAt(0) === args[0].charAt(0).toUpperCase()) {
            arr[i] = args[1].charAt(0).toUpperCase() + args[1].slice(1);
            return arr.join(" ");    
          
            }
      else if (arr[i].charAt(0) === args[0].charAt(0).toLowerCase()){
            arr[i] = args[1].toLowerCase();
            return arr.join(" ")

      } 

      }

}


myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");