const student = {
name : 'Sasha',
age : 46,
surname: 'Belov',
};
const studentCS = { ...student };
studentCS.speiality = 'Computer Science';
const courses = {
Math : 10,
English: 9,
Sport : 8,
};
const permissions = {
canView : true,
canEdit : false,
canPrint: true,
};
Object.assign(studentCS, courses, permissions);
console.log(studentCS);
studentCS.average = function () {
return (this.Math + this.Sport + this.English) / 3;
};
studentCS.checkPermission = function () {
return [
this.canView,
this.canEdit,
this.canPrint,
].filter(i => i).length;
};
console.log('Score: ' + studentCS.average());
console.log('Number of enabled rights: ' + studentCS.checkPermission());