Function parameters allow a function to operate on different inputs. In this case, inDate
is the local name given to the argument supplied when you call the function. So the function should be:
function dateUS(inDate) {
document.write(getMonth(dateUS) + "https://stackoverflow.com/" + dateUS.getDate() + "https://stackoverflow.com/" + dateUS.getFullYear());
}
If you want to write today’s date, you call the function this way:
dateUS(today);
There isn’t enough information in the question to explain why undefined
is being shown after the date. My guess is you’re doing something like:
document.write(dateUS(today));
This would be appropriate if dateUS
returned its result instead of writing it itself. That probably would be a better way to define it, but it’s not how you did it.