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

153
Vistas
My value1.length is receiving a length undefined error. The value2.length and value3.length aren't receiving errors

Value1.length is sending a undefined error however the other two values are not. Why is it only the first value isn't running properly?

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

0

What does typeerror: cannot read property “values” from undefined really mean?

To understand this, you first need to understand what it means to be undefined in JavaScript. Let’s take a look at a simple example using 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;

Something is undefined when it is an object that is expected to hold a reference to a value, but in fact references nothing. So you have to check your input1's value.

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