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