有没有一种方法可以遍历数组中的日期并将它们添加到该对象?

Is there a way I could iterate through dates in an array and add them to this object?

我正在使用我在网上找到的 jQuery 日历,但我很难将日期添加到其中。 我能够遍历 API 响应并将它们推送到一个数组。但是从那里我很难将它添加到日历中。

        $(function(){
          $("#calendar").simpleCalendar();
        });

        var dates = [];
        var descriptions = [];

        for(i = 0; i < result['data']['holidays'].length; i++){
          let date = result['data']['holidays'][i]['date']['iso'];
          dates.push(new Date(date));
          descriptions.push(result['data']['holidays'][i]['description']);
        }

        console.log(dates[34] + " " + descriptions[34]);
                
        $("#calendar").simpleCalendar({       
          // Events displayed
          displayEvent:true,
          // Dates of the events                  
          events: [           
            {
              startDate: dates[1],
              endDate: dates[1],
              summary: descriptions[1]
            }
          ]
        });       

我试过将它添加到循环中并将数组键作为“i”,但这对我不起作用。

在循环中填充 events 变量,并直接在 json.

上使用它
    $(function(){
      $("#calendar").simpleCalendar();
    });

    var eventsArr = [];

    for(i = 0; i < result['data']['holidays'].length; i++){
      let date = result['data']['holidays'][i]['date']['iso'];
      eventsArr.push({
          "startDate": new Date(date),
          "endDate"  : new Date(date),
          "summary"  : result['data']['holidays'][i]['description']
      });
    }

    $("#calendar").simpleCalendar({       
      // Events displayed
      displayEvent:true,
      // Dates of the events                  
      events: eventsArr
    });