function weight(money) { const baseValue = money * 1000 // to get to gramms (1/1000 Stone) const stone = Math.floor(baseValue / 1000) const remainder = baseValue - (stone * 1000) const ounces = remainder / 25 let stoneRepresentation = '' let ouncesRepresentation = '' return { stone: stoneRepresentation, ounces: ouncesRepresentation, } } function registerHelper(hbs) { hbs?.registerHelper('weight', (data) => { let template = `` const {stone, ounces} = weight(data) if (stone > 0) { template += `${stone}` } if (ounces > 0) { template += `${ounces}` } template += `` return new Handlebars.SafeString(template) }) } export { weight, registerHelper }