cart = {
"Items": 3,
"Item": {
"Apple iPhone 5S": {
"productId": 688,
"url": "http://website.com/phone_iphone5s.html",
"price": 299.99
},
"Solio Mono Solar Charger": {
"productId": 655,
"url": "http://website.com/solio_charger.html",
"price": 29.95
},
"24 Month Warranty Package": {
"productId": 681,
"url": "http://website.com/24_month_warranty.html",
"price": 129.95
}
},
"Total": 459.89
}
我想编写一个JavaScript函数,在浏览器开发工具控制台中输出商品总数、每个商品的价格以及购物车的总值。例如:需要选择Apple Iphone 5S 及其价格、Solio Mono Solar Charger 及其价格等。不使用硬编码键(例如“Apple iPhone 5S”、“Solio Mono Solar Charger”)。有什么办法吗??
有可能获得这种格式吗?
Items: 3
- Apple iPhone 5S ($299.99)
- Solio Mono Solar Charger ($29.95)
- 24 Month Warranty Package ($129.95)
Total: 459.89