Skip to content

Instantly share code, notes, and snippets.

@himynameisdave
Created July 14, 2015 15:27
Show Gist options
  • Select an option

  • Save himynameisdave/3ffe94aa28c1e85fff49 to your computer and use it in GitHub Desktop.

Select an option

Save himynameisdave/3ffe94aa28c1e85fff49 to your computer and use it in GitHub Desktop.
Alex's JS homework
// 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