Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let family = {
- incomes: [ 2500, 3200, 250.43, 360.45],
- expenses: [ 320.34, 128.45, 176.87, 1450.00]
- }
- function sum (array){
- let total = 0;
- for( let value of array){
- return total
- total += value
- }
- function calculateBance(){
- const calculateExpenses = sum (family. expenses)
- const calculateIcomes = sum (family. incomes)
- const total = calculateIncones - calculeExpenses
- const itsOk = toal >= 0
- let balanceText = "negative"
- if (itsOk){
- balancetext = "positive"
- }
- console.log("Your total is $ {balancetext}: ${total.toFixed(2)}")
- }
- calculeteBalance()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement