//Exercise 3a:
for (var a=1; a<12; a++) {
for (var b=00; b<60; b++) {
for (var c=00; c<60; c++) {
console.log(a + ':' + b + ':' + c + 'AM');
}
}
}
for (var alpha=12; alpha<13; alpha++) {
for (var x=00; x<60; x++) {
for (var y=00; y<60; y++) {
console.log(alpha + ':' + x + ':' + y + 'PM');
}
}
}
for (var d=1; d<13; d++) {
for (var e=00; e<60; e++) {
for (var f=00; f<60; f++) {
console.log(d + ':' + e + ':' + f + 'PM');
}
}
}
//Exercise 3b:
function toTwoDigits(number) {
if (number < 10 && number >= 0) {
return '0' + number;
} else
return number;
}
//Applying to Exercise 3a:
for (var q=0; q<10; q++) {
toTwoDigits(q);
}
I am starting my journey into Javascript and have crafted a for loop that generates the seconds in each minute for every hour in a day, on a 12-hour clock. The second part of the exercise required me to create a function that converts any single-digit number to a two-digit number. I believe I have completed both tasks successfully, but I am struggling with implementing the function into the for loop. Can anyone provide some assistance with this, please?