Identifying Rotten Strawberries

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?

Please post a link to the exact exercise. Thanks.

1 Like

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

1 Like

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.

1 Like

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.

4 Likes

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.

2 Likes

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