Equilibrium Element
/*Given an array of N positive numbers. The task is to find the position where equilibrium first occurs in the array. Equilibrium position in an array is a position such that the sum of elements before it is equal to the sum of elements after it.*/ 1st input - N=4 desire-output=-1 arr=[3,3,5,1] 2nd input - N=5 desire-output=2 arr=[3,3,5,5,1] function equilibriumElement(N, arr){ //write code here for(i=0;i<N;i++){ left=0; for(j=0;j<i;j++){ left=left+arr[j]; } right= 0; for(k=i+1;k<N;k++){ right=right+arr[k]; } if(right===left){ console.log(i); }else{ console.log(-1); } } } what i get -1 -1 2 -1 -1 //how to get a single output?