Looking to loop through the Data array and indicate with an "O" if it contains the specified Month and Number. For example, for "Jan-1", Array1[0][0]
should be set to "O". However, the code provided below is not working as expected. Any assistance would be appreciated.
var Data = ["Jan-1", "Feb-4", "Apr-5"];
var Month= ["Jan", "Feb", "Mar", "Apr", "May"];
var Number = ["1", "2", "3", "4", "5"];
var Array1 = [[]];
for (var k = 0; k < Data.length; k++) {
var split = Data[k].split("-");
for (var z = 0; z < Month.length; z++) {
for (var s = 0; s < Number.length; s++) {
if (Month[z] == split[0] && Number[s] == split[1]) {
Array1[z][s] = "O";
} else {
Array1[z][s] = "X";
}
}
}
}
number/month | Jan | Feb | Mar | Apr | May
------------------------------------------------------
1 | O | X | X | X | X
2 | X | X | X | X | X
3 | X | X | X | X | X
4 | X | O | X | X | X
5 | X | X | X | O | X