Learn JavaScript: Objects 5/15

let day = "Friday";
let alarm;

let person = {
  name: 'Tyron',
  age: 40, 
  weekendAlarm: "No alarms needed",
  weekAlarm: "Alarm set to 7AM"


if(day === 'Saturday' || day === 'Sunday') {
    alarm = person["weekendAlarm"];
else {
  alarm = person["weekAlarm"];


My code get’s an error at step 3 “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’?”

Nevermind. I found that you can get the solution. I am not stuck anymore.


but getting the solution prevents you from learning something critical, which is trying to understand error message and attempting to solve them.


The problem was I didn’t realize the test suite wanted a string called “weekendAlarm” & “weekAlarm” instead of putting in the logical answer which is pointing to the actual person.weekendAlarm itself.

The hint doesn’t mention the answer should be a string instead of the actual object itself.


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