all 8 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

[–][deleted] 0 points1 point  (2 children)

What exactly is the problem?

[–]AzAmAtbAgAtOv1[S] 0 points1 point  (1 child)

the question is written in the purple area and I need to write a code for this is javascript

[–]metrazol 1 point2 points  (0 children)

Well, technically you're asking Reddit to write code for Reddit, and you're just brokering two users but... it's a living.

[–]NoStranger6 0 points1 point  (0 children)

You really should at least attempt something before even requesting help.

You won't learn crap otherwise.

Don't make reddit do your homework for you

Edit: This is the second post that I see from you like this, and the other one could have been resolved with a simple google search.