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