Can anyone help me please ? I'm stuck when build OOP in Javascript

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();

ok, we need to see actual task to figure out why tests are not passing

oke, should i put the task in this section or in message?

what message?
put it here in this thread

this is the task :

Task 1: Code a Person class

Code a Person class, with three parameters in the constructor: name, age, and energy.

Set the default parameters in the Person class as follows:

name = "Tom"

age = 20

energy = 100

Code two methods in the Person class. Name those methods sleep() and doSomethingFun().

The sleep() method should take the existing energy level and increase it by 10.

The doSomethingFun() method should take the existing energy level and decrease it by 10.

Task 2: Code a Worker class

Code a sub-class, inheriting from the Person class, and name it Worker.

The Worker class has two additional parameters in the constructor:

  • xp (for “experience points”)
  • hourlyWage.

These properties are set to the following default values:

xp = 0

hourlyWage = 10

The Worker class has all the paramerters and methods of its super-class.

Additionally, it has the goToWork() method, which, whenever it’s run, increases the value of the xp property by 10.

Task 3: Code a intern object

Inside the intern function instantiate the Worker class to code a new intern object.

The intern should have the following characteristics:

name: Bob

age: 21

energy: 110

xp: 0

hourlyWage: 10

Run the goToWork() method on the intern object. Then return the intern object.

Task 4: Code a manager object

Inside the manager function instantiate the Worker class to code a new manager object.

The manager object should have the following characteristics:

name: Alice

age: 30

energy: 120

xp: 100

hourlyWage: 30

Run the doSomethingFun() method on the manager object. Then return the manager object.

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=0, 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(0, 10, "Bob", 21, 110);
    return intern.goToWork();
}
intern();



// Task 4: Code a manager object, methods
function manager() {
    manager = new Worker(100, 30, "Alice", 30, 120);
    return manager.doSomethingfun();
}
manager();

ok, I think one of the issues is syntax

Your method should be

not

double-check all spelling in your code, there can be more stuff like that

like this :

// Task 3: Code an intern object, run methods
function intern() {
    intern = new Worker(0, 10, "Bob", 21, 110);
    goToWork();
}
intern();



// Task 4: Code a manager object, methods
function manager() {
    manager = new Worker(100, 30, "Alice", 30, 120);
    doSomethingfun();
}
manager();

what do you mean by this?

i’ve been change my method :

from this

doSomethingfun()

to this

doSomethingFun()

so what others issue that still wrong in my code?

Did you test it after this change?

yes, but still didn’t pass the challenge…
the output in terminal is fine but when submit my work i still get failed message 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 the output on terminal :

[Running] node “/home/coder/project/learn/ooprogramming.js”

Experience points is increasing, currently at: 10

Energy is decreasing, currently at: 110

[Done] exited with code=0 in 0.071 seconds

I am not sure about this one.
Maybe you don’t need these calls:

inside the function

Maybe they wnat you to do this stuff:

function intern() {
    intern = new Worker(0, 10, "Bob", 21, 110);
    return intern;
}

intern()

// console.log(intern)

intern.goToWork()

if i don’t call that, the output in the terminal is nothing and still didn’t pass the challenge :disappointed_relieved:

I think this is the hard challange :cold_sweat:

that’s good, right
what’s the point in easy stuff

It’s mean we can’t solve this problem?

There is nothing fancy about this problem.

Did you try stuuf I suggested above?

We are not solving it.
You are solving it, I am just giving some directions here.