Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width">
- <title>vii. Functions</title>
- </head>
- <body>
- <script id="jsbin-javascript">
- /* Functions are considered programs within programs because we write functions
- to execute a block of code. In the bigger picture our program is made up of a bunch
- of these smaller functions that work together.
- There are two phases to functions.
- First we must create our function.
- // example of creating a function //
- */ function newFunc(number1, number2) {
- console.log(number1 + number 2);
- };
- /* Here we have created a function called newFunc and it takes a number as an argument.
- Then we must call or invoke our function.
- // example of calling/invoking function //
- */ function(2, 4); // will return 6
- /* Parameters, in our case */ (number1, number2 /* are our parameters.
- Parameters are placeholders that give us an idea of what is going to be passed
- to the function.
- Arguments, in this case */ (2, 4) /* are the ACTUAL values being passed to our function.
- The syntax for a named function is:
- */
- function newFunc(number1, number2) {
- console.log(number1 + number 2)
- }
- </script>
- <script id="jsbin-source-javascript" type="text/javascript">/* Functions are considered programs within programs because we write functions
- to execute a block of code. In the bigger picture our program is made up of a bunch
- of these smaller functions that work together.
- There are two phases to functions.
- First we must create our function.
- // example of creating a function //
- */ function newFunc(number1, number2) {
- console.log(number1 + number 2);
- };
- /* Here we have created a function called newFunc and it takes a number as an argument.
- Then we must call or invoke our function.
- // example of calling/invoking function //
- */ function(2, 4); // will return 6
- /* Parameters, in our case */ (number1, number2 /* are our parameters.
- Parameters are placeholders that give us an idea of what is going to be passed
- to the function.
- Arguments, in this case */ (2, 4) /* are the ACTUAL values being passed to our function.
- The syntax for a named function is:
- */
- function newFunc(number1, number2) {
- console.log(number1 + number 2)
- }
- </script></body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement