I am facing an issue with the java-script multidimensional array . I want to search a date and month in a given array if present .I mean i want to count dates except saturday and sunday and national holidays I have this array
var natDays = [
[1, 1, 'uk'],
[1, 19, 'uk'],
[2, 16, 'uk'],
[4, 23, 'uk'],
[7, 03, 'uk'],
[7, 04, 'uk'],
[9, 07, 'uk'],
[8, 12, 'uk'],
[11, 11, 'uk'],
[11, 26, 'uk'],
[12, 25, 'uk']
];
from reference of this answer Here . I have created my function like this
function check_hol(month,date)
{
var natDays = [
[1, 1, 'uk'],
[1, 19, 'uk'],
[2, 16, 'uk'],
[4, 23, 'uk'],
[7, 03, 'uk'],
[7, 04, 'uk'],
[9, 07, 'uk'],
[8, 12, 'uk'],
[11, 11, 'uk'],
[11, 26, 'uk'],
[12, 25, 'uk']
];
for( var md = 0; md <= natDays.length; md++ )
{
alert(natDays[md][0]+'='+month+' and '+natDays[md][1]+'='+date) ;
if( natDays[md][0] != month && natDays[md][1] != date )
{
return true;
}
}
return false;
}
I am using this function to calculate the working days in this function
function workingDays(){
var n=0;
for(var i=1; i<=dp.datediff; i++){
var d1 = new Date();
d1.setDate(d1.getDate()+i);
if(d1.getDay() !== 0&&d1.getDay()!==6 && check_hol(d1.getMonth()+1,d1.getDate())===true)
{
n++;
}
}
alert(n);
dp.wdiff = n;
getShipDays();
getProdDays();
getQuantity();
getShipProdDays();
}
but it returns 0 in the output of working days . if i remove && check_hol(d1.getMonth()+1,d1.getDate())===true
from my second function it is working fine .
can't understand where i am wrong .