-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
26 lines (26 loc) · 848 Bytes
/
script.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
document.getElementById("nome").focus();
function calcula() {
let nome = document.getElementById("nome").value;
let trab = parseFloat(document.getElementById("trab").value);
let teste = parseFloat(document.getElementById("teste").value);
let media = (trab + teste) / 2;
let res = nome + " oteve média: " + media;
document.getElementById("res").value = res;
}
function cl() {
document.getElementById("nome").value = "";
document.getElementById("trab").value = "";
document.getElementById("teste").value = "";
document.getElementById("res").value = "";
document.getElementById("nome").focus();
}
document.addEventListener("keydown", event => {
if (event.keyCode == 27) {
cl();
}
})
document.addEventListener("keydown", event => {
if (event.keyCode == 13) {
calcula();
}
})