-
Notifications
You must be signed in to change notification settings - Fork 0
/
conta.js
26 lines (19 loc) · 719 Bytes
/
conta.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const form = document.querySelector("form")
const resp1 = document.querySelector("#outResp1")
const resp2 = document.querySelector("#outResp2")
let numContas = 0
let valTotal = 0
let resposta = ""
form.addEventListener ("submit", (e) =>{
e.preventDefault()
const descricao = form.inDescricao.value
const valor = Number(form.inValor.value)
numContas++
valTotal = valTotal + valor
resposta = resposta + descricao + " - R$: " + valor.toFixed(2) + "\n"
resp1.innerText = `${resposta}-------------------------------`
resp2.innerText = `${numContas} Conta(s) - Total R$: ${valTotal.toFixed(2)}`
form.inDescricao.value = ""
form.inValor.value = ""
form.inDescricao.focus()
})