Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function accountBalance(input) {
- let transactionCount = Number(input.shift());
- let balance = 0;
- let counter = 1;
- while (transactionCount >= counter) {
- let num = Number(input.shift());
- if (num < 0) {
- console.log("Invalid operation!");
- break;
- }
- balance += num;
- console.log(`Increase: ${num.toFixed(2)}`);
- counter++;
- }
- console.log(`Total: ${balance.toFixed(2)}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment