# JavaScript Algorithm: Equal Sides of an Array

JavaScript Algorithm: Equal Sides of an Array. Return an array index where the sum of the left side of the index in the array is equal to the sum of the right side. If you find this algorithm helpful, check out my other JavaScript algorithm solution articles.

### Return an array index where the sum of the left side of the index in the array is equal to the sum of the right side

We are going to write a function called `findEvenIndex` that accepts an array, `arr`, as an argument.

You are given an array of integers. The purpose of the function is to take the array and return the index where the sum of the integers to the left of the index is equal to the sum of integers to the right of the index. If there is no such thing or if the array is empty, return `-1`.

Example:

``````[1,2,3,4,3,2,1] // output: 3
[1,100,50,-51,1,1] // output: 1``````

If we look at the first example, the fourth number (index 3) is where the sum of the left side of the index equals the sum of the right side of the index.

Left side of index 3: `1 + 2 + 3 = 6`

Right side of index 3: `3 + 2 + 1 = 6`

If you look at the second example. It’s the same thing:

To the left of index 1: `1`

To the right of index 1: `50 + -51 + 1 + 1 = 1`

## Principles of Functional Programming in JavaScript That Will Make Your Coding Life Easier

Who else loves to write side-effects-free functions? I think we, as programmers, all do. Today, in this story, I will walk you through the basic principles of functional programming that will make your coding life easier.

## 4 Ways You Can Get Rid of Dirty Side Effects for Cleaner Code in JavaScript

4 Ways You Can Get Rid of Dirty Side Effects for Cleaner Code in JavaScript. Bugs are born in many ways. Creating side effects is one of them. Some people say side effects are evil, some say they’re not.

## Coding Interviews: Common Algorithms

I previously wrote about some common coding algorithms that you’ll run into on your job search. The article was received fairly well so I thought I’d do a couple more to help in your journey to becoming more familiar with algorithms.

## Kadane’s Algorithm: Gateway to Dynamic Programming

This tricky Kadane’s Algorithm with a deceptively simple solution is a great introduction to more optimal problem-solving practices. Continue ...

## Coding 101: Programming Language Building Blocks

This article will introduce the concepts and topics common to all programming languages, that beginners and experts must know!