Skip to main content
replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

I found thisthis code to group JSON data by any Key. Use it in your code to group the results by DayOfWeek.

getListItems('MyMeetings','?select=Title,DayOfWeek',
    function(items){
        var daysOfWeek = groupBy(items, function(item){
            return [item.DayOfWeek];
        });
        console.log(daysOfWeek);
    },
    function(error){
       console.log(JSON.stringify(error));
    }
);

function groupBy( array , f )
{
  var groups = {};
  array.forEach( function( o )
  {
    var group = JSON.stringify( f(o) );
    groups[group] = groups[group] || [];
    groups[group].push( o );  
  });
  return Object.keys(groups).map( function( group )
  {
    return groups[group]; 
  })
}

I found this code to group JSON data by any Key. Use it in your code to group the results by DayOfWeek.

getListItems('MyMeetings','?select=Title,DayOfWeek',
    function(items){
        var daysOfWeek = groupBy(items, function(item){
            return [item.DayOfWeek];
        });
        console.log(daysOfWeek);
    },
    function(error){
       console.log(JSON.stringify(error));
    }
);

function groupBy( array , f )
{
  var groups = {};
  array.forEach( function( o )
  {
    var group = JSON.stringify( f(o) );
    groups[group] = groups[group] || [];
    groups[group].push( o );  
  });
  return Object.keys(groups).map( function( group )
  {
    return groups[group]; 
  })
}

I found this code to group JSON data by any Key. Use it in your code to group the results by DayOfWeek.

getListItems('MyMeetings','?select=Title,DayOfWeek',
    function(items){
        var daysOfWeek = groupBy(items, function(item){
            return [item.DayOfWeek];
        });
        console.log(daysOfWeek);
    },
    function(error){
       console.log(JSON.stringify(error));
    }
);

function groupBy( array , f )
{
  var groups = {};
  array.forEach( function( o )
  {
    var group = JSON.stringify( f(o) );
    groups[group] = groups[group] || [];
    groups[group].push( o );  
  });
  return Object.keys(groups).map( function( group )
  {
    return groups[group]; 
  })
}
Source Link
Yayati
  • 1.7k
  • 4
  • 16
  • 36

I found this code to group JSON data by any Key. Use it in your code to group the results by DayOfWeek.

getListItems('MyMeetings','?select=Title,DayOfWeek',
    function(items){
        var daysOfWeek = groupBy(items, function(item){
            return [item.DayOfWeek];
        });
        console.log(daysOfWeek);
    },
    function(error){
       console.log(JSON.stringify(error));
    }
);

function groupBy( array , f )
{
  var groups = {};
  array.forEach( function( o )
  {
    var group = JSON.stringify( f(o) );
    groups[group] = groups[group] || [];
    groups[group].push( o );  
  });
  return Object.keys(groups).map( function( group )
  {
    return groups[group]; 
  })
}