Advertisement
Crenox

Functions in Javscript

Dec 4th, 2015
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. var functionName = function(variable)
  2. {
  3. // code code code
  4. // code code code
  5. // (more lines of code)
  6. };
  7.  
  8. // calling the function
  9. functionName(variable);
  10.  
  11. -------------------------------------------------------------------------------------------------------------------------------
  12. EXAMPLE #1
  13. var foodDemand = function (food)
  14. {
  15. console.log("I want to eat" + " " + food + ".");
  16. };
  17.  
  18. foodDemand("carrots");
  19.  
  20. OUTPUT:
  21. I want to eat carrots.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement