OBJECTS The this Keyword I undefined problem


I need help with this specific area in my code , its loging this is my name undefined, i dont get why, what am i doing wrong? the rest of the code i understand

sayHello: ()=> {
return this is my name ${this.name}

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

sayHello: ()=> {
return this is my name ${this.name}

sayGoodbye () {
return ‘Goodbye!’


person.hobbies = [‘Basketball’, ‘Coaching’];
person.hobbies = [‘Basketball’];


let day = ‘Tuesday’;
let alarm;

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


8.15 - The This Keyword! (Yes ... another one!)

The author wants us to see that the above will not work. Arrow functions do not have a this object like ordinary functions and methods do.

sayHello () {
    return `this is my name, ${this.name}`;


Thanks man, the arrow function was the issue, i changed it and the code is displaying the name. I appreciate it


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