Light Mode
Dark Mode
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;* * }* * }**

  • index
  • power
Created: July 31, 2019, 9:42 p.m.
Updated: Aug. 1, 2019, 3:46 p.m.
0
1
User avatar
marianods81