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

193
Visualizações
How to set value in object constructor?

I have problem with my script.

Why my constructor of this object do not know that value of wynik1 is changing and always return "this.A" instead of changing it?

var wynik1 = (liczba1 / liczba2) * profil;

function potatos(name, moc, square, A, B, C, D, price) {
  this.name = name;
  this.moc = moc;
  this.square = square;
  this.A = A;
  this.B = B;
  this.C = C;
  this.D = D;
  this.price = function() {
    if (wynik1 < 18000) {
      return this.A;
    }
    if (wynik1 < 10000) {
      return this.B;
    }
    if (wynik1 < 5000) {
      return this.C;
    }
    if (wynik1 < 3000) {
      return this.D;
    }
  };
}

const animus = new potatos('nameone', 370, 1.7, 7533, 5670, 4800, 4200);
const anomus = new potatos(' olar', 470, 1.7, 7800, 6900, 5260, 4630);
const atopuso = new potatos('komisuslar', 780, 1.7, 7900, 6080, 5450, 4815);

var prices = (function moc() {
  if (liczba4 == "A") {
    return animus.price(4200, 4000, 3800, 3600);
  }
  if (liczba4 == "B") {
    return anomus.price(4000, 4200, 4600, 5000);
  }
  if (liczba4 == "C") {
    return atopuso.price(4200, 4500, 4800, 5300);
  }
})();
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This is because the condition you specified inside if(wynik1 <18000) will be true most of the time, use this instead:

if(wynik1 <18000 && wynik1 >= 10000)
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