Building the Right Environment to Support AI, Machine Learning and Deep Learning
Most of this should look pretty familiar. You've got your basic array, conditional statements, prompt and alert boxes. Now let's break it down and see what we did.
And this is what it looks like:
This one should be pretty easy to understand. The first four variables are like the previous examples. The next one,
monarr, is given the value of an array whose elements are the length of each month, from January to December. There's also a formula for determining a leap year. You might want to add this to your collection of snippets. (You do have a collection of snippets, don't you?)
In the script above, if the year is a leap year, then the second element in the array of the variable
monarr is equal to 29. If you think about it, the array represents the number of days in the months, beginning with January, which has an index number of "0". That means that the second element in the array (
monarr) is February, with an index number of "1." The leap year calculation then changes its array element to "29" for this calculation.
The "Y2K" Problem
You will find many scripts have what is called the "Y2K fix." That means they will have something like the following code:
(This is why the
getYear method is deprecated. This also applies to the
setYear method, which was deprecated in favor of the
If you come across a script like the one above, just change the
getYear method to the
getFullYear method and remove the following line:
That wraps up this section on the
Until next time ... keep on scriptin'!
IT Solutions Builder TOP IT RESOURCES TO MOVE YOUR BUSINESS FORWARD
Which topic are you interested in?
What is your company size?
What is your job title?
What is your job function?
Searching our resource database to find your matches...