Skip to content

Instantly share code, notes, and snippets.

@chaseconey
Created February 3, 2015 03:58
Show Gist options
  • Save chaseconey/e6aaacfa02475f6d153d to your computer and use it in GitHub Desktop.
Save chaseconey/e6aaacfa02475f6d153d to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
// The previous chapter introduced the standard function Math.min that returns its smallest argument. We can do that ourselves now. Write a function min that takes two arguments and returns their minimum.
// Your code here.
// console.log(min(0, 10));
// → 0
// console.log(min(0, -10));
// → -10
// URL: http://eloquentjavascript.net/03_functions.html#p_aW/Uoj4mDd
function min(x, y) {
if (x < y) {
return x;
}
return y;
}
console.log(min(0, 10));
console.log(min(0, -10));
</script>
<script id="jsbin-source-javascript" type="text/javascript">// The previous chapter introduced the standard function Math.min that returns its smallest argument. We can do that ourselves now. Write a function min that takes two arguments and returns their minimum.
// Your code here.
// console.log(min(0, 10));
// → 0
// console.log(min(0, -10));
// → -10
// URL: http://eloquentjavascript.net/03_functions.html#p_aW/Uoj4mDd
function min(x, y) {
if (x < y) {
return x;
}
return y;
}
console.log(min(0, 10));
console.log(min(0, -10));</script></body>
</html>
// The previous chapter introduced the standard function Math.min that returns its smallest argument. We can do that ourselves now. Write a function min that takes two arguments and returns their minimum.
// Your code here.
// console.log(min(0, 10));
// → 0
// console.log(min(0, -10));
// → -10
// URL: http://eloquentjavascript.net/03_functions.html#p_aW/Uoj4mDd
function min(x, y) {
if (x < y) {
return x;
}
return y;
}
console.log(min(0, 10));
console.log(min(0, -10));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment