Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

175
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda