Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am trying to make it so that when a transaction/expense is added the balance cant go below $0 How could I do that? import

I am trying to make it so that when a transaction/expense is added the balance cant go below $0 How could I do that?

image text in transcribed

import './index.css'

import {Header} from './Header'

import {Income} from './Income'

import {History} from './History'

import {New} from './New'

function clearField(e) {

document.getElementById('form').reset();

}

var transactionValue = 0.0;

var finalValue = 0.0;

var finalBalance = 0.0;

function addTransaction(e) {

e.preventDefault();

if (document.getElementById('amount').value > 0) {

var income = document.getElementById('moneyi');

transactionValue = parseFloat(document.getElementById('amount').value);

finalValue = parseFloat(income.innerHTML);

finalValue = finalValue + transactionValue;

finalValue = finalValue.toFixed(2)

document.getElementById('moneyi').innerHTML = finalValue;

}

if (document.getElementById('amount').value

var expense = document.getElementById('moneye');

transactionValue = parseFloat(document.getElementById('amount').value);

finalValue = parseFloat(expense.innerHTML);

finalValue = finalValue + transactionValue;

finalValue = finalValue.toFixed(2)

document.getElementById('moneye').innerHTML = finalValue;

}

var balance = document.getElementById('balance');

finalBalance = parseFloat(balance.innerHTML);

finalBalance = finalBalance + transactionValue;

finalBalance = finalBalance.toFixed(2);

document.getElementById('balance').innerHTML = finalBalance;

transactionValue = 0.0;

}

function App() {

return (

)

}

export default App;

Expense Tracker

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions