1 | function startTime() |
||
2 | { var today=new Date(); |
||
3 | var weekday=new Array(7); |
||
0 ignored issues
–
show
Unused Code
introduced
by
![]() |
|||
4 | var weekday=["Minggu","Senin","Selasa","Rabu","Kamis","Jumat","Sabtu"]; |
||
0 ignored issues
–
show
Comprehensibility
Naming
Best Practice
introduced
by
The variable
weekday already seems to be declared on line 3 . Consider using another variable name or omitting the var keyword.
This check looks for variables that are declared in multiple lines. There may be several reasons for this. In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs. If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared. ![]() |
|||
5 | var monthname=new Array(12); |
||
0 ignored issues
–
show
|
|||
6 | var monthname=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; |
||
0 ignored issues
–
show
Comprehensibility
Naming
Best Practice
introduced
by
The variable
monthname already seems to be declared on line 5 . Consider using another variable name or omitting the var keyword.
This check looks for variables that are declared in multiple lines. There may be several reasons for this. In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs. If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared. ![]() |
|||
7 | var dayname=weekday[today.getDay()]; |
||
8 | var day=today.getDate(); |
||
9 | var month=monthname[today.getMonth()]; |
||
10 | var year=today.getFullYear(); |
||
11 | var h=today.getHours(); |
||
12 | var m=today.getMinutes(); |
||
13 | var s=today.getSeconds(); |
||
14 | h=checkTime(h); |
||
15 | m=checkTime(m); |
||
16 | s=checkTime(s); |
||
17 | document.getElementById('clocktime').innerHTML=dayname+", "+day+"-"+month+"-"+year+", "+h+":"+m+":"+s; |
||
18 | t=setTimeout(function(){startTime()},500); |
||
0 ignored issues
–
show
|
|||
19 | } |
||
20 | // function checkTime to add a zero in front of numbers<10 |
||
21 | function checkTime(i) |
||
22 | { if(i<10){i="0"+i;} |
||
23 | return i; |
||
24 | } |