Created
August 22, 2012 02:33
-
-
Save katanacrimson/3421667 to your computer and use it in GitHub Desktop.
Football season is here
This file contains hidden or 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
$ node pass.js | |
99.3 |
This file contains hidden or 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 passerRating(attempts, completions, yards, tds, interceptions) { | |
var result = 0 | |
var array = [ | |
((completions / attempts) - .3) * 5, | |
((yards / attempts) - 3) * .25, | |
(tds / attempts) * 20, | |
2.375 - ((interceptions / attempts) * 25) | |
] | |
array.forEach(function(val) { | |
result += Math.max(0, Math.min(val, 2.375)) | |
}) | |
return Math.round((result / 6) * 1000) / 10 | |
} | |
console.log(passerRating(30, 18, 280, 2, 1)) // 99.3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CHALLENGE ACCEPTED. Code golf engage.
https://gist.github.com/3421667