Question
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?
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started