Created
July 16, 2015 12:22
-
-
Save montyanderson/09dd6e53b32a399c573d to your computer and use it in GitHub Desktop.
Convert a ratio to an array of percentages.
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 rtp(ratios) { | |
var total = 0; | |
ratios.forEach(function(ratio) { | |
total += ratio; | |
}); | |
var percentages = []; | |
ratios.forEach(function(ratio) { | |
var percentage = (ratio / total) * 100; | |
percentages.push(percentage); | |
}); | |
return percentages; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment