Binary Agent infinite loop

I keep getting an infinite loop but I’m not seeing one, can somebody help me please, it is saying it is caused by the first for loop I have. Thank you.

function binaryAgent(num) {
  num=num.split(" ");
  var total=0;
  var final=[];
   for (i=0;i<num.length;i++)
  var placeHolder=1;
 var str=num[i].split("");
  for (i=str.length-1;i>=0;i--)
      if (str[i]==1) 
  return final;

binaryAgent("01000001 01000001");

You’re overwriting the iterating variable, so it’s not counting as you expect it to. Relying on implicit variable declaration is never good and this is a good example why!

The problem is since you are using the variable i in both for loops, you keep resetting the value of i. Try putting a different variable name (i.e. j) for the second for loop.

Thank you very much!