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