javascript - JS环境第0行脚本错误

标签 javascript arrays object runtime-error

我的 JS 代码有问题。我必须用对象构建一个闹钟,但它不起作用,即使在我看来很好。 这是:

function AlarmClock(){

  this.hour;
  this.minutes;
  this.Hours=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];

  this.currentTime=
    function(h, m){
    this.hour=h;
    this.minutes=m;
    if (this.hour>23){
      this.hour=0;
    }
    if(this.minutes>59){
      this.minutes=0;
    }
  }

  this.alarm=
    function(h, m){
    this.hour=h;
    this.minutes=m;
    if(this.hour>23){
      this.hour=0;
    }
    if(this.minutes>59){
      this.minutes=0;
    }
  }

  this.tic=
    function(){
    var i=0;
    while(i<=m){
      m.currentTime+=i;
    if(m.currentTime==60){
      h.currentTime+=1;
    }
   if (h.currentTime==24){
      h.currentTime=0;
    } 
   if(((h.currentTime)&&(m.currentTime))==((h.alarm)&&(m.alarm))){
      return ("Time to wake up!");
    }else{
        i++;
    }
  }
}

function foo(){
  var c=new AlarmClock();
  c.currentTime(13, 0);
  c.alarm(13, 2);
}
  foo();

我在两个不同的环境中尝试了两次:

我怎样才能跨过这个?

非常感谢:D

最佳答案

函数 AlarmClock() 缺少最后一个右大括号 }。只需在函数 foo() 上方放置一个 } 即可。

关于javascript - JS环境第0行脚本错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27020521/

相关文章:

javascript - apple “The 50 Billion Apps Countdown Promotion” 这个js代码有什么意义?

javascript - 如何防止iFrame警告框

javascript - 当用户要写东西时如何防止重新加载?

c - 将文本文件中的整数存储到整数数组中

PHP 不可见字符串

javascript - 无法运行对象的功能

javascript - AngularJS 表单验证不起作用

java - 为什么会收到 java.io.EOFException 和 ArrayOutOfBounds 错误?帮助?

javascript - 在另一个对象中引用对象javascript

c# - 如何扩展对象层次结构以保存额外数据?