Skip to content

Instantly share code, notes, and snippets.

@kenjinp
Created August 7, 2017 05:44
Show Gist options
  • Save kenjinp/846bb657eef1cb0b018cddd536d691bd to your computer and use it in GitHub Desktop.
Save kenjinp/846bb657eef1cb0b018cddd536d691bd to your computer and use it in GitHub Desktop.
/**
* Returns if the number is dense or not (averge of digits > 7)
* @param {int} int to test
* @returns {boolean}
*/
function isDenseNumber(int) {
let digitArray = []
let valDigits = 0
while (int) {
let digit = int % 10
digitArray.push(digit)
valDigits += digit
int = parseInt(int / 10)
}
digitArray.reverse()
let isDense = (valDigits / digitArray.length) > 7
return isDense
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment