Advertisement
Carlos_Chaves

Untitled

Jul 20th, 2021 (edited)
1,620
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let family = {
  2.     incomes: [ 2500, 3200, 250.43, 360.45],
  3.     expenses: [ 320.34, 128.45, 176.87, 1450.00]
  4. }
  5. function sum (array){
  6.     let total = 0;
  7. for( let value of array){
  8.     return total
  9.     total += value
  10. }
  11. function calculateBance(){
  12.     const calculateExpenses = sum (family. expenses)
  13.     const calculateIcomes = sum (family. incomes)
  14.     const total = calculateIncones - calculeExpenses
  15.     const itsOk = toal >= 0
  16.     let balanceText = "negative"
  17.     if (itsOk){
  18.         balancetext =  "positive"
  19. }
  20.     console.log("Your total is $ {balancetext}: ${total.toFixed(2)}")
  21. }
  22.     calculeteBalance()
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement