-1
In one exercise I asked to calculate the average of the notes,however at the time of showing appears a value completely out of logic
Script
function cadastrarUsuario() {
let nome = document.querySelector("#nome").value;
let nota1 = document.querySelector("#nota1").value;
let nota2 = document.querySelector("#nota2").value;
let nota3 = document.querySelector("#nota3").value;
getAprovado(nota1, nota2, nota3);
criarUsuarioTable(nome,nota1,nota2,nota3)
}
function getAprovado(nota1, nota2, nota3) {
console.log('numero um ',nota1)
console.log('numero dois ',nota2)
console.log('numero tres ',nota3)
let media = (nota1 + nota2 + nota3) / 3;
if (media >= 7) {
alert('Aprovado')
} else {
alert('Reprovado')
}
}
function criarUsuarioTable(nome,nota1,nota2,nota3){
let html = document.querySelector("#tabela");
html.innerHTML =
`
<tr>
<td>${nome}</td>
<td>${nota1}</td>
<td>${nota2}</td>
<td>${nota3}</td>
<td>${(nota1+nota2+nota3)/3}</td>
</tr>
`
}
</script>
Console
Felipe Machado Da Silva 5 9 10 1970
Both the way inside the media string template, and the variable are giving the value "crazy"
– Felipe Machado