Created
December 1, 2015 19:04
-
-
Save niksudan/ef8d215c937ae7a5a484 to your computer and use it in GitHub Desktop.
Decimal calculator [JS]
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
var calculate = function(input) | |
{ | |
var result = [], sum = 0; | |
input.forEach(function(element) { | |
sum += element; | |
}); | |
input.forEach(function(element) { | |
result.push(element / sum); | |
}); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment