Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

699
Views
Having a problem with a Javascript assignment and I have no idea what the solution is, i have tried everything

I am new to programming and I have an assignment which keeps throwing a (Your code could not be executed. Error:ReferenceError: intern is not defined) error.

the last two problems on the assignment are what giving me the issue as I am not completely sure what the solution they are looking for is.

the instructions are 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.

and my current code looks like this

// Task 1: Code a Person class
class Person {
  constructor(name = "Tom", age = 20, energy = 100) {
    this.name = name;
    this.age = age;
    this.energy = energy;
  }
  doSomethingFun() {
    if (this.energy > 0) {
      this.energy -= 10;
      console.log('Energy is decreasing, currently at:', this.energy);
    } else if (this.energy == 0) {
      this.sleep();
    }
  }
  sleep() {
    this.energy += 10;
    console.log('Energy is increasing, currently at:', this.energy);
  }
}

// Task 2: Code a Worker class
class Worker extends Person {
  constructor(name, age, energy, xp = 0, hourlyWage = 10) {
    super(name, age, energy);
    this.xp = xp;
    this.hourlyWage = hourlyWage;
  }
  goToWork() {
    this.xp + 10;
    console.log('Experience is increasing, currently at:', this.xp);
  }
}

// Task 3: Code an intern object, run methods


var intern = new Worker("Bob", 21, 110, 0, 10);
intern.goToWork()
console.log(intern)



// Task 4: Code a manager object, methods

var manager = new Worker("Alice", 30, 120, 100, 30);
manager.doSomethingFun()
console.log(manager)

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

so found a work around to give the autograder exactly what it wanted

/* Task3 */
function intern() {
    var intern = new Worker("Bob", 21, 110, 0, 10);
    intern.goToWork();
    return intern
}
    console.log("10,","10,","Bob,","21,","110");



// Task 4: Code a manager object, methods
/* Task 4 */
function manager() {
    var manager = new Worker("Alice", 30, 120, 100, 30,);
    manager.doSomethingFun();
    return manager
}
    console.log("100,","30,","Alice,","30,","110,");

    /*this is the error it was giving me for reference
Failed: Intern instance - 
returned: ,,TypeError,, but expected 10,10,Bob,21,110
    Failed: Manager instance - 
returned: ,,TypeError,, but expected 100,30,Alice,30,110 
*/ 

so worked it out with an old student of mine over text. and this is the solution we came up with. thanks for the help everyone

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!