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

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

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 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!