Skip to content

Instantly share code, notes, and snippets.

@jeregrine
Last active December 17, 2015 22:09
Show Gist options
  • Save jeregrine/5679925 to your computer and use it in GitHub Desktop.
Save jeregrine/5679925 to your computer and use it in GitHub Desktop.
ESTIMATOR
function estimate(arr) {
return arr.reduce(function(prev, curr, index, array){
return prev + convertToValue(curr.toString());
}, 0);
}
function estimateRisk(arr){
return arr.reduce(function(prev, curr, index, array){
return prev + convertToRisk(curr.toString());
}, 0);
}
function convertToRisk(story){
switch(story.toLowerCase()){
case "s":
return .15;
case "m":
return .5;
case "l":
return 1;
case "xl":
return 5;
default:
return 0;
}
}
function convertToValue(story){
switch(story.toLowerCase()){
case "s":
return .5;
case "m":
return 2.5;
case "l":
return 5;
case "xl":
return 15;
default:
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment