POS收银机 版本:v0.2
- 学会把基本描述转换成程序;
- 能够驾驭三个循环;
商店里进行购物结算时会使用收银机(POS)系统,这台收银机会在结算时根据客户的购物车(Cart)中的商品(Item)进行结算和打印收据(Receipt)。
我们需要实现一个名为printReceipt
函数,该函数能够将指定格式的数据作为参数输入,然后在浏览器的控制台中输出收据的文本。
输入格式(样例):
[
'ITEM000000',
'ITEM000000',
'ITEM000000',
'ITEM000000',
'ITEM000000',
'ITEM000001',
'ITEM000001',
'ITEM000004'
]
清单内容(样例):
***<没钱赚商店>收据***
名称:可口可乐,数量:5瓶,单价:3.00(元),小计:15.00(元)
名称:雪碧,数量:2瓶,单价:3.00(元),小计:6.00(元)
名称:电池,数量:1个,单价:2.00(元),小计:2.00(元)
----------------------
总计:23.00(元)
**********************
- 根据
test/main-test.js
中的测试用例,在main/main.js
文件中编写实现代码并确保测试通过; - 请在保证代码可读性的前提下,尽可能用最少的代码行数完成作业;
- 运行文件下面的
run.html
文,使测试通过
- 学会遍历查找内容