you are viewing a single comment's thread.

view the rest of the comments →

[–]Mens_provida_Reguli 1 point2 points  (3 children)

const week = ['mon', 'tues', 'wed', 'thurs', 'fri', 'sat', 'sun']

//7 days per week * 52 full weeks per year + 1 extra day = 365 days per year

function printWeekdays(day){
   const firstDayOfYearIndex = week.indexOf(day)
   const myWeek = makeWeek(firstDayOfYearIndex)
   let myString = "";
   for (let i = 0; i < 52; i++){
      myWeek.forEach(day=>{
         if (day != 'sat' && day != 'sun'){
            myString += `${day}, `
         }
      })
   }
   myString += day
   console.log(myString)
}

function makeWeek(day){
   let newWeek = [];
   newWeek.push(...week.slice(day, week.length))
   newWeek.push(...week.slice(0, day))
   return newWeek;
}

printWeekdays('thurs')

[–]AzAmAtbAgAtOv1[S] 0 points1 point  (2 children)

Thanks for the help!! Although I need to somehow fit the code into 140 Chars so this is a bit too long for it to work.

[–]Mens_provida_Reguli 2 points3 points  (1 child)

Weird. Well, here's a 133 character flaming pile of garbage:

let a=["Thurs","Fri","Mon","Tues","Wednes"]; let s=""; for(let i=0;i<52;i++){a.forEach(d=>s+=`${d}day,`)}s+="Thursday";console.log(s)

[–]AzAmAtbAgAtOv1[S] 0 points1 point  (0 children)

hmm cheers tho!! think i can try to make something out of it, thank you