# Identifying Rotten Strawberries

#1

//Here is an example of a strawberry index
var index = 20;

//Boolean value rotten
var rotten = false;
var strawberries = 500;

//If the index is divisible by five, the strawberry is rotten, so set
//rotten to true. False, otherwise
if(strawberries %= 5 == index){
false;
}else{
true;
}

#2

Hi @iqbalhanafi,

Itâ€™s better to provide a link to the exercise so that others can have a look on the exercise itself and you can learn how to format your code here.

//If the index is divisible by five, the strawberry is rotten, so set
//rotten to true. False, otherwise

So you just need var `index` and var `rotten`.

var `strawberries` is not needed.

How to check index is divisible by five? What value should you compared to if the index is divisible by five?

``````if ( ________ % 5 === _____ )
``````

Next, if index is divisible by 5, means if the condition is true, set rotten to true, so you need to reassign value to rotten, like this:

``````rotten = true;
``````

Now finish the code for the else part with the same method above.

Hope this clarifies

#3

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