0

Digital clock code

I have written this code and it's failing to run what did I do wrong this is the code: <!DOCTYPE html> <html> <head> <title>Digital Clock</title> <script> setInterval(function(){ var currentTime = new Date(); var hours = currentTime.getHours(); var minutes = currentTime.getMinutes(); var seconds = currentTime.getSeconnds(); var period ="AM"; if(hours >= 12){ period ="PM"; } if(hours > 12){ hour = hours - 12; } if(minutes < 10){ minutes = "0"+minutes; } if(seconds < 10){ seconds = "0"+seconds; } var clockTime = hours ":" + munutes ":" + seconds " " + period; var clock = document.getElementById('clock'); clock.innerText ='clockTime'; },1000); </script> </head> <body> <div id="clock"></div> </body> </html>

7th Jun 2018, 1:08 PM
Tanaka Bester
Tanaka Bester - avatar
3 Respostas
+ 5
- You missed + operator while concatenating the string. - clockTime shouldn't be within single quote (' ') in innerText assignment. - There were some spelling errors Fixed code :) https://code.sololearn.com/WvkWZ6F0Hv18/?ref=app
7th Jun 2018, 1:22 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 1
thank very much
7th Jun 2018, 1:26 PM
Tanaka Bester
Tanaka Bester - avatar
0
please help
7th Jun 2018, 1:08 PM
Tanaka Bester
Tanaka Bester - avatar