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

121
Views
Index variable of an array in a for loop throwing error

I want to compare the start date of the curr_item array based on index, but im getting this particular error at the arrow marked line.Im not sure what the issue is :(

0: Object start_time: "2021-10-27T13:30:00.000+05:30" end_time: "2021-10-27T13:45:00.000+05:30" 1: Object start_time: "2021-10-27T13:46:00.000+05:30" end_time: "2021-10-27T14:00:00.000+05:30" 2: Object start_time: "2021-10-27T14:00:00.000+05:30" end_time: "2021-10-27T15:02:00.000+05:30"


for (let index = 0; index < possible_slots; index++) {
  if (
    curr_time.toMillis() ===
   -----> DateTime.fromISO(curr_item[index].start_time).toMillis() <-----
  ) {
    slotlist.push({
      start_time: DateTime.fromISO(curr_item[index].start_time).toISO(),
      end_time: DateTime.fromISO(curr_item[index].end_time).toISO(),
      name: `asd`
    });
  } else {
    slotlist.push({
      start_time: DateTime.fromISO((curr_item[index]).start_time).toISO(),
      end_time: DateTime.fromISO(curr_item[index].end_time).toISO(),
      hole: `true${index}`
    });

    curr_time = DateTime.fromISO(slotlist[slotlist.length - 1].end_time);
  }
  curr_item[index] = curr_item[index + 1];
}

Error: Cannot read properties of undefined (reading 'start_time')

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There can be only two reasons for this:

  1. Array which is according to your code curr_item is undefined. 2.The index you are trying to access inside the curr_item array is not available in the array. meaning curr_item[index] gives undefined and when you try to access the start_time of the above statement it throws the error.
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!