Skip to content

Instantly share code, notes, and snippets.

@katanacrimson
Created August 22, 2012 02:33
Show Gist options
  • Save katanacrimson/3421667 to your computer and use it in GitHub Desktop.
Save katanacrimson/3421667 to your computer and use it in GitHub Desktop.
Football season is here
$ node pass.js
99.3
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
@katanacrimson
Copy link
Author

CHALLENGE ACCEPTED. Code golf engage.
https://gist.github.com/3421667

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment