Dont understand the Question - Attempt at answer


#1


https://www.codecademy.com/courses/spencer-sandbox/0/2?curriculum_id=506324b3a7dffd00020bf661


I don't get anything at all. No error just nothing. No console log.

// 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.
for(var i = 0;i === multiplesOfEight;i++) {
var answer = multiplesOfEight[i] % 8 !== 0;
console.log(answer);
}

#2

your loop:

for(var i = 0;i === multiplesOfEight;i++)

in particular your condition, for the first run/iteration of the loop, the condition is false, so the whole loop never runs


#3

The question asks you to replace the x in this code var answer = multiplesOfEight[X] % 8 !== 0; with the number that doesn't fit in this array var multiplesOfEight = [8,16,24,32,40,58];

No need to write a loop.


#4

Thanks, ill try that


#5

Yeah i thought so, just didnt understand the question. Thanks.


#6

ahhh multiplesOfEight.Length was what i was missing


#7

// 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;
console.log(answer);
return answer;

// 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;
console.log(answer);
if(answer === true) return answer;

OK so 58 is not modular to 8. Cool, i still don't get a result.


#8

I believe you are over complicating the question, the only thing you are supposed to do, like the question says is replace X in line 6. So no need for what's below.


#9

Yes i was Over complicating things. Ok so its a simple change like below. I swear i tried this before and it didn't work. Thanks for helping me out.

var answer = multiplesOfEight[58] % 8 !== 0;

#10

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.