javascript - Applying a function to a nested loop -
//problem 3a: (var a=1; a<12; a++) { (var b=00; b<60; b++) { (var c=00; c<60; c++) { console.log(a + ':' + b + ':' + c + 'am'); } } } (var alpha=12; alpha<13; alpha++) { (var x=00; x<60; x++) { (var y=00; y<60; y++) { console.log(alpha + ':' + x + ':' + y + 'pm'); } } } (var d=1; d<13; d++) { (var e=00; e<60; e++) { (var f=00; f<60; f++) { console.log(d + ':' + e + ':' + f + 'pm'); } } } //problem 3b: function onetotwo(number) { if (number < 10 && number >= 0) { return '0' + number; } else return number; } //now apply problem 3a: (var q=0; q<10; q++) { onetotwo(q); }
i beginning learn javascript , have written loop output should seconds in every minute in every hour in 1 day, on 12-hour clock. second part of question write function turns 1 digit number respective 2 digit number. think have written both of these correctly, having trouble applying loop. can me please???
you can use
setinterval(function(){ alert("hello"); }, 1000);
1000 refers 1000 ms 1 second
you can replace function(){} function name
<script>setinterval(function(){ console.log(new date().tolocaletimestring());+"\n"; }, 1000);</script>
Comments
Post a Comment