Skip to content

Instantly share code, notes, and snippets.

@RobertFischer
Last active April 3, 2018 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobertFischer/6aa3e21cd7e15846f4e1e7d54c9fe758 to your computer and use it in GitHub Desktop.
Save RobertFischer/6aa3e21cd7e15846f4e1e7d54c9fe758 to your computer and use it in GitHub Desktop.
Task Completion Calculation
const {taskArray,completeTasks} = this.props; // These are both arrays of task ids (and nothing else)
const totalTaskSize = _.size(taskArray);
const completeTaskSize = _.size(_.intersection(taskArray, completeTasks)) // https://lodash.com/docs/4.17.5#intersection
const pctComplete = (completeTaskSize*1.0)/(totalTaskSize*1.0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment