Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

357
Views
Javascript - how to take array of abbreviated days and output full name of days

I am trying to take a report of class meeting days in abbreviated form. Each row has an array of days (M,T,W,TH,F,S,SU). How could I loop through the array and change each value of:

M to Monday T to Tuesday W to Wednesday TH to Thursday F to Friday S to Saturday SU to Sunday

I would like to keep the array intact. To switch from {M,W,F} to {Monday,Wednesday,Friday}.

I have tried to for loop through and use a switch in the loop with no luck.

Can you help?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I would use a constant map to help me translate from short to long.

Like this:

const DAYS_SHORT_TO_LONG = {
  SU: 'Sunday',
  M: 'Monday',
  T: 'Tuesday',
  W: 'Wednesday',
  TH: 'Thursday',
  F: 'Friday',
  S: 'Saturday',
}

const daysToConvert = ['M', 'SU', 'F', 'TH'];

const result = daysToConvert.map((shortDay) => DAYS_SHORT_TO_LONG[shortDay]);

console.log(result);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!