Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>vii. Functions</title>
  7. </head>
  8. <body>
  9.  
  10. <script id="jsbin-javascript">
  11. /* Functions are considered programs within programs because we write functions
  12. to execute a block of code. In the bigger picture our program is made up of a bunch
  13. of these smaller functions that work together.
  14.  
  15. There are two phases to functions.
  16. First we must create our function.
  17. // example of creating a function //
  18. */ function newFunc(number1, number2) {
  19. console.log(number1 + number 2);
  20. };
  21.  
  22. /* Here we have created a function called newFunc and it takes a number as an argument.
  23. Then we must call or invoke our function.
  24.  
  25. // example of calling/invoking function //
  26.  
  27.  
  28. */ function(2, 4); // will return 6
  29.  
  30. /* Parameters, in our case */ (number1, number2 /* are our parameters.
  31. Parameters are placeholders that give us an idea of what is going to be passed
  32. to the function.
  33.  
  34. Arguments, in this case */ (2, 4) /* are the ACTUAL values being passed to our function.
  35.  
  36.  
  37. The syntax for a named function is:
  38.  
  39.  
  40. */
  41.  
  42. function newFunc(number1, number2) {
  43. console.log(number1 + number 2)
  44.  
  45. }
  46. </script>
  47.  
  48.  
  49.  
  50. <script id="jsbin-source-javascript" type="text/javascript">/* Functions are considered programs within programs because we write functions
  51. to execute a block of code. In the bigger picture our program is made up of a bunch
  52. of these smaller functions that work together.
  53.  
  54. There are two phases to functions.
  55. First we must create our function.
  56. // example of creating a function //
  57. */ function newFunc(number1, number2) {
  58. console.log(number1 + number 2);
  59. };
  60.  
  61. /* Here we have created a function called newFunc and it takes a number as an argument.
  62. Then we must call or invoke our function.
  63.  
  64. // example of calling/invoking function //
  65.  
  66.  
  67. */ function(2, 4); // will return 6
  68.  
  69. /* Parameters, in our case */ (number1, number2 /* are our parameters.
  70. Parameters are placeholders that give us an idea of what is going to be passed
  71. to the function.
  72.  
  73. Arguments, in this case */ (2, 4) /* are the ACTUAL values being passed to our function.
  74.  
  75.  
  76. The syntax for a named function is:
  77.  
  78.  
  79. */
  80.  
  81. function newFunc(number1, number2) {
  82. console.log(number1 + number 2)
  83.  
  84. }
  85.  
  86. </script></body>
  87. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement