- script.js
JavaScript
var totalPages = 6; // Total number of pages
for (var page = 1; page <= totalPages; page++) {
muffin.print(page);
}
Result
Goalscompleted
- After the variable
totalPages, declare a variableconsumptionTotalequal to0. - After it, create a variable
consumptionPerPage. It equals70. - Inside the loop, after initiating the
muffin.print()command, increase the value ofconsumptionTotalvariable byconsumptionPerPagewith the help of the+=operator. - Below, in the loop, log the
consumptionTotalvalue in the console.
Comments