I am trying to create a object using my placeholder. The current code works however it is creating array in my Children property. How can I recode so that my output is object
const placeholder = (index, isRootDirectory) => {
const create = {
id: index,
title: null,
location: index,
isRootDirectory,
padStyle: [
{
icon: null,
color: null,
},
],
UUID: null,
action: null,
Children: [],
};
return create;
};
const createLayout = () => {
let root = {
info: "Custom Layout",
Children: [],
};
for (let i = 0; i < 2; i++) {
root.Children.push(placeholder(i, true));
console.log(root);
}
console.log(root);
};
Current output:
{"Children": [{"Children": [Array], "UUID": null, "action": null, "id": 0, "isRootDirectory": true, "location": 0, "padStyle": [Array], "title": null}, {"Children": [Array], "UUID": null, "action": null, "id": 1, "isRootDirectory": true, "location": 1, "padStyle": [Array], "title": null}], "info": "Custom Layout"}
Desired output
{"Children": [{"Children": [object], "UUID": null, "action": null, "id": 0, "isRootDirectory": true, "location": 0, "padStyle": [object], "title": null}, {"Children": [object], "UUID": null, "action": null, "id": 1, "isRootDirectory": true, "location": 1, "padStyle": [object], "title": null}], "info": "Custom Layout"}