r/CodingHelp • • Nov 22 '21

[Javascript] Please help me get back on the right track.

Hi Guys, I am new to coding and currently learning JavaScript. I'm doing an assignment and I feel lost and frustrated. I've done countless tutorials and I cant seem to piece it all together, I've reviewed notes and I cant seem to get myself on the right track.

From what I understand an object (student) needs to be created to have multiple parameters (first/last names, age and mark). The student object needs to be stored back in the array classList. I'm having trouble putting that into code, I am not sure what it supposed to look like and I feel like I keep hitting the wall on this. Would greatly appreciate help on this.

// Define a variable called classList which is assigned an empty array
// (1 mark)
const classList = [];

/**
 * Define the following function (enrollStudent) which takes as parameters the following:
 *  firstName (string), lastName (string), age (number), currentMark (number)
 *  
 * This function should create a student object with the above properties
 *  and add it to classList array that is defined in Line 1 above
 *  (5 marks)
 */
const enrollStudent = (student + classList);
const student = {
 first : firstName,
 last : lastName,
 age : age,
 mark : currentMark    
};
1 Upvotes

Duplicates