Accessing Object Properties III 5/15


#1

Creating a topic for the first time here, so forgive me if I made any mistakes. I am getting an error message.

https://www.codecademy.com/courses/learn-javascript-objects/lessons/objects/exercises/object-property-access-iii?action=lesson_resume&course_redirect=introduction-to-javascript

I am getting this error message: " Did you write an if condition that checks if the day is Saturday, or is Sunday and if so, sets the alarm variable to ‘weekendAlarm’?"

let person = {name: 'Sachin', age: 24, weekendAlarm: 'No alarms needed', weekAlarm: 'Alarm set to 7AM'};
let day = 'Sunday';
let alarm;
if(day === 'Saturday' || day === 'Sunday')
{
  alarm = 'weekendAlarm';
} 
else
{
  alarm = 'weekAlarm';
}
//console.log(person['name']);
//console.log(person['age']);

#2

okay, the exercise seems to have trouble validating your code because you didn’t put if(day === 'Saturday' || day === 'Sunday') and { on the same line, it should be:

if(day === 'Saturday' || day === 'Sunday') {

same for else, there is nothing wrong with the way you put your curly brackets, but the exercise can’t validate it correctly for some reason


#3

Typing the if(day ==='Saturday' || day === 'Sunday') and { on the same line fixed the issue. I type it on the next line because it’s less confusing for me if I type that way, it should actually work but it’s not. Codecademy should fix this.


#4

good to hear you solved it :slight_smile:

Then you should make a bug report


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.