Добрый день, помогите, пожалуйста найти ошибку и правильно вывести в консоль.
ошибка Uncaught SyntaxError: Identifier 'validDate' has already been declared
function User(name, date) {
this.name = name;
this.date = date;
}
User.prototype.getInfo = function() {
return {
name: this.name,
date: this.date
};
};
function Admin(name, date, isRootAdmin) {
User.apply(this, arguments);
this.getRootProp = function() {
return isRootAdmin;
};
}
Admin.prototype = Object.create(User.prototype);
Admin.prototype.constructor = Admin;
Admin.prototype.getInfo = function() {
const info = User.prototype.getInfo.call(this);
info.isRootAdmin = this.getRootProp();
return info;
};
function Guest(name, date, validDate) {
User.apply(this, arguments);
const validDate = new Date(
this.date.getFullYear(),
this.date.getMonth(),
this.date.getDate() + 7
);
this.getValidDate = function() {
return validDate;
};
}
Guest.prototype = Object.create(User.prototype);
Guest.prototype.constructor = Guest;
Guest.prototype.getInfo = function() {
const info = User.prototype.getInfo.call(this);
info.validDate = this.getValidDate();
return info;
};
const strainger = Guest.getInfo();
console.log(strainger);