Equilibrium index solution

Proposed Solution
function equilibrium(a) {
  let indicies = [];
  for(let i = 0; i < a.length; i++){
    let left = a.slice(0, i).reduce((a, e) => a + e, 0),
      right = a.slice(i + 1).reduce((a, e) => a + e, 0);
    if(left == right){
      indicies.push(i);
    }
  }
  return indicies;
}

Challenge: Equilibrium index

Link to the challenge:

Do you have a question?

1 Like

posting a solution because there wasn’t one

Hello there.

Thank you, for your contribution. For future contributions, please wrap your solution within :

[details]
```
code goes here...
```
[/details]

Your solution will be reviewed by the fcc team and moderators

Please follow the instructions on how to post proposed Guide Post solutions.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.