Q:

based on index of array add items to array in object

I am scraping a website and have an array of numbers that I am looping over:
const arr = [1,2,3,1,2,4,5,6,7];

they correspond to win/lose/draw for different teams:
i.e.
1st item in array is won, second is draw, third is loss, fourth is won, fifth is draw, sixth is loss etc.
How can I loop through these so I have something like the following:
const teams = [{
  won: 1,
  draw: 2,
  lost: 3
 },{ 
  won: 1,
  draw: 2,
  lost: 4
 },{
  won: 5,
  draw: 6,
  lost: 7
}];

I tried something like the following but it didn't work as I expected.

   const arr = [1, 2, 3, 1, 2, 4, 5, 6, 7];

const newArr = [];

arr.forEach((item, index => {
   if (index % 0 === 0) {
     newArr.push({
       won: item
     });

   } else if (index % 1 === 0) {
     newArr.push({
       draw: item
     });
   } else {
     newArr.push({
       lost: item
     });
    }
 });

A:

You want 
index % 3 === 0; // 0, 3, 6, ...
index % 3 === 1; // 1, 4, 7, ...
index % 3 === 2; // 2, 5, 8, ...

