Interactive online courses HTML Academy
2026-03-09 12:22 Diff

Now let’s add a mode that skips every second page.

The mode will be activated at the 'alternate' value of the mode variable.

To choose whether to print even or odd pages, we will use the variable startPage: if it equals 1, odd pages are printed, and if it equals 2 even pages are printed.

Since we have an alternative type of printing, pages are printed in an unusual way. The counter can be called approximately the same as the printing mode alternatePage.

Note that the increment is not going to be useful here. The counter will increase by two, that’s why you should use an entry of the type counter = counter + 2 or the shorter version counter += 2.

Now we’ll add a new printing mode, and in the next task, we will experiment with this mode and switch between printing even and odd pages.