I am a beginner to JavaScript. i want to create a common key for some values in JavaScript object. For example, in the below code we have a employee name with some tasks assigned to them, so i have created the tasks as nested object. Now i feel that this is looking like a basic level code. is there any way to achieve this effectively?. Also i want to know how to retrieve nested object's value in function.
const taskInfo = [
{
name: "john",
mail: "mailid",
task1: { taskname: "name", priority: 2, groupname: "name" },
task2: { taskname: "name", priority: 2, groupname: "name" },
task3: { taskname: "name", priority: 2, groupname: "name" }
},
{
name: "smith",
mail: "mailid",
task1: { taskname: "name", priority: 2, groupname: "name" },
task2: { taskname: "name", priority: 2, groupname: "name" }
}
];