Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function problem(input) {
- input.shift()
- let totalSum = 0;
- let counter = 0;
- for (let i = 0; i < input.length; i++) {
- counter++
- let sum = 0;
- let money = input.splice(0, 3)
- if (counter % 3 === 0) {
- sum = money[2] + money[2] * 0.50
- sum = money[1] - sum
- } else if (counter % 5 === 0) {
- sum = money[1] * 0.90 - money[2]
- } else {
- sum = money[1] - money[2]
- }
- totalSum += sum
- console.log(`In ${money[0]} Burger Bus earned ${sum.toFixed(2)} leva.`)
- i -= 1
- }
- console.log(`Burger Bus total profit: ${totalSum.toFixed(2)} leva.`)
- }
Add Comment
Please, Sign In to add comment