A price cell with three shapes
Distinguish a missing price from a price of zero.
your task
Keep the parameter type. Format numbers and numeric text with two decimal places, including zero. Return “no price” for null or empty text. The type check and all cases must pass.
The starter labels numeric zero “no price”. It also stops when a price arrives as text. The room table uses null or an empty string for a missing price.
Run code does two things. First the compiler checks the types and lists each error with its line. Then your code runs once for each case. A type error does not stop the run. The exercise is solved when there are no type errors and every case passes.
Starter code
or press Ctrl EnterNot run yet
type check
Not run yetprice.ts
Expected result: no type errors.
cases
Not run yetNumeric and text prices
Expected output
1
12.502
8.00See the input and the code for this case
console.log(priceLabel(12.5));
console.log(priceLabel("8"));Not run yetNull and empty text
Expected output
1
no price2
no priceSee the input and the code for this case
console.log(priceLabel(null));
console.log(priceLabel(""));Not run yetNumeric and text zero
Expected output
1
0.002
0.00See the input and the code for this case
console.log(priceLabel(0));
console.log(priceLabel("0"));