По заданию мне нужно написать функцию hireNewEmployee, которая будет принимать в параметры объект employee и возвращать 'You're Hired! Congrats!' или 'No hired: sorry we cannot hire you. Here is why: ', reason). Где у reason будет массив свойств по которым не подошел работник.
К примеру:
ограничение в возрасте – не моложе 25 лет на эту должность
образование: высшее
прошлый опыт: минимум 1 год.
Примечание: создавать объект employee через defineProperty с указанием дескрипторов.
Пробовал решить, код не работает, в консоль выдает ошибку.
const employee = {};
const reason = [
{
age: 25,
education: 'higher',
experience: 1
}
]
Object.defineProperties(employee, {
name: {
value: 'Dmitriy',
writable: false,
configurable: false,
enumerable: false
},
age: {
value: 21,
writable: true,
enumerable: true,
configurable: true
},
education: {
value: 'higher',
writable: true,
enumerable: true,
configurable: true
},
experience: {
value: 0,
writable: true,
enumerable: true,
configurable: true
}
})
function hireNewEmployee (objectEmployee,objectReason) {
for (let key in objectEmployee) {
if (objectEmployee.key['age'] >= objectReason.key['education']
&& objectEmployee.key['education'] === objectReason.key['education']
&& objectEmployee.key['experience'] >= 1) {
return console.log('You are Hired! Congrats!');
}
}
return console.log(`Not hired: sorry we cannot hire you. Here is why: ${objectReason}`);
}
hireNewEmployee(employee,reason);