const filters = {
age: (a) => a >= 25,
education: (a) => a === 'higher',
experience:(a) => a >= 1,
};
const employee = {};
const defaultDescriptors = {
writable: true,
enumerable: true,
configurable: true
};
Object.defineProperties(employee, {
name: {
...defaultDescriptors,
value: 'Dmitriy',
writable: false
},
age: {
...defaultDescriptors,
value: 21
},
education: {
...defaultDescriptors,
value: 'middle'
},
experience: {
...defaultDescriptors,
value: 0
}
})
function hireNewEmployee (employee,filters) {
const reasons = [];
Object.entries(filters).forEach(([name,func]) => {
if (func(employee[name]) === false) {
function lieToEmployer (employee) {
return Object.defineProperties(employee, {
age: {
value: 27
},
education: {
value: 'higher'
},
experience: {
value: 7
}
});
}
lieToEmployer(employee);
reasons.push(name);
}
});
return reasons.length
? `Not hired: sorry we cannot hire you. Here is why: ${reasons.join(', ')}`
: 'You are Hired! Congrats!';
}
console.log(hireNewEmployee(employee,filters));
const filters = {
// age: function (a) {
// return a) => a >= 25,
// }
age: (a) => a >= 25,
education: (a) => a === 'higher',
experience:(a) => a >= 1,
}
const employee = {};
const defaultDescriptors = {
writable: true,
enumerable: true,
configurable: true
}
Object.defineProperties(employee, {
name: {
...defaultDescriptors,
value: 'Dmitriy',
writable: false
},
age: {
...defaultDescriptors,
value: 21
},
education: {
...defaultDescriptors,
value: 'higher'
},
experience: {
...defaultDescriptors,
value: 0
}
})
function hireNewEmployee (employee,filters) {
const reasons = [];
Object.entries(filters).forEach(([name,func]) => {
if (func(employee[name]) === false) {
reasons.push(name);
}
})
return reasons.length
? `Not hired: sorry we cannot hire you. Here is why: ${reasons.join(', ')}`
: 'You are Hired! Congrats!';
}
console.log(hireNewEmployee(employee,filters));
const filters = {
age: function (element) {
return element >= 25;
},
education: function (element) {
return element === 'higher'
},
experience: function (element) {
return element >= 1
}
}
if ( filters.age() === false
|| filters.education() === false
|| filters.experience() === false) {
errors.push(name);
}
function hireNewEmployee (objectEmployee,arrayReason) {
if (objectEmployee['age'] >= arrayReason['age']
&& objectEmployee['education'] === arrayReason['education']
&& objectEmployee['experience'] >= arrayReason['experience']) {
return console.log('You are Hired! Congrats!');
}
return console.log(`Not hired: sorry we cannot hire you. Here is why: ${arrayReason}`);
}
hireNewEmployee(employee,reason);