javascript - Script error in line 0 on a JS environment -
i've got problem js code. have construct alarm clock objects, doesn't work, seems me fine. here is:
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 wake up!"); }else{ i++; } } } function foo(){ var c=new alarmclock(); c.currenttime(13, 0); c.alarm(13, 2); } foo();
i've tried twice in 2 different environment:
- the first jsenvironment,(http://www.di.unipi.it/~mezzetti/easyjs2/) give me
"syntaxerror: unexpected end of input"
(maybe because had make mistakes) - on other hand, second 1 ( http://www.squarefree.com/jsenv/) give me error
"error on line 0: script error."
how can ride on this?
thank :d
the function alarmclock()
missing 1 last closing braces }
. put }
above function foo()
.
Comments
Post a Comment