Help ! Equilibrium index

Help ! Equilibrium index
0

#1

Tell us what’s happening:
I just check the console.log output with my code in jsbin and it shows the output is correct
I dont know what is wrong with it.

Your code so far


function equilibrium (a) {
  var lower = 0;
  var higher = 0;
  var output = [];

  for(let i = 0; i<a.length; i++){
    for(let j = 0; j<i; j++){
      higher += a[j];
    }
    for(let k = i+1; k<a.length; k++){
      lower += a[k];
    }
    if(higher == lower){
      output.push(i);
    }
    lower = 0;
    higher = 0;
  }

  return output;

}

equilibrium([-7, 1, 5, 2, -4, 3, 0])

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/coding-interview-prep/rosetta-code/equilibrium-index/


#2

There’s something way wrong with that challenge. The values passed to your function by the assertion tests are not the test arrays.

Bummer :frowning:

BUT I am like 99.99999% sure your code would pass each of the test cases so I’ll give you a checkmark. :white_check_mark: