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

194
Views
¿Cómo establecer el valor en el constructor de objetos?

Tengo un problema con mi script.

¿Por qué mi constructor de este objeto no sabe que el valor de wynik1 está cambiando y siempre devuelve "this.A" en lugar de cambiarlo?

 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 answers
Answer question

0

Esto se debe a que la condición que especificó dentro if(wynik1 <18000) será cierta la mayor parte del tiempo, use esto en su lugar:

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