Skip to content

Instantly share code, notes, and snippets.

@neysidev
Created February 5, 2022 13:24
Show Gist options
  • Select an option

  • Save neysidev/161bede823fa3c46d6e5a345e5eb2d68 to your computer and use it in GitHub Desktop.

Select an option

Save neysidev/161bede823fa3c46d6e5a345e5eb2d68 to your computer and use it in GitHub Desktop.
/**
* Calculate percentage
*
* @param {number} percent - The percentage to be converted to a decimal
* @param {number} total - total number of items
*
* @example (50 / 100) * 300 => 150
* @returns {number} percentage value
*/
function percentage(percent: number, total: number): number {
return (percent / 100) * total
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment