Created
July 14, 2015 15:27
-
-
Save himynameisdave/3ffe94aa28c1e85fff49 to your computer and use it in GitHub Desktop.
Alex's JS homework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // QUESTION 1 | |
| var combineArgs = function( a, b ){ | |
| alert(a + b); | |
| }; | |
| combineArgs("This question ", "is easy"); | |
| // QUESTION 2 | |
| var highOrLow = function( num, sayHigh, sayLow ){ | |
| if( num > 5 ) | |
| alert(sayHigh); | |
| else | |
| alert(sayLow); | |
| }; | |
| // QUESTION 3 | |
| highOrLow = function( num, sayHigh, sayLow ){ | |
| if( num > 5 ) | |
| return sayHigh; | |
| else | |
| return sayLow; | |
| }; | |
| alert( highOrLow( 6, "High number", "Low number" ) ); | |
| // QUESTION 4 | |
| var x = function sayBoom(){ | |
| alert("BOOM!"); | |
| }; | |
| x(); | |
| // QUESTION 5 | |
| var callFunction = function( fn ){ | |
| // checking if argument is a function, otherwise this would error | |
| // not really needed as the question says to just assume it is a function | |
| if( typeof fn === "function" ){ | |
| fn(); | |
| } | |
| }; | |
| callFunction( x ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment