Introduction to Javascript - Objects The "this" Keyword I


I am trying to call the method sayHello() but I got the following error below

I have added the ‘this’ keyword so that it could define the variable inside the object. According to the error message this is a syntax error not reference error but I can’t see anything wrong with the syntax. Can you please advise ?

This is my code:

var day = "Monday";
let alarm; 

var person = {
  weekendAlarm: 'No alarms needed', 
  weekAlarm: 'Alarm set to 7AM',
  name: 'james', 
  sayHello: () => {
    return 'Hello, my name is
  sayGoodbye() {
  return 'Goodbye!'

person.hobbies =['music', 'martial arts'];
person.hobbies =['music']; 

if (day == 'Saturday'|| day == 'Sunday') {
  alarm = 'weekendAlarm';
} else  {
  alarm = 'weekAlarm';



Please remember to include a link to the exercise when posting a question. Thanks.

Your template string needs to in backtick quotes…

 return `Hello, my name is ${}.`

We only need one of the above lines. The second of the two may be removed.


Thank you. it works now :slight_smile:


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