I’m doing some challenge to build OOP in Javascript right now, when i ran the output in terminal is fine, but i still didn’t pass the challange and it said in the result like this :
Failed: Intern instance - returned: ,TypeError, but expected 10,10,Bob,21,110 Failed: Manager instance - returned: ,TypeError, but expected 100,30,Alice,30,110
I’m doing some challenge to build OOP in Javascript right now, when i ran the output in terminal is fine, but i still didn’t pass the challange and it said in the result like this :
Failed: Intern instance - returned: ,TypeError, but expected 10,10,Bob,21,110 Failed: Manager instance - returned: ,TypeError, but expected 100,30,Alice,30,110
this is my code :
// Task 1: Code a Person class
class Person {
constructor(name ="Tom", age =20, energy = 100) {
this.name = name;
this.age = age;
this.energy = energy;
}
sleep() {
this.energy += 10;
console.log('Energy is increasing, currently at:', this.energy)
}
doSomethingfun() {
this.energy -= 10;
console.log('Energy is decreasing, currently at:', this.energy)
}
}
// Task 2: Code a Worker class
class Worker extends Person{
constructor(xp, hourlyWage = 10, name, age, energy,) {
super(name, age, energy);
this.xp = xp;
this.hourlyWage = hourlyWage;
}
goToWork() {
this.xp += 10;
console.log('Experience points is increasing, currently at:', this.xp)
}
}
// Task 3: Code an intern object, run methods
function intern() {
intern = new Worker("", "10", "Bob", "21", "110");
intern.goToWork();
}
intern();
// Task 4: Code a manager object, methods
function manager() {
manager = new Worker("100", "30", "Alice", "30", "120");
return manager.doSomethingfun();
}
manager();