- 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
consumptionPerPagevariable, create variableeconomyMode, which containsfalse. - In the loop after calling
muffin.print(), add a condition that works ifeconomyModeequalstrueand if the number of the current pagepageis greater than3. - Inside this condition, increase
consumptionTotalbyconsumptionPerPage * 0.5with the help of the+=operator.
Comments