krustev_84

Untitled

Mar 9th, 2020
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. function accountBalance(argument) {
  2. let transactions = Number(argument.shift());
  3. let balance = 0;
  4. let counter = 0;
  5.  
  6. while (transactions >= counter) {
  7. let num = Number(argument.shift());
  8. if (num < 0) {
  9. console.log(`Invalid operation!`);
  10. break;
  11. }
  12. balance += num;
  13. console.log(`Increase: ${num.toFixed(2)}`);
  14. }
  15. console.log("Total: " + balance.toFixed(2));
  16.  
  17. }
  18. accountBalance([5, 120, 45.55, -150]);
Advertisement
Add Comment
Please, Sign In to add comment