Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function furniturre(input){
- let pursche = input.splice(input.indexOf("Purchase"))
- let totalPrice = 0
- let path=/>>(?<product>[A-Za-z]+)<<(?<price>\d+(.\d+)?)!(?<quant>\d+)/g
- console.log('Bought furniture:')
- for(let element of input ){
- //let text = element.shift()
- let arr = element.matchAll(path);
- for (let el of arr){
- totalPrice+= Number(el.groups.price)*Number(el.groups.quant)
- console.log(el.groups.product)
- }
- }
- console.log(`Total money spend: ${totalPrice.toFixed(2)}`)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement