要在calendar.js中添加事件,您可以使用以下步驟:
const newEvent = {
title: 'Birthday Party',
date: '2022-10-15',
time: '15:00'
};
const events = [
{ title: 'Meeting', date: '2022-10-10', time: '09:00' },
{ title: 'Lunch', date: '2022-10-12', time: '12:00' }
];
events.push(newEvent);
events.forEach(event => {
console.log(`${event.title} on ${event.date} at ${event.time}`);
});
這樣,您就成功在calendar.js中添加了新的事件。您可以根據自己的需求對事件對象進行定制和排列。