index.js 719 B

123456789101112131415161718192021222324
  1. import requiredArgs from "../_lib/requiredArgs/index.js";
  2. import { monthsInQuarter } from "../constants/index.js";
  3. /**
  4. * @name quartersToMonths
  5. * @category Conversion Helpers
  6. * @summary Convert number of quarters to months.
  7. *
  8. * @description
  9. * Convert a number of quarters to a full number of months.
  10. *
  11. * @param {number} quarters - number of quarters to be converted
  12. *
  13. * @returns {number} the number of quarters converted in months
  14. * @throws {TypeError} 1 argument required
  15. *
  16. * @example
  17. * // Convert 2 quarters to months
  18. * const result = quartersToMonths(2)
  19. * //=> 6
  20. */
  21. export default function quartersToMonths(quarters) {
  22. requiredArgs(1, arguments);
  23. return Math.floor(quarters * monthsInQuarter);
  24. }