var kids = [{}];
i = 0;
while (i++ !== count) {
child = {
value: Math.floor(Math.random() * 100),
children: addChildren(Math.floor(Math.random() * 10))
};
kids.push(child);
console.log( kids );
}
The problem with this is the kids object has an empty first element. How can I circumvent it? If I don’t declare it as a JSON object, I can’t access the push element.
Thanks
Just declare kids as an empty array: