04-Dates
Last updated
Last updated
Here we'll work with having the option to include a beginning date and ending date in our search.
Let's add the conditional statements for end date and start date. Let's do this after the url and before the fetch. Note that some code has been omitted below. We are in the fetchResults
function, if you're lost:
If you print the url
to the now, you should see .
This is a rudimentary version of form validation, which is a method of ensuring that specific fields are filled out in a form. You've seen form validation. Think about when you go sign up for a new account somewhere, and you are prompted for more information. Form Validation will force you to enter information. In this case, we are not being forced to enter a start date or end date. It's optional. If the input fields for dates aren't blank, denoted by the !== ''
, the date values will be added to the URL string. If they're blank, the expressions inside of the conditionals are ignored.
There are many more options that you could use to append more items to your URL strings. If you're interested, go to the and play around.