Stack Exchange
Loop for tables in react-table
I'm trying to create a loop for react-table. 
I have a function   getMyData 
const getMyData =()=> {
  const arrAvg = arr => arr.reduce((a, b) => a + b, 0) / arr.length;
  let result = {
    today: null,
    average: null,
    name: null,
  }

  for (var key in data.users) {
    const start =  moment(data.users[key].lastUpdated)
    const end = moment();
    const range = moment.range(start, end);
    const days = range.diff('days');

    console.log('The days are ',days);

    if (days >= 0 && days < 7) {
      result.today = data.users[key].availabilityArray[days];
      result.average = arrAvg(data.users[key].availabilityArray.splice(days + 1));
      result.name = data.users[key].name;
      var absentVal = result.absent=   data.users[key].absent
    }

    console.log('Executing this command ', key);
    if (absentVal===true){
      return {result}
    }
    console.log('End of return result',result );
  }
}

and then export functions 
const range1 = len => {
  const arr = [];
  for (let i = 0; i < len; i++) {
    arr.push(i);
  }

  console.log('The arr is ', arr);
  return arr;
};

export function makeData(len = 2){
  return range1(len).map(d=> {
    return getMyData();
  });
}


How do we create a loop which renders data filtered through getMyData function?

Could you add the result console.log ?

@Striped. I get too many values in the console for result. Here is the output http://prntscr.com/iwmv92

Ok, I saw your outputs, and first you have strange things in your code, for instance var absentVal = result.absent=   data.users[key].absent is really weird in my opinion. Then getMyData returns a single object which apparently looks like {today, average, name} so you can't loop on it.

@Striped, Yes true! It returns only single values {today, average, name} for now. Is there a way in which we can make the function  getMyData return values in a loop?

I'm sorry I don't understand your error or what you want to do. Your code seems fine though.
