I'm, trying to use the getFullYear as a parameter in a object but when I return it I get the full date, not only the year.
let person = {
firstName: '',
lastName: '',
nationality: '',
born: '',
print3: function() {
return 'My name is ' + this.firstName + ' ' + this.lastName + ' from ' + this.nationality + '.' + ' I was born ' + born + '.';
},
init: function(firstName, lastName, nationality, born) {
this.firstName = firstName;
this.lastName = lastName;
this.nationality = nationality;
this.born = born;
}
};
let born = new Date('1643-01-04');
let year = born.getFullYear();
// console.log(born.getFullYear());
person.init('Isaac', 'Newston', 'England', year)
ANSWER = person.print3();
The problem I have is that I only want the full year in the answer but I get the full date with day and time and everything. And when I console.log the variable I get on the full year.
Expected output: "My name is Isaac Newston from England. I was born 1643 ."
Real output: "My name is Isaac Newston from England. I was born Sun Jan 04 1643 01:12:12 GMT+0112 (centraleuropeisk normaltid)."
Any ideas?
Regards
Comments
Post a Comment