It feels like you're asking the community to solve a business requirement that is not clearly defined.
What does the integer array have to with the UI? Why do you need the array in the first place and what purpose does the array fulfill? If you explain at a higher level what you goals is then we can help you with a design solution.
your requirements are still weak. by group, do you mean an array? array of group arrays? what is the grouping favor, just the static values in your sample.
select the group is simple:
var arr = [1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 15, 16, 18, 19, 20, 21, 22, 23];
var group1To4 = arr.reduce(function(l,c) {
if (c >= 1 && c <= 4) l.push(c);
return l;
},[]);
this you could generalize to:
function group (arr,low,high) {
return arr.reduce(function(l,c) {
if (c >=low && c <= hi) l.push(c);
return l;
},[]);
}
var groups = [];
groups.push(group(arr,1,4));
groups.push(group(arr,6,12));
groups.push(group(arr,15,16));
groups.push(group(arr,18,23));
Member
34 Points
63 Posts
hours grouping using javascript
Jul 02, 2016 01:19 PM|krdobariya|LINK
deleted
All-Star
52251 Points
23315 Posts
Re: hours grouping using javascript
Jul 02, 2016 01:36 PM|mgebhard|LINK
It feels like you're asking the community to solve a business requirement that is not clearly defined.
What does the integer array have to with the UI? Why do you need the array in the first place and what purpose does the array fulfill? If you explain at a higher level what you goals is then we can help you with a design solution.
Member
34 Points
63 Posts
Re: hours grouping using javascript
Jul 02, 2016 04:59 PM|krdobariya|LINK
Hello mgebhard,
i have day wise time entry this is my first day time entry in hours.
my requirement is to display like that in UI; no any logical algorithm just i have to display like that.
Time : 1 - 4
Time : 6 - 12
Time : 15 - 16
Time : 18 - 23
my requirement is just grouping.
Thanks,
KD
All-Star
57884 Points
15513 Posts
Re: hours grouping using javascript
Jul 04, 2016 12:54 AM|bruce (sqlwork.com)|LINK
your requirements are still weak. by group, do you mean an array? array of group arrays? what is the grouping favor, just the static values in your sample.
select the group is simple: