# Coding for Scrubs: Return The Updated Day (JS)

`Days in the week are represented as strings: ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")Write a function solution that, given a string day representing the day of the week and an integer num (between 0 and 500, inclusive), returns the day of the week that is num days laterFor example, given day = "Mon" and num = 2, the function should return "Wed". `

# Pseudocode:

`          ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]index #      0      1      2      3      4      5      6 `
`1. Make an array of the days 2. Grab the index number of each day3. Grab the index of the new day by adding num 4. Module the index by 7 5. Return!`

# Writing the Function:

`function whatDay(day, num){   let days = ["Mon", "Tues", "Weds", "Thurs", "Fri", "Sat", "Sun"]}`
`function whatDay(day, num){   let days = ["Mon", "Tues", "Weds", "Thurs", "Fri", "Sat", "Sun"]   let dayIndex = days.indexOf(day)}`
`function whatDay(day, num){   let days = ["Mon", "Tues", "Weds", "Thurs", "Fri", "Sat", "Sun"]   let dayIndex = days.indexOf(day)   let newDayIndex = dayIndex + num}`
`function whatDay(day, num){   let days = ["Mon", "Tues", "Weds", "Thurs", "Fri", "Sat", "Sun"]   let dayIndex = days.indexOf(day)   let newDayIndex = dayIndex + num   let newDayIndex = newDayIndex % 7}`
`function whatDay(day, num){   let days = ["Mon", "Tues", "Weds", "Thurs", "Fri", "Sat", "Sun"]   let dayIndex = days.indexOf(day)   let newDayIndex = dayIndex + num   let newDayIndex = newDayIndex % 7   return days[newDayIndex]}`

# Conclusion:

`function whatDay(day, num){   let days = ["Mon", "Tues", "Weds", "Thurs", "Fri", "Sat", "Sun"]   let dayIndex = days.indexOf(day)   let newDayIndex = dayIndex + num % 7   return days[newDayIndex]}console.log(whatDay("Weds", 1))// => "Thu"`

Software Engineer in the making.

## More from Aymes S.

Software Engineer in the making.