Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!