The basic structure of a function looks like this:
function functionName() {
// the JavaScript you want to run
}
The keyword function lets the JavaScript interpreter know you’re creating a function—
it’s similar to how you use if to begin an if/else statement or var to create a variable.
function printToday()
{
var today = new Date();
document.write(today.toDateString());
}
The function’s name is printToday. It has just two lines of JavaScript code that retrieve
the current date, convert the date to a format we can understand
function functionName() {
// the JavaScript you want to run
}
The keyword function lets the JavaScript interpreter know you’re creating a function—
it’s similar to how you use if to begin an if/else statement or var to create a variable.
function printToday()
{
var today = new Date();
document.write(today.toDateString());
}
The function’s name is printToday. It has just two lines of JavaScript code that retrieve
the current date, convert the date to a format we can understand