Cannot read property push of undefined when combining arrays

0 votes

When pushing an array's contents to another array I get

var order = new Object(), stack = [];
for(var i=0;i<a.length;i++){
    if(parseInt(a[i].daysleft) == 0){ order[0].push(a[i]); }
    if(parseInt(a[i].daysleft) > 0){ order[1].push(a[i]); }
    if(parseInt(a[i].daysleft) < 0){ order[2].push(a[i]); }
}

Why do I get this error in the second if statement?

Nov 16, 2022 in Java-Script by Ashwini
• 5,430 points
569 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Java-Script

0 votes
1 answer

Uncaught TypeError: Cannot read property 'setState' of undefined

Hello kartik, You dont have to bind anything, ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,840 points
832 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'indexOf' of undefined

Hello @kartik, First of all, you don't need ...READ MORE

answered Jun 2, 2020 in Java-Script by Niroj
• 82,840 points
19,549 views
0 votes
0 answers

Uncaught TypeError: Cannot read property 'top' of undefined

I have two different kinds of sticky ...READ MORE

May 11, 2022 in Java-Script by Kichu
• 19,040 points
3,383 views
0 votes
0 answers

Sort array of objects by string property value

I have this array of JavaScript objects: var objs ...READ MORE

May 10, 2022 in Java-Script by Kichu
• 19,040 points
922 views
0 votes
0 answers
0 votes
0 answers

map function for objects (instead of arrays)

I have an object: myObject = { 'a': ...READ MORE

Nov 16, 2022 in Java-Script by Ashwini
• 5,430 points
622 views
0 votes
1 answer

Cannot read property 'push' of undefined when combining arrays

The reason why you get this ERROR ...READ MORE

answered Feb 11, 2022 in Java by Rahul
• 9,680 points
2,279 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,520 points
1,315 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'msie' of undefined - jQuery tools

Hello, Use the following script tag in your ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,840 points
15,710 views
0 votes
1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,840 points
23,295 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP