Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(inputArr) {
- inputArr.pop();
- let regExValidator = /%([A-Z][a-z]+)%[^|$%.]*<(\w+)>[^|$%.]*\|(\d+)\|[^|$%.0-9]*(\d+|\d+\.\d+)\$/;
- let totalIncome = 0;
- let bill = 0;
- for (let order of inputArr) {
- if (order.match(regExValidator)) {
- let [, customer, product, count, price] = order.match(regExValidator);
- bill = count * price;
- console.log(`${customer}: ${product} - ${bill.toFixed(2)}`);
- totalIncome += bill;
- }
- }
- console.log(`Total income: ${totalIncome.toFixed(2)}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement