Identifying Rotten Strawberries


#1

Why am I getting 417?

//You have 500 good strawberries, indexed from 1 to 500
var goodStrawberries = 500;

//For every strawberry whose index is divisible
//by 5, decrement the value of goodStrawberries by 1
for (var i = 0; i < goodStrawberries; i++){
if(i % 5 === 0){
goodStrawberries–;
}
}
console.log(goodStrawberries);

And why is it referring me to glossary to learn about for loops when glossary is a totally blank page?


#2

Please post a link to the exact exercise. Thanks.


#3

Ok I figured it out, but dang what a frustrating experience.


#4

Could still use a link so we can investigate that blank page you speak of.

Was the problem related to starting on 0? 0 % 5 === 0.


#5

No the problem was that I was getting 416 instead of 400 because of decrementing the variable every iteration. this is the challenge https://www.codecademy.com/courses/introduction-to-javascript/0/3# and it doesn’t teach you about for loops at all, it just says to learn about them, go here http://www.codecademy.com/glossary and that page has nothing of value.


#6

The above link points to a member profile. Here is the link to the glossary…

https://www.codecademy.com/articles/glossary-javascript

That is the link in the lesson page, so I don’t understand how the other link got in there.


#7

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