Created
September 25, 2016 16:40
-
-
Save mojenmojen/1333ee96106eee3c069fdb492a524e11 to your computer and use it in GitHub Desktop.
Write a function min that takes two arguments and returns their minimum.
This file contains 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
// 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