Array indexing from 1 not 0? 1.2 Question


#1

Hi,

Wondering why the code below passes - shouldn't multiplesOfEight[4] be the correct answer if an array indexes from 0? I've seen this happen in another exercise as well.

Thanks!

// Here is an array of multiples of 8. But is it correct?
var multiplesOfEight = [8,16,24,32,40,58];

// Test to see if a number from the array is NOT a true
// multiple of eight. Real multiples will return false.
var answer = multiplesOfEight[5] % 8 !== 0;


#2

that depends, i think multiplesOfEight[5] is correct, i assume the exercise ask you to select the 4th element? we start count from 1, so the 4th element on a count which starts at one, is 5 on a counts that start at zero


#3

I guess that's my question...the exercise emphasizes to start from a count of 0 (and reminds you that's what arrays do) but only starting from a count of 1 returns the correct result. Is it a mistake?


#4

Oh wow. Never mind. I was wrong. Thanks for the quick answer!