I am trying to store the values that correspond to Sundays and Saturdays for the current month in an array (arr) and display it in the console, the variable 'd' represents the number of days in the current month.
When I try to display a specific value like console.log(arr[1]) it shows "undefined" in the console.
let arr = [];
console.log(arr);
console.log(arr[0]);
const renderDay = () => {
  let td = [];
  for (let i = 1; i <= d; i++) {
    if (
      days[i].toLocaleDateString("fr-FR", options).slice(0, 3) === "sam" ||
      days[i].toLocaleDateString("fr-FR", options).slice(0, 3) === "dim"
    ) {
      td.push(
        <td className="test" key={i}>
          {days[i].toLocaleDateString("fr-FR", options).slice(0, 3)}
        </td>
      );
      arr.push(i);
    } else
      td.push(
        <td key={i}>
          {days[i].toLocaleDateString("fr-FR", options).slice(0, 3)}
        </td>
      );
  }
  return td;
};
I wanted to check if the array is empty, so I display the whole array with console.log(arr),the output looks fine, it shows an array with length: 8 arr = {0: 6 , 1: 7 , 2: 13 , 3: 14 , 4: 20 , 5: 21 , 6: 27 , 7: 28}, who represents the index of Saturdays and Sundays in the current month, but I can't access to every specific value by index.
How I can access to every specific value by its index (arr[0],arr[1],arr[2]....)?
 
     
    