slanted-gamedev-toolz
Version:
A slanted mix of tools for your brilliant ideas in game design.
13 lines (12 loc) • 500 B
JavaScript
export function addPluralToUntilType(value, unit) {
function numberWithCommas(inputMoney, showNegatives = false) {
if (inputMoney < 0 && !showNegatives) {
return (inputMoney * -1).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
return inputMoney.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
return `${numberWithCommas(value)} ${unit}${value !== 1 ? "s" : ""}`;
}
export function addPluralS(value) {
return `${value !== 1 ? "s" : ""}`;
}