-1 means it was not found. That means that there is no element in this.events whose endTime property is equal to this.dataService.yearlyTimeSlots[i].From.
user663031
–
user663031
2017-06-07 09:50:58 +00:00
CommentedJun 7, 2017 at 9:50
events is an array of objects, e.endTime is a date and this.dataService.yearlyTimeSlots[i].From is a date too, the method itself returns -1 all the time
user8090896
–
user8090896
2017-06-07 09:53:36 +00:00
CommentedJun 7, 2017 at 9:53
You need to make sure that the dates you are trying to compare are in precisely the same format, such as msec since epoch, or ISO format, etc. This should not be that hard to debug. Stop the debugger at that line, and examine this.events and this.dataService.yearlyTimeSlots[i], and make sure that the latter value occurs as the endTime property of some element in this.events. Just out of curiosity, where is i coming from?
this.events.findIndex? What value is passed to e?-1means it was not found. That means that there is no element inthis.eventswhoseendTimeproperty is equal tothis.dataService.yearlyTimeSlots[i].From.this.eventsandthis.dataService.yearlyTimeSlots[i], and make sure that the latter value occurs as theendTimeproperty of some element inthis.events. Just out of curiosity, where isicoming from?