From b3250363e52d58c9cb1f4374dbd47c56c681de7c Mon Sep 17 00:00:00 2001 From: Leander Furumo Date: Sat, 31 Oct 2026 01:15:00 +0100 Subject: [PATCH] don't display rounded number of liters and use norwegian number formatting --- src/components/calculator.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/calculator.tsx b/src/components/calculator.tsx index c657d2d..79e28c1 100644 --- a/src/components/calculator.tsx +++ b/src/components/calculator.tsx @@ -5,8 +5,10 @@ const MAX_PEOPLE = 3000; const BOTTLE_CENTILITERS = 150; const SLICES_PER_PIZZA = 8; +const formatNumber = (value: number) => value.toLocaleString("nb-NO"); + const calculateLiters = (people: number, thirstiness: number) => { - return Math.ceil((people * thirstiness) / 100); + return Math.ceil((people * thirstiness) / 10) / 10; }; const calculateBottles = (people: number, thirstiness: number) => { @@ -76,14 +78,14 @@ const Calculator = () => {

- {calculateLiters(people, thirstiness)} + {formatNumber(calculateLiters(people, thirstiness))} {" "} liter

eller

- {calculateBottles(people, thirstiness)} + {formatNumber(calculateBottles(people, thirstiness))} {" "} flasker (1,5L)

@@ -91,14 +93,14 @@ const Calculator = () => {

- {calculatePizzaSlices(people, hungriness)} + {formatNumber(calculatePizzaSlices(people, hungriness))} {" "} pizzastykker

eller

- {calculatePizzas(people, hungriness)} + {formatNumber(calculatePizzas(people, hungriness))} {" "} store pizzaer