- script.js
JavaScript
var mode = 'document'; // Printing driver mode
var pageNumber = 5; // Copied page number
var copyCount = 7; // Number of copies
var totalPages = 6; // Pages in the document
if (mode === 'pageCopy') {
for (var copies = 1; copies <= copyCount; copies++) {
muffin.print(pageNumber);
}
}
if (mode === 'document') {
for (var page = 1; page <= totalPages; page++) {
muffin.print(page);
}
}
Result
Goalscompleted
Let’s add the printing mode of the document pages in the reverse order.
- At the end of the program, add a check that compares
modewith the value of'reverse'. - Inside this check, add a loop that decreases the value of
reversePagefromtotalPagesto1inclusively. Decrease the value ofreversePageby one at each iteration. - Inside the loop, add the print command for the current page
reversePage. - Change the value of the
modevariable to'reverse'.
Comments