I need to create new objects in an object with a function. It should work this way: I need to collect some data into a big object that consists of some smaller objects that I should create using a function. It works this way: a user gets a created by my function object, fills it and then this object is pushed to the big object. The problem is I don't totally understand how to create a new object every time because my code just changes data in one object. The creation of the new function should happens only when it's required by a user.
My code:
let ger_tasks = {}
let name = 1;
let descr = 2;
let timing = 3;
function newTask(name,descr,timing) {
this.name = name;
this.descr = descr;
this.timing = timing;
name = {
description:descr,
timings:timing,
}
ger_tasks.name = name;
}
newTask('a','b','c')
newTask('0','1','2')
console.log(ger_tasks)
Thanks in advance!
a user gets aand missed the word . i just run your code . do you mean you want to append the object ?