Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

95
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda