- script.js
JavaScript
var mode = 'reverse'; // Printing driver mode
var pageNumber = 5; // Copied page number
var copyCount = 7; // Number of copies
var totalPages = 6; // Pages in the document
var startPage = 1; // Starting page
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);
}
}
if (mode === 'reverse') {
for (var reversePage = totalPages; reversePage >= 1; reversePage--) {
muffin.print(reversePage);
}
}
if (mode === 'alternate') {
for (var alternatePage = startPage; alternatePage <= totalPages; alternatePage += 2) {
muffin.print(alternatePage);
}
}
Result
Goalscompleted
Now let’s use the mode added in the previous task.
- Change the value of the
mode
variable to'alternate'
. - To print even pages, change the value of the
startPage
variable to2
.
Comments