(function(){ function Self(firstName, lastName, level){ this.firstName= firstName; this.lastName= lastName; this.level= level; this.fullName; if(level === undefined){ this.level= 0; } this.setFullName= function() { this.fullName= this.firstName + " " + this.lastName; } this.getFullName= function(){ return this.fullName; } } var status = { "stage 1": “passed”, "stage 2": “passed”, "stage 3": “passed”, "stage 4": { "self clinic": “completed”, "home sessions":{ "day 1": “completed”, "day 2": “completed”, "day 3": “completed” }, "status": "passed" } }; Self.prototype.isEvolving= function(status){ var evolving = 0; for(var key in status){ if(status[key] === 'passed' || status[key].status === 'passed) { evolving++; } } if (evolving !== 0) { return true; } else{ return false; } } Self.prototype.assert= function(){ var person= this; var name= person.getFullName(); if(person.isEvolving(status)){ console.log(name+” will be a world class developer.”); } }; var me = new Self(“Esther”, “Falayi”, 0); me.setFullName(); me.assert(); })();
// вывод: «Эстер Фалайи станет разработчиком мирового уровня».