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

144
Views
Mi value1.length está recibiendo un error de longitud indefinida. value2.length y value3.length no reciben errores

Value1.length está enviando un error indefinido, sin embargo, los otros dos valores no lo están. ¿Por qué solo el primer valor no funciona correctamente?

 placeOrder.addEventListener("click", function (e) { e.preventDefault(); var value1 = input1.value; if (value1.length < 1) { value1 = 0; coffeeTotal = 0; } else { coffeeTotal = coffeePrice * parseInt(value1); } var value2 = input2.value; if (value2.length < 1) { value2 = 0; bagelTotal = 0; } else { bagelTotal = bagelPrice * parseInt(value2); } var value3 = input3.value; if (value3.length < 1) { value3 = 0; biscottiTotal = 0; } else { biscottiTotal = biscottiPrice * parseInt(value3); } var total = coffeeTotal + bagelTotal + biscottiTotal; console.log(total); });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

¿Qué significa realmente typeerror: no se pueden leer los "valores" de propiedad de undefined?

Para comprender esto, primero debe comprender qué significa no estar definido en JavaScript. Echemos un vistazo a un ejemplo simple usando variables:

 // This line is a variable declaration // we create it, but do not assign it a value // so it is undefined var a; // In this line we declare and assign a variable // this is not undefined var b = 6;

Algo no está definido cuando es un objeto que se espera que contenga una referencia a un valor, pero de hecho no hace referencia a nada. Así que tienes que comprobar el valor de tu input1.

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!