jeudi 24 novembre 2016

Logic: List of Day Format With Select Trigger

To explain what needed, i give some examples:

  1. The Input : Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. The Output : Monday - Sunday.
  2. The Input : Monday, Tuesday, Thursday, Friday, Saturday, Sunday. The Output : Monday, Tuesday, Thursday - Sunday.
  3. The Input : Wednesday, Thursday, Friday, Saturday, Sunday. The Output : Wednesday - Sunday.
  4. The Input : Monday, Wednesday, Thursday, Saturday, Sunday. The Output : Monday, Wednesday, Thursday, Saturday, Sunday
  5. Etc

Currently, i create 2 array and 1 string:

dayOption: any = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
daySelected: any = [true, true, true, true, true, true, true]
dayFormated: any = '';

But, i was done it with very complex and too much if-statement. I'm sure there's another simple and efficient ways to do that.

Note: Typescript language. I just need the logic, whatever language you used for.

Aucun commentaire:

Enregistrer un commentaire