0👍
I think mapping doesn’t require to loop into your array.
and -1 is somehow mean that the date does not exist in your array.
Maybe because in every loop you add a day to it before you see the actual day.
I think you could try:
var alldays = [...];
//you should eliminate these two codes
// datestart = something;
// dateend = something;
var holiday;
for(var i in alldays){
console.log(alldays.map(Number).indexOf(this.leaveState.currentHoliday));
}
Source:stackexchange.com