How to process time data in the form of |

to make a course scheduling system, pass the selected course time period to the backend, and the structural data of the backend needs such
localhost:10090/paiban/save?teacherId=1&paiban=2018-08-08 | 08:00-09:00 | 10:00-12:00 | 13:00-19 Glaze 00002018-08-09 | 08:00-09:00 | 10:00-12:00 | 13:00-19:00
because you have to queue for many days, but also pass the selected time period of each day

.

the key is that there is no train of thought. Please give me some advice


The idea of

is that you first need to generate structured data, and then switch to string when you need it.

let demo = [{
        date: '2018-08-08',
        ranges: [
            ['08:00', '09:00'],
            ['12:00', '13:00']
        ]
    },
    {
        date: '2018-08-09',
        ranges: [
            ['08:00', '09:00'],
            ['12:00', '13:00']
        ]
    }
]

 demo.map(d => {
    return d.date + '|' + d.ranges.map(r => r.join('-')).join('|')
}).join(',')
Menu