{"size": 870, "ext": "js", "max_stars_repo_path": "src/common/calculations/getTotalDailyAmount.js", "max_stars_repo_name": "thelifenadine/food-motivated", "max_stars_repo_stars_event_min_datetime": "2021-08-14T15:21:29.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-14T15:21:29.000Z", "max_issues_repo_path": "src/common/calculations/getTotalDailyAmount.js", "max_issues_repo_name": "thelifenadine/food-motivated", "max_issues_repo_issues_event_min_datetime": "2021-01-14T22:41:49.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-15T02:59:23.000Z", "max_forks_repo_path": "src/common/calculations/getTotalDailyAmount.js", "max_forks_repo_name": "thelifenadine/food-motivated", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 9, "max_forks_count": null, "avg_line_length": 39.5454545455, "max_line_length": 90, "alphanum_fraction": 0.7620689655}
import toPercent from './toPercent';

/*
  The weight of the dog, is passed in as either pounds or kilograms.

  The weight is multiplied by it's smaller unit amount, for example 16 (16 oz per lb) to
  get the amount that the dog weights in ounces (or 1000 for grams).

  The maintenance amount to be fed to the dog is passed in as an integer (2, for example)
  and divided by 100 to get it's percentage: 0.02

  The total amount to be fed (per day) is then calculated by multiplying the weight of the
  dog by the calculated percentage to feed and returned in ounces or grams.
*/
const getTotalDailyAmount = (weight, maintenancePercentage, unitAmount = 16) => {
  const weightByUnit = weight * unitAmount;
  const totalAmountInOuncesOrGrams = weightByUnit * toPercent(maintenancePercentage);
  return totalAmountInOuncesOrGrams;
};

export default getTotalDailyAmount;
