stevemcilwaine
6/4/2019 - 10:22 AM

Percentage string calculation and creator

Takes an amount and a total and calculates the percentage. It then returns a string with the percentage and "%".

/**
 * Calculate percentage and returns as string
 * @param {number} amount - amount count
 * @param {number} total - max total
 * @return {string} - returns templated string percentage with '%'
 */
const percentageMath = (amount, total) => {
  return `${Math.round((amount / total) * 100)}%`;
}