1
The code itself is working, as far as I’m concerned, the problem is that I’m not sure why my function is returning Undefined. It’s a simple function that’s returning what I really want, but I really don’t understand this Undefined.
Follows the code:
var nomeAluno = ["Gabriel", "Joao", "Maria", "Joaquim", "Joana"];
var np1 = [10, 9.2, 7, 0, 10];
var np2 = [7, 10, 9, 3, 9.8];
function calculaMedia(nota1, nota2){
return (nota1 + nota2) / 2;
}
function condicao(media){
if(media >= 7){
console.log("Aluno aprovado!");
}else{
console.log("Aluno reprovado");
}
}
for (i in nomeAluno){
media = calculaMedia(np1[i], np2[i]);
console.log("Aluno, " + nomeAluno[i] + ", NP1: " + np1[i] + ", NP2: " + np2[i]
+ " Média: " + media + ", Condição: " + condicao(media) +"\n");
}
console.log inside a console.log?
– Kayo Bruno