Skip to content

Instantly share code, notes, and snippets.

@finalcut
Last active January 29, 2019 13:30
Show Gist options
  • Save finalcut/9f6ed0b4ff5e55ce8ec72213b5c53e65 to your computer and use it in GitHub Desktop.
Save finalcut/9f6ed0b4ff5e55ce8ec72213b5c53e65 to your computer and use it in GitHub Desktop.
Odd or Even Number Function
<html>
<head>
<script type="text/javascript">
// define a function
function isEven(numberToTest)
{
var minVal = -1000000;
var maxVal = 1000000;
if(!isNaN(numberToTest)
&& numberToTest >= minVal
&& numberToTest <= maxVal
){
return numberToTest % 2 === 0;
}
/*
more verbose way
if(numberToTest % 2 === 0){
return true;
} else {
return false;
}
*/
}
// call the function
isEven();
</script>
</head>
<body>
this is a page containing a function to determine
if a number is odd or even. It is purely for demonstration purposes.
the min max test is not accurate/complete.
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment