<!-- JavaScript:Basics code snippet 2. --> <!-- Writing text to the page by calling a function. --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- Code source: http://www.justfigures.co.uk/ --> <!-- A resource for web developers using XHTML, CSS, JavaScript, PHP --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>View code snippet page</title> <script language="JavaScript" type="text/javascript"> <!-- hide JavaScript from old browsers // this is the function with one argument function writeText(text){ document.write(text) } // end hiding script --> </script> </head> <body> <script language="JavaScript" type="text/javascript"> <!-- hide JavaScript from old browsers /* declare variable with a 'var statement', identifiers must not start with a number and by convention start with a lower case letter */ var myVar // initialise the variable by assigning a starting value myVar='Hello World' // call the function with the argument 'myVar' writeText(myVar) // end hiding script --> </script> </body> </html>