Covering losses issue



I’m doing the problem at

I complete the problem and my answer is the same as the Help says (earnings = 157.5) but instead of accepting my answer, it says

“Oops, try again. Are you using a for loop to iterate through 10 strawberries?”

Although I obviously have : see my code below.

//To make up the money you lost from picking rotten strawberries,
//you decide to pick 10 extra strawberries everyday for the next
//7 days.

//Your earnings
var earnings = 0;

//Fill in the outer loop with an inner loop that loops through
//10 strawberries and increment your earnings by 2.25 for every 
//extra strawberry that you pick

for (var days = 7; days > 0; days--)
for(var strawberries = 1; strawberries<11; strawberries ++)
        earnings += 2.25;

//Boolean that returns true if your losses have been covered
var lossesCovered = true;

//Write an if statement that changes the lossesCovered to true
//if the earnings are greater than or equal to 225

        {lossesCovered = false}

Appreciate your help.


the course you take is no longer supported, so bugs might exist

if we look at the validation:

if (code.indexOf("< 10") < 0 &&
    code.indexOf("> 10") < 0 &&
    code.indexOf("<10") < 0 &&
    code.indexOf(">10") < 0 &&
    code.indexOf("=10") < 0 &&
    code.indexOf("= 10") < 0)
     return "Are you using a for loop to iterate through "
     + "10 strawberries?";

we see that 10 is required in the loop condition, you use 11


So it is indeed a small bug. I have replaced 11 by 10 as you suggested (and therefore 1 by 0 to get the same count) and it worked.

Out of curiosity, what else is no longer supported ?

Thanks for your quick and helpful answer.


the old learning environment is longer supported, the one which you are currently using:

the new learning environment looks different:

here is the JS course in new learning environment:

or if you prefer es6:


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