Check every price
A price check must report when there are no prices to check.
your task
For each price of 0 or less, print “bad price: ” followed by the price. Finish with the count, as in “checked 3 prices”. For an empty list, print only “fail: no prices to check”.
The price report ends with just “checked”, even when the list is empty. A reader cannot tell how many prices the test checked.
Run code runs your code once for each case. It compares what your code prints with the expected output.
Starter code
or press Ctrl EnterNot run yet
cases
Not run yetOne price is zero
Expected output
1
bad price: 02
checked 3 pricesSee the input and the code for this case
const prices = [40, 0, 25];
Not run yetAll prices are positive
Expected output
1
checked 2 pricesSee the input and the code for this case
const prices = [40, 25];
Not run yetThe price list is empty
Expected output
1
fail: no prices to checkSee the input and the code for this case
const prices = [];