1
What’s the simplest way to do it with array a kind of bank where I deposit a value in a array and show the same after. My difficulty is in modifying the array, where the initial value would be 0 and then as you deposit the value increases based on my logic there very simple.
var dinheiro = [];
var totalSaque;
function depositar() {
var deposito = document.getElementById("txt").value;
totalSaque = dinheiro + deposito;
document.getElementById("dep").innerHTML = "--valor depositado--";
}
function verConta() {
document.getElementById("ex").innerHTML = totalSaque;
document.getElementById("dep").innerHTML = "";
}
<!DOCTYPE html>
<html>
<head>
<title>banco</title>
</head>
<body>
<h1 style="float: left;">No Caixa:</h1><h1 id="ex" style="float: left;">0</h1>
</br></br></br></br></br>
<input id="txt" type="number">
<button onclick="depositar()">Depositar</button>
<button onclick="verConta()">ver Conta</button>
<p id="dep"></p>
</body>
</html>
Do you have to store in an array? If you don’t need to, just add the amount deposited with the amount in the account.
– GBTX
But when I press the button "see account" after having deposited for example 20 and 10 for example. appears the 10 and not 30 understood? I have some very wrong logic, but I don’t know what it is
– Marcelo T. Cortes
I will post the example without the array, if you still want with the array then put with another answer.
– GBTX
If you can post both versions, I’d really appreciate it.
– Marcelo T. Cortes