Skip to content

Instantly share code, notes, and snippets.

@paitonic
Created April 27, 2020 16:41
Show Gist options
  • Select an option

  • Save paitonic/a217ad6d4b12711dc01ee3c8945e8fdc to your computer and use it in GitHub Desktop.

Select an option

Save paitonic/a217ad6d4b12711dc01ee3c8945e8fdc to your computer and use it in GitHub Desktop.
doGoodEstimate.js
const GOOD_OVERALL_EFFORT_DAYS = 30;
const MAX_DAYS_PER_TASK = 4
const doGoodEstimate = (tasks) => {
let estimated = tasks.map((task) => {
task.effort = Math.floor((Math.random() * MAX_DAYS_PER_TASK) + 1);
return task;
});
const totalEffort = estimated.reduce((sum, task) => {
return sum + task.effort;
}, 0);
if (totalEffort > GOOD_OVERALL_EFFORT_DAYS) {
estimated = doGoodEstimate(estimated);
}
return estimated;
}
doGoodEstimate(tasks);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment