Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

174
Visualizações
Error in my task 4, it seems that .checked and .value doesn't seem to work as intended

Link to Scrimba to check on code : https://scrimba.com/scrim/czvrQJcM

Essentially what should happen is that when the details are added and the button is clicked, the data first gets saved into the object, 'student' and pushed into the array. Then the array is run and the students names are displayed on the page.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I just solve your problem. Look: At your enrolStudent() function you set the following line:

    studentList = studentList.push(student);

So, you should change it to:

    studentList.push(student);

This is because the push() method returns the length of the array. So, you don't need to attribute the operation result to the array. The method already updated its own value.

Task4 after the change:

    function enrolStudent()
    {
        let firstnameRef = document.getElementById("fname");
        let lastnameRef = document.getElementById("lname");
        let studentIdRef = document.getElementById("studentid");
        let dateRef = document.getElementById("date");
        let courseRef = document.getElementById("course");
        let genderRef = document.getElementsByName("gender");
        for (let i=0; i < genderRef.length; i++)
        {
            if (genderRef[i].checked)
            {
                var genderSelection = genderRef[i];
            }
        }
        let student = new Object();
        student.firstName = firstnameRef.value;
        student.lastName = lastnameRef.value;
        student.id = studentIdRef.value;
        student.course = studentIdRef.value;
        student.gender = genderSelection.value;
        student.date = dateRef.value;
        studentList.push(student);
        var val = studentList.push(student);
        studentEnrolSummaryRef.innerHTML = displayStudents(studentList);
        console.log(val);
    }

```
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda