Accessing Object Properties III One advantage that bracket notation has over dot notation is that you can use variables inside the brackets to select the keys of an object.
let day = 'Wednesday';
let alarm;
let person = {
name: 'Tyron',
weekendAlarm: 'No alarms needed',
weekAlarm: 'Alarm set to 7AM',
age: 40
};
if(day === 'Saturday'|| day === 'Sunday'){
alarm = 'weekendAlarm';
}else{
alarm = 'weekAlarm';
}
console.log(person['name']);
console.log(person['age']);
console.log(person[alarm]);