I have an array with objects and an object. I want to use the array's every value parameters as the second object values.
here is the array:
attributes = [
{key: 'Wifi', value: true},
{key: 'Parking', value: false},
{key: 'Pets', value: false},
{key: 'Restaurant', value: false},
{key: 'Bar', value: false},
{key: 'Swimming pool', value: false},
{key: 'Air conditioning', value: false},
{key: 'Gym', value: true},
]
and here is the object:
data = {
type: 'hotels',
id: '11',
attributes: {
has_wifi: false,
has_parking: false,
has_pets: false,
has_restaurant: false,
has_bar: false,
has_swimming_pool: false,
has_air_conditioning: false,
hsa_gym: false,
name: '',
main_image_src: 'https://placebear.com/300/300',
meal_plan: '',
user_id: '1',
booking_id: '1',
amount: '5000',
currency: 'HUF',
status: 'pending',
stars: ''
}
So i want to make the 'has_wifi' parameter to be equal with the 'Wifi', which is true in this case. expected output:
...has_wifi: false,
has_parking: true,
has_pets: false,
has_restaurant: false,
has_bar: false,
has_swimming_pool: false,
has_air_conditioning: false,
hsa_gym: true,...
Thanks!
I tried these:
for (let i = 0; i < 8; i++) {
this.hotelservice.hotel.data.attributes[i] = this.hotelAttributes.data.attributes[i].value;
}
this.hotelAttributes.data.attributes.forEach ((attr, index) => {
this.hotelservice.hotel.data.attributes[index] = attr.value;
})