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