let DaysArray: any = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]
I am looking to transform the above array into an Object structure as shown below:
let DaysObject: any = {
time: {
headerName: ""
},
monday: {
headerName: "Monday"
},
tuesday: {
headerName: "Tuesday"
},
wednesday: {
headerName: "Wednesday"
},
thursday: {
headerName: "Thursday"
},
friday: {
headerName: "Friday"
},
saturday: {
headerName: "Saturday"
},
sunday: {
headerName: "Sunday"
}
};
Can anyone help me with writing a for loop in JavaScript to achieve this transformation? I appreciate any assistance, thank you!