To explain what needed, i give some examples:
- The Input : Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. The Output : Monday - Sunday.
- The Input : Monday, Tuesday, Thursday, Friday, Saturday, Sunday. The Output : Monday, Tuesday, Thursday - Sunday.
- The Input : Wednesday, Thursday, Friday, Saturday, Sunday. The Output : Wednesday - Sunday.
- The Input : Monday, Wednesday, Thursday, Saturday, Sunday. The Output : Monday, Wednesday, Thursday, Saturday, Sunday
- 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