Novicesyntax & basics
The Tap-Room Slate
The innkeeper of the Wet Badger chalks one line on the slate for every order that leaves the kitchen, and last night's cellar-hand chalked them all crooked. She wants a carver who can write the lines the same way every time.
Write slateLine(name, count, price).
nameis a string: the item ordered.countis a non-negative integer: how many were ordered.priceis a non-negative integer: the cost in coins of a single one.
Return a single string of the form:
NAME xCOUNT = TOTAL coins
where NAME is name exactly as given, COUNT is count, and TOTAL is count multiplied by price. The spaces and the x and the = appear exactly as shown above.
The last word is coins, except when the total is exactly 1, in which case it is coin.
examples
- case 1
name of "Barley Ale", count of 3, price of 4"Barley Ale x3 = 12 coins" - case 2
name of "Tallow Candle", count of 1, price of 1"Tallow Candle x1 = 1 coin" (the total is 1, so the word is singular) - case 3
name of "Turnip", count of 0, price of 7"Turnip x0 = 0 coins"
- reward
- 120 XP
- signature
slateLine
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
loading the editor…
- three ales
- total of one is singular
- nothing ordered
- free kindling stays plural
- one costly item
- a long order