0
My intention is to make the famous algorithm of school grades to calculate the average student, which is usually done with arrays, but I want to know if it is also possible with use of objects, my attempt was this, but I’m getting Undefined as a result:
var alunos = []
var media = 0;
var soma = 0;
for (let i = 0; i <= 3; i++) {
    const aluno = {
        name: prompt('NOME: '),
        nota1: Number(prompt('NOTA 1:')),
        nota2: Number(prompt('NOTA 2:')),
        nota3: Number(prompt('NOTA 3:')),
        nota4: Number(prompt('NOTA 4:'))
    }
    alunos.push(aluno);
    soma += aluno.nota1.nota2.nota3.nota4
    media = soma / alunos.length;
    console.log(media);
    // zerando os dados para realizar o cálculo dos próximos alunos
    media = 0;
    soma = 0;
}If the question is not clear, the objective of the algorithm is to receive the student’s name, his 4 grades and after that calculate his average.
Take a look at object breakdown, it will help a lot.
– Pedro Henrique