Skip to content

Instantly share code, notes, and snippets.

@mojenmojen
Created September 25, 2016 16:40
Show Gist options
  • Save mojenmojen/1333ee96106eee3c069fdb492a524e11 to your computer and use it in GitHub Desktop.
Save mojenmojen/1333ee96106eee3c069fdb492a524e11 to your computer and use it in GitHub Desktop.
Write a function min that takes two arguments and returns their minimum.
// compare firstNum and secondNum and return the smaller of the two
function min( firstNum, secondNum ) {
if ( firstNum < secondNum )
return firstNum;
else
return secondNum;
}
console.log(min(0, 10));
// → 0
console.log(min(0, -10));
// → -10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment