Beginner
Split the bill to the paisa
Three friends share a ₹1000 dinner. Split it so the shares are whole paise, differ by at most one paisa, and add up exactly to the total.
Write three functions: toPaise(rupees) turns a rupee amount into whole paise; splitBill(totalRupees, people) returns an array of shares in paise; formatINR(paise) returns the amount formatted for India, like ₹12,34,567.89.
The page code already lists each share in #shares.
What Check tests
toPaise(4.35)is exactly 435- ₹100 for 3 adds up to 10000 paise, with shares at most 1 apart
- ₹0.30 for 3 is 10 paise each
formatINR(123456789)gives₹12,34,567.89- The page lists ₹333.34, ₹333.33 and ₹333.33
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Your page
Press Run to see the page.
Console
Nothing logged yet.