var arr = ['09:30:00', '09:45:00', '10:00:00', '10:15:00', '10:30:00', '10:45:00', '11:00:00', '11:15:00'];
var $elem = $("<table>", {
'class': 'table table-responsive table-bordered overview-table',
'border': '1'
});
var $tbody = $("<tbody>", {
'class': 'overview_table_td'
}).appendTo($elem);
$.each(arr, function(i) {
$tbodyTR = $("<tr>", {}).appendTo($tbody);
if (i % 4 == 0) {
$tbodyTH = $("<th>", {
'scope': 'row',
'html': arr[i].slice(0, -6),
'rowspan': '4'
}).appendTo($tbodyTR);
}
$tbodyTH = $("<th>", {
'scope': 'row',
'html': arr[i].slice(3, 5)
}).appendTo($tbodyTR);
});
$(".overview").html($elem);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="overview">
</div>
I am getting unexpected output when I do i % 4 == 0 but I have can I achieve from array that 09 occurs how many times.
If there any solution for it?
Expected Result
Look if in array there is a 09:30:00, 09:45:00. so after slice this value i m getting 2 times 09. so i want to use that counter in i % 2 == 0, and you can see further after slice i can get 10, 4 times so if condition will be i % 4 == 0
So i want to run if condition 2 time when it is 09 and 4 time when it is 10.
Hope you get my expected Result.
Need Help.
