Let's witness the power of the Date plugin by building a pure client-side web tool that adds or subtracts values based on the current date. The tool will allow users to enter how many days, months, or years to add or subtract to the current date. This can be helpful for getting the exact date of past events. Note that this calculator doesn't do input validation, and thus, if you were to use it, you would have to modify it so that it validates the user's input. In particular, if the user inputs an invalid value to add or subtract to the current date, such as 'apple' instead of a number, the script will break.
We'll start by setting up the HTML. The first key element is a paragraph that will show the current date. We will have three form fields to allow users to set the options for the calculation. The first form field is a
<select>
element (drop-down menu) that will determine what operation we will use: eitherAdd
orSubtract
. The second...