Hi,
I’m wondering if you can help me understand this please.
The solution is:
let person = {
name: ‘John’,
age: 53,
weekendAlarm: ‘No alarms needed’,
weekAlarm: ‘Alarm set to 7AM’
};let day = ‘Wednesday’
let alarm;
if (day === ‘Saturday’ || day === ‘Sunday’) {
alarm = ‘weekendAlarm’;
} else {
alarm = ‘weekAlarm’;
}
But in my mind it should be:
let person = {
name: ‘John’,
age: 53,
weekendAlarm: ‘No alarms needed’,
weekAlarm: ‘Alarm set to 7AM’
};let day = ‘Wednesday’
let alarm;
if (day === ‘Saturday’ || day === ‘Sunday’) {
alarm = person.weekendAlarm;
} else {
alarm = person.weekAlarm;
}
Why do we not have to reference the object before the key?
Thanks,