Interactive online courses HTML Academy
2026-03-09 12:30 Diff

The program perfectly shows when you can eat more, but does not report anything if there is any excess. Because of this, the Muffin nearly ate extra 10 grams! You must remedy the situation.

Create a fork that will be triggered if the condition is not met. For this, we use the following pattern:

if (condition) { actions; } else { other actions; }

The “action” fork is triggered if the condition is met. The “other actions” fork is triggered if the condition is not met.

This is how we tell the program how to act in this or that situation. Such structures can be read as follows: if the condition is met, complete the action, otherwise complete other actions. In our case, the condition is as follows: if the amount of food eaten is less than the daily amount, then you can eat more, otherwise you cannot.

When all conditions of work are described, the program can work with real data from the boss. Let’s add the second branch of the condition to complete development of the “Can I Eat More?” program.