• Index Power

 

Hi Guys,

I am new to developing and I just did the index power excercise and this code aparently checks out but it gives me an error. It says that with an array = [1,1,1,1,1,1,1,1,1] and n=9, the answer is -1 and should be 1.

My Code: function indexPower(array, n){ * for (var i=0; i < array.length; i++){* * if (array[i] === n){* * var m = array[n]n; * return m;* * };* *
* }
* if (array[i] != n) {* * return -1;* * }* * }**