I am looking for a way to incorporate values from an Object (weekdayMap) into an existing array (vehicleAvailabilities) that contains objects. I require the value Montag on day one and Dienstag on day two.
This pattern continues for each day of the week.
The desired result should be:
const result = [
{id: 1, day: "1", value: true, weekday: 'Montag'},
{id: 2, day: "2", value: true, weekday: 'Dienstag'} ...
based on these arrays:
const vehicleAvailabilities = [
{id: 1, day: "1", value: true},
{id: 2, day: "2", value: true},
{id: 3, day: "3", value: true},
{id: 4, day: "4", value: true},
{id: 5, day: "5", value: true},
{id: 6, day: "6", value: false},
{id: 7, day: "7", value: false}
]
const weekdayMap = {
1: 'Montag',
2: 'Dienstag',
3: 'Mittwoch',
4: 'Donnerstag',
5: 'Freitag',
6: 'Samstag',
7: 'Sonntag'
}