Search and Replace code showing wrong

Tell us what’s happening:

The bellow code is showing wrong but the console is showing the correct result please help.

Your code so far

function myReplace(str, before, after) {
  var tst = [];
  var str_arr = str.split(" ");
  for (var i = 0; i < str_arr.length; i++){
    
    if (str_arr[i] == before)
      str_arr.splice(i,1,after);
  }
  //return str_arr[1];
  return str_arr.join(' ');
}

myReplace("Let us get back to more Coding", "Coding", "algorithms");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36.

Link to the challenge:

What do the failing tests say?

On console the result is totally correct but few arguments are showing wrong in the result board.
I tried to match the length, and they matched.

Which tests are failing?

Am I missing something?

ohhhh! I see now…
thanks for your time.

:+1:t2: Good job finding it on your own.