Skip to content

Instantly share code, notes, and snippets.

@krohne
Created December 29, 2014 19:14
Show Gist options
  • Save krohne/a6ba5f16d8c839389dc9 to your computer and use it in GitHub Desktop.
Save krohne/a6ba5f16d8c839389dc9 to your computer and use it in GitHub Desktop.
Determine if integer is an even number, using last digit.
function isEven(int) {
var intStr = int.toString(),
lastDigit = intStr.charAt(intStr.length - 1);
return ("02468".indexOf(lastDigit) > -1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment