- script.js
JavaScript
var totalPages = 6; // Total number of pages
var consumptionTotal = 0; // Total toner consumption
var consumptionPerPage = 70; // Toner consumption per page
for (var page = 1; page <= totalPages; page++) {
muffin.print(page);
// Add the check here
consumptionTotal += consumptionPerPage;
console.log(consumptionTotal);
}
Result
Goalscompleted
- After the
consumptionPerPage
variable, create variableeconomyMode
, which containsfalse
. - In the loop after calling
muffin.print()
, add a condition that works ifeconomyMode
equalstrue
and if the number of the current pagepage
is greater than3
. - Inside this condition, increase
consumptionTotal
byconsumptionPerPage * 0.5
with the help of the+=
operator.
Comments