Getting error in this, could you guys spot the error
thanks in advance

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

//Boolean value rotten
var rotten = false;

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

if (index % 5 === 0)
console.log('rotten =true');

    console.log('rotten = false');


console.log() is a function to log something to the console (output window), why would you use it when setting a variable?


= has a return value. It is perfectly valid to set a value and print it at the same time. Mind, as a string it is not code so nothing will happen but

 > console.log(rotten=true)
=> undefined
 > rotten
=> true   


Oh i get it, my mistake.

Thanks you the help


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