the background gave me a data structure as the header. I don"t feel very good to use it. I want to change the format.
var dateInfo = {
week1_end: "2018-09-09",
week1_start: "2018-09-03",
week2_end: "2018-09-16",
week2_start: "2018-09-10",
week3_end: "2018-09-23",
week3_start: "2018-09-17",
week4_end: "2018-09-30",
week4_start: "2018-09-24",
week5_end: "2018-10-07",
week5_start: "2018-10-01"
};
these are not good to render directly to the page. I think the structure is probably modified to be easy to deal with
dateInfo = [
{week1_start:"2018-09-03",week1_end:"week1_end"},
{week2_start:"2018-09-03",week2_end:"week1_end"} ]
the idea at first is to get the same slider in front of it and make an object and then put it in the array. But every time I print, it"s not what I thought.
var new_arr = []
for(item in dateInfo){
// console.log(item)
var str1 = item.match(/(\S*)_/)[1];
if (item.includes(str1)) {
var obj = {
item : dateInfo[item]
}
}
new_arr.push(obj)
}
Why is this happening? Am I thinking wrong?