how to create an array of times with half hour intervals instead of declare in variable

后端 未结 3 478
深忆病人
深忆病人 2021-01-24 04:42

i have an long const values below like this ,is it possible to create in function in typescript to reduce a long const.

export const DepartTime = 
[\'00.00\', \'         


        
3条回答
  •  我在风中等你
    2021-01-24 05:04

    You can just use division by 2.

    let DepartTime = [...Array(48)].map((e, i) => {
        return (i/2<10 ? '0' : '') + (i/2 - i/2 % 1) + (i/2 % 1 != 0 ? '.30' : '.00');
    });
    console.log(DepartTime);

提交回复
热议问题