Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

101
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda