Advertisement
Guest User

Untitled

a guest
Aug 1st, 2015
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1.  
  2.  
  3. // QUESTION 1
  4. var combineArgs = function( a, b ){
  5. alert(a + b);
  6. };
  7.  
  8. combineArgs("This question ", "is easy");
  9.  
  10.  
  11. // QUESTION 2
  12. var highOrLow = function( num, sayHigh, sayLow ){
  13. if( num > 5 )
  14. alert(sayHigh);
  15. else
  16. alert(sayLow);
  17. };
  18.  
  19.  
  20. // QUESTION 3
  21. highOrLow = function( num, sayHigh, sayLow ){
  22. if( num > 5 )
  23. return sayHigh;
  24. else
  25. return sayLow;
  26. };
  27.  
  28. alert( highOrLow( 6, "High number", "Low number" ) );
  29.  
  30.  
  31. // QUESTION 4
  32. var x = function sayBoom(){
  33. alert("BOOM!");
  34. };
  35.  
  36. x();
  37.  
  38.  
  39. // QUESTION 5
  40. var callFunction = function( fn ){
  41. // checking if argument is a function, otherwise this would error
  42. // not really needed as the question says to just assume it is a function
  43. if( typeof fn === "function" ){
  44. fn();
  45. }
  46. };
  47.  
  48. callFunction( x );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement