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

146
Views
JavaScript- making lists and more

Given the following assignment:

In JavaScript, you want to manage a list of exam registrations. To do this, it is necessary to create the Enrollment function, which acts as a constructor of the Objects of type Enrollment: these objects are characterized by a code, the date, the name of the teaching, the student's serial number from the date of the appeal. In addition, the PDP practice number (if the student has a recognized PDP) can be specified for an enrollment. Then create the SubscriptionList function, which acts as a constructor of objects that manage collections of inscriptions. A collection provides the following methods: addSubscription (which receives the Subscription object to be inserted), get (which receives the subscription code to be returned), and drop (which receives the subscription code to be deleted from the collection). This is what I have done for the first part:

function Inscription(code, date, subject, studentId, dateOfExam)

this.code= code;
this.date= date; 
this.subject = subject;
this.studentId = studentId;
this.dateOfExam = dateOfExam;

var MyList = new Array(); 
my.Inscription(new inscription( "W123", "010722", "JavaScript", "8410" , "010722"));

not sure about the rest thanks in advance

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You started good, although the code you provided doesn't compile. let's fix that:

// added PDP
function Inscription(code, date, subject, studentId, dateOfExam, PDP) {
  this.code = code;
  this.date = date;
  this.subject = subject;
  this.studentId = studentId;
  this.dateOfExam = dateOfExam;
  this.PDP = PDP;
}

// var MyList = new Array();
// my.Inscription(new inscription("W123", "010722", "JavaScript", "8410", "010722"));
// this makes more sense: (note lower case upper case)
var inscription = new Inscription("W123", "010722", "JavaScript", "8410", "010722");
// anoher one:
var other_inscription = new Inscription("W124", "010722", "JavaScript 2", "8411", "010722");
// btw - why didn't you call it Enrollment?

// ok next is the SubscriptionList function 
function SubscriptionList() {
  var private_arr = []; // !

  // has the following methods:
  this.addSubscription = function(subscription) {
    private_arr.push(subscription);
  }

  this.get = function(subscription_code) {
    // ...
  }

  this.drop = function(subscription_code) {
    // ...
  }

  // let's add one more!
  this.toString = function() {
    return JSON.stringify(private_arr, null, 4)
  }
}

// new you can
var subscriptionList = new SubscriptionList();
subscriptionList.addSubscription(inscription);
subscriptionList.addSubscription(other_inscription);
subscriptionList.drop("W123");

console.log(subscriptionList.toString())
// good luck.
.as-console-wrapper {
  max-height: 100% !important;
}

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!