Defining Functions with Parameters - Javascript Language Basics

Javascript examples for Language Basics:Introduction

Introduction

JavaScript allows you to define parameters for functions.

Demo Code

ResultView the demo in separate window

<!DOCTYPE HTML>
<html>
    <head>
        <title>Example</title>
    </head>
    <body>
        <script type="text/javascript">

            function myFunc(name, topic) {
                document.writeln("Hello " + name + ".");
                document.writeln("It is " + topic + " today");
            };//from  w w  w  .j  a va2  s  .  c o m

            myFunc("Joe", "Monday");
        </script>
    </body>
</html>

Related Tutorials