Created
February 1, 2016 17:13
-
-
Save giannispan/56c1e3c9cd3ad52b273b to your computer and use it in GitHub Desktop.
Is Integer Array ?
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
function isIntArray(arr) { | |
console.log(arr); | |
if (arr == null) return false; | |
if (arr.constructor !== Array || arr == null) return false; | |
if (arr.length < 1) return true; | |
for (var i = 0; i < arr.length; i++) | |
if ((arr[i] % 1 != 0)) return false; | |
else | |
var check = isInt(arr[i]); | |
return check; | |
} | |
function isInt(value) { | |
return !isNaN(value) && Number.isInteger(value) && (value.toFixed(0) % 1 == 0) && | |
parseInt(Number(value)) == value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment