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 in Java-Script by Ashwini
• 2,760 points
33 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,800 points
357 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,800 points
14,519 views
0 votes
0 answers

Uncaught TypeError: Cannot read property 'top' of undefined

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

May 11 in Java-Script by Kichu
• 19,040 points
1,096 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 in Java-Script by Kichu
• 19,040 points
218 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 in Java-Script by Ashwini
• 2,760 points
25 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 in Java by Rahul
• 9,680 points
467 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,510 points
413 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,800 points
10,053 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,800 points
17,531 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