i need to make an expense checker, and this is the requirement in javascript: In the div with the verdict id displays the message You spent too much! if the value of the expenses exceeds 20% of Jon's total income. Otherwise you will see the message Your expenses are in the parameters.
This is html code:
<div>
<div>Valoare alocatie: <input id="revenue"></div>
<div>Cheltuieli totale : <input id="expenses"></div>
<button id="check-button">Verifică</button>
<div id="verdict"></div>
</div>
how can i solve the problem ? i tried this:
let revenue=document.getElementById('revenue');
let expenses=document.getElementById('expenses');
let btn=document.getElementById('check-button');
let verdict=document.getElementById('verdict');
You could try this:
if(expenses > (20/100 * revenue)){
verdict.innerText += 'You spent too much!';
} else {
verdict.innerText += 'Your expenses are in the parameters';
}
Basically what it does is checks if the expenses are more than 20%(which can also be represented as 20/100) of revenue (* revenue) and prints out accordingly.