I have three arrays:
var dates = ['07/31/2013', '08/01/2013', '08/02/2013', '08/03/2013', '08/04/2013', '08/05/2013', '08/06/2013', '08/07/2013'];
The dates array contains every date in a range of a week.
var meetingdates = ['07/31/2013', '08/02/2013', '08/03/2013', '08/04/2013', '08/05/2013', '08/07/2013'];
The meetingdates array contains dates, where there are 1 or more meetings.
var meetings = ['1', '3', '2', '4', '1', '5']
The meetings array contains the number of the meetings on the dates from meetingdates.
I want to compare the dates array with the meetings array, if an entry from the meetingsarray exists in dates I want to put the number of the meetings which belongs to that date in a new array, if theres no match an 0 will be inserted:
So after comparing the meetingsarray with dates this will be the final result.
meetingsPerDate = ['1', '0', '3', '2', '4', '1', '0', '0'];
I tried solving this with the following for-loop:
if(dates[y] == meetingdates [y]){
meetingsPerDate [y] = meetings [y];
}else {
meetingsPerDate[y] = 0;
}
}
I know I will be missing some numbers because both of the arrays are not following the same pattern, but I really don't know how to solve this.
I hope I've explained my problem well, if not please let me know.
Any help is very appreciated,
Thanks!