Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function softUniBarIncome(input) {
- input.splice(input.indexOf("end of shift"), 1)
- let totalPrice = 0
- let path = /%(?<name>[A-Z][a-z]*)%.*<(?<product>\w+)>.*?\|(?<quant>\d+)\|.*?(?<price>-?\d+([\|\$\%\.]\d+)?)\$/
- input.forEach((element, index) => {
- if ((element = path.exec(input[index])) !== null) {
- let maches = path.exec(element)
- let sum = maches.groups.quant * maches.groups.price
- totalPrice += sum
- console.log(`${maches[1]}: ${maches[2]} - ${sum.toFixed(2)}`)
- }
- });
- console.log(`Total income: ${totalPrice.toFixed(2)}`)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement