Trying to figure out a logic ( I am a newbie willing to learn more )

var apple = 20;
var banana = 18;
var peach = apple-banana;

if ((banana*apple) > 360){
    document.write("<h3> (banana*apple) is greater than 360  </h3>");
}
else {
  document.write("<h3> (banana*apple) is less than 360  </h3>");

So the point was trying to see what’s gonna happen when the value is equal to 360? But what I got from my web-page shows (banana*apple) is less than 360.
Since I didn’t execute = in this statement… Shouldn’t the web not show up anything instead of saying it’s less than 360? Because 20*18 =360 …
Please enlight me, much appreciated during this crazy adventure since starting this course!
:raising_hand_woman::raising_hand_woman::raising_hand_woman:

Your ‘if’ statement is only true for anything greater than 360 and based off of that logic, 360 is not greater than 360 therefore the ‘else’ condition gets executed instead. What you wrote in the ‘else’ block for the <h3> tag may have been the source of the confusion as it should read ("<h3> (banana*apple) is not greater than 360 </h3>"); to reflect the actual condition being checked.

1 Like

Thank you for the clarification. So that’s kind of logic when it’s not greater than 360 then it determines less than 360 instead ?

But I wonder if those conditions are not met the web should just show nothing right? Like when I wrote the wrong code then the web usually not showing anything.

Now I just sort myself out =D:joy::joy::joy::joy:

Thank you for the help, I believe it’s part of learning when you question yourself then helped by others then figure out at the end !

1 Like