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.
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 = [];
}
CodePudding user response:
Inside Project
class add addTask(task)
method. Something like:
addTask(task) {
this.tasks.push(task);
}