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

96
Views
Write a class "AntraMath" & Constructor function along with defining functions "add" , "multiply", and "done" So that the value of "res" printed is 30

Code Snippet:

let myMath = new AntraMath(10);

myMath.add(5);

myMath.multiply(2);

let res = myMath.done();

console.log(res);

Constructor Function Attempt:

function AntraMath (_value){

    let myMath = new AntraMath(10);

    myMath.add(5);

    myMath.multiply(2);

    let res = myMath.done();

    console.log(res);

}

I tried to create a Constructor function "AntraMath" & follow along with the errors given afterwards. But after setting up; I received "Output: [Done] exited with code=0" instead of receiving any error's or the desired output 30.

Thank you to who ever may be reading this along with any input given.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You will need to define a class (or prototype) and use it. Your code contains usage, but does not contain the definitions you need.

class AntraMath {

    constructor(_value) {
        this._value = _value;
    }
    
    add(_value) {
        this._value += _value;
        return this;
    }
    
    multiply(_value) {
        this._value *= _value;
        return this;
    }

    done() {
        return this._value;
    }
}

    let myMath = new AntraMath(10);

    myMath.add(5);

    myMath.multiply(2);

    let res = myMath.done();

    console.log(res);

about 4 years ago · Juan Pablo Isaza 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!