- script.js
JavaScript
var foodInGrams = muffin.ask('How many grams of food have you eaten today? Just be honest?');
var dayLimit = 80;
var foodToEat;
if (foodInGrams < dayLimit) {
foodToEat = dayLimit - foodInGrams;
} else {
console.log('Not a piece more!');
}
Result
Goalscompleted
Let’s complete our work on the program.
- Instead of the
console.log('Not a piece more!');
command, set the variablefoodToEat
to zero value. - After the
else
block, log in the console a message made up of three fragments: string'You can eat '
, variablefoodToEat
, string' more grams.'
.