Javascript 立即打开时间按钮

Javascript 立即打开时间按钮,javascript,json,loops,button,time,Javascript,Json,Loops,Button,Time,我正试图创建一个按钮,显示我按下按钮时哪些商店开门。我使用filterJSON:Function()过滤掉打开的时间,但我似乎无法让循环只显示打开的时间。我知道我需要做什么来创建按钮,但无法找到一种方法来显示当前时间的打开时间 var hours = feature.properties.hours; for (y = 0; y < hours.length; y++) { var normalizeHours= hours[y].replace(/\s

我正试图创建一个按钮,显示我按下按钮时哪些商店开门。我使用filterJSON:Function()过滤掉打开的时间,但我似乎无法让循环只显示打开的时间。我知道我需要做什么来创建按钮,但无法找到一种方法来显示当前时间的打开时间

    var hours = feature.properties.hours;
      for (y = 0; y < hours.length; y++) {
        var normalizeHours= hours[y].replace(/\s/g, '').toLowerCase();
        if (watcher.indexOf(normalizeHours) !== -1) {
          return feature;
        }
      }`

变量
hours[y]
不是字符串


首先,您必须更改您的
(y=0;i可能是已编辑问题的副本,以删除指向GeoJSON的引用和标记,因为这与GeoJSON完全无关。添加了JSON标记,这就是您正在使用的。请参阅:@iH8看起来问题有两个;)。
hours: {
    monday: {
        close: "18:00:00",
        open: "10:00:00",
        call: false
    },
    tuesday: {
        close: "18:00:00",
        open: "12:00:00",
        call: true
    },
    friday: {
        close: "None",
        open: "None",
        call: false
    },
    wednesday: {
        close: "18:00:00",
        open: "17:00:00",
        call: false
    },
    thursday: {
        close: "None",
        open: "None",
        call: true
    },
    sunday: {
        close: "18:00:00",
        open: "15:33:00",
        call: false
    },
    saturday: {
        close: "18:00:00",
        open: "15:00:00",
        call: false
    }
},
console.log(hours[y]);
Object {close: "18:00:00", open: "10:00:00", call: false}
Object {close: "18:00:00", open: "12:00:00", call: true}
Object {close: "None", open: "None", call: false}
Object {close: "18:00:00", open: "17:00:00", call: false}
Object {close: "None", open: "None", call: true}
Object {close: "18:00:00", open: "15:33:00", call: false}
Object {close: "18:00:00", open: "15:00:00", call: false}
for (var y in hours) {

    var normalizeHoursOpen= hours[y].open.replace(/\s/g, '').toLowerCase();
    var normalizeHoursClose= hours[y].close.replace(/\s/g, '').toLowerCase();
   var week = ["monday","tuesday","wednesday","thursday","saturday","sunday","friday"];

  var hours =  {
    monday: {
        close: "18:00:00",
        open: "10:00:00",
        call: false
    },
    tuesday: {
        close: "18:00:00",
        open: "12:00:00",
        call: true
    },
    friday: {
        close: "None",
        open: "None",
        call: false
    },
    wednesday: {
        close: "18:00:00",
        open: "17:00:00",
        call: false
    },
    thursday: {
        close: "None",
        open: "None",
        call: true
    },
    sunday: {
        close: "18:00:00",
        open: "15:33:00",
        call: false
    },
    saturday: {
        close: "18:00:00",
        open: "15:00:00",
        call: false
    }
}


  for (day in week){

        console.log(hours[week[day]])
  }