Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(args) {
- let income = 0;
- args.forEach((str) => {
- if (str !== 'end of shift') {
- const newRe = /%([A-Z][a-z]+)%[^|$%.]*<(\w+)>[^|$%.]*\|(\d+)\|[^|$%.]*?([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\$/gm.exec(str);
- if (newRe !== null) {
- const [, customerName, product, count, price] = newRe;
- const totalPrice = Number(count) * Number(price);
- income += totalPrice;
- console.log(`${customerName}: ${product} - ${totalPrice.toFixed(2)}`);
- }
- }
- });
- console.log(`Total income: ${income.toFixed(2)}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement