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