Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let pattern = /(?<custm>\%[A-Z][a-z]+\%).*(?<prod>\<\w+\>).*(?<count>\|\d+\|).*(?<price>\d+\$|\d+[\.]\d+\$)/g;
- let i = 0;
- let arr = [];
- while (input[i] !== 'end of shift') {
- if ((customer = pattern.exec(input[i]) !== null) {
- console.log(customer[0]);
- }
- i++;
- }
- // console.log(`{customerName}: {product} - {totalPrice}`);
- // console.log(`Total income: {income}`);
- }
- solve(
- ['%George%<Croissant>|2|10.3$',
- '%Peter%<Gum>|1|1.3$',
- '%Maria%<Cola>|1|2.4$',
- 'end of shift']
- );
Advertisement
Add Comment
Please, Sign In to add comment