Advertisement
bebo231312312321

Untitled

Mar 14th, 2023
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function furniturre(input){
  2. let pursche = input.splice(input.indexOf("Purchase"))
  3. let totalPrice = 0
  4. let path=/>>(?<product>[A-Za-z]+)<<(?<price>\d+(.\d+)?)!(?<quant>\d+)/g
  5. console.log('Bought furniture:')
  6. for(let element of input ){
  7.     //let text = element.shift()
  8.     let arr = element.matchAll(path);
  9. for (let el of arr){
  10.     totalPrice+= Number(el.groups.price)*Number(el.groups.quant)
  11. console.log(el.groups.product)
  12. }
  13. }
  14.  
  15. console.log(`Total money spend: ${totalPrice.toFixed(2)}`)
  16.  
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement