Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

(javascript)Is it possible to push an object in the array located inside another object?

Is it possible to push an object in the array located inside another object? I really can’t think of ways to do it.

I am doing this project from The Odin Project. I have nowhere else to ask this question. Please kindly let me know if it’s not allowed here. thanks.

and for clarification this is not an assignment, I am not graded for this I just simply want to move forward cause I’ve been frustratingly stuck at this project for almost a month now. You don’t have to provide the answer. An article or reference on how to do it is okay and very much appreciated by me.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I want to push this

class Task {
  constructor(title, date, priority, desc) {
  this.title = title;
  this.date = date;
  this.priority = priority;
  this.desc = desc; 
  }

inside the array of the Project class

class Project {
  constructor(name) {
  this.name = name;
  this.tasks = [];
  }

>Solution :

Inside Project class add addTask(task) method. Something like:

addTask(task) {
    this.tasks.push(task);
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading