I'm just learning JS callback function, in this code when I separately run seniorOrJunior method it's working just fine but when I called it through callback function It shows the following error!
let date = new Date();
let john = {
id : 0123,
name : 'Not Set',
joinYear : 2015,
category : 'Not Set',
position : 'Software Engineer',
fullname : function (firstname, lastname) {
this.name = 'firstname' + ' ' + 'lastname';
},
checkLength : function() {
date.getFullYear() - this.joinYear;
},
seniorOrJunior : function () {
if (this.checkLength() < 2) {
this.category = 'Junior';
} else {
this.category = 'Senior';
}
}
}
function salary(callback) {
callback();
if (john.category === seniorOrJunior) {
console.log('Your salary is 40k');
} else if (john.category === seniorOrJunior) {
console.log('Your Salary is 25k');
}
}
salary(john.seniorOrJunior);