create a simple weekly agenda with hourly slots in javascript

index.tsx
// set up the hours of the day
const hours = ['9:00am', '10:00am', '11:00am', '12:00pm', '1:00pm', '2:00pm', '3:00pm', '4:00pm', '5:00pm'];

// create a two-dimensional array to hold hourly slots for each day of the week
const weeklyAgenda = [
  ['Monday'],
  ['Tuesday'],
  ['Wednesday'],
  ['Thursday'],
  ['Friday'],
  ['Saturday'],
  ['Sunday']
];

// fill in the hourly slots for each day of the week
for (let i=0; i<weeklyAgenda.length; i++) {
  for (let j=0; j<hours.length; j++) {
    weeklyAgenda[i].push(hours[j]);
  }
}

// print out the weekly agenda
for (let i=0; i<weeklyAgenda.length; i++) {
  console.log(weeklyAgenda[i].join('\t'));
}
652 chars
26 lines

This code will create a two-dimensional array that holds hourly slots for each day of the week. The first column of the array will be the day of the week, and the subsequent columns will hold the hourly slots. The code then loops through the array to fill in the hourly slots for each day of the week. Finally, the code prints out the weekly agenda by looping through the array and printing out each row.

gistlibby LogSnag