Skip to content

Commit d81fa17

Browse files
remove comment
1 parent 428849e commit d81fa17

1 file changed

Lines changed: 11 additions & 37 deletions

File tree

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,30 @@
1-
// function formatAs12HourClock(time) {
2-
// //extract digits representing hours
3-
// const hours = Number(time.slice(0, 2));
4-
// //if houre value over 12, subtract 12
5-
// //if hour value under 12 , continue
6-
// if (time === "00:00") {
7-
// return `12:00 am`;
8-
// }
9-
// if (hours > 12) {
10-
// // add pm and reurn value
11-
// return `${hours - 12}:00 pm`;
12-
// }
13-
// //add am or pm
14-
// //return new value
15-
// return `${time} am`;
16-
// }
17-
181
function formatAs12HourClock(time) {
2+
console.log(time.length);
193

20-
console.log(time.length)
21-
224
if (time.length == 4) {
23-
console.log("got here")
24-
time=time.padStart(5, "0")
5+
console.log("got here");
6+
time = time.padStart(5, "0");
7+
}
8+
9+
if (typeof time !== "string") {
10+
return "nccorect timing format";
2511
}
26-
27-
if (typeof time !== "string") {
28-
return "nccorect timing format";
29-
}
3012

31-
const match = time.match(/^(\d{1,2}):(\d{2})$/);
13+
const match = time.match(/^(\d{1,2}):(\d{2})$/);
3214

33-
if (!match) {
34-
return "Inccorect timing format";
35-
}
15+
if (!match) {
16+
return "Inccorect timing format";
17+
}
3618

37-
38-
3919
const hours = Number(time.slice(0, 2));
4020
const minutes = Number(time.slice(3, 5));
41-
console.log(hours + ` <------------look here hour`);
42-
console.log(time + ` <------------look here time`);
43-
4421

4522
if (time === "00:00") {
4623
return `12:00 am`;
4724
}
4825
if (time === "12:00") {
4926
return `12:00 pm`;
5027
}
51-
5228

5329
if (hours < 12) {
5430
return `${time} am`;
@@ -73,5 +49,3 @@ function formatAs12HourClock(time) {
7349
}
7450

7551
export { formatAs12HourClock };
76-
77-

0 commit comments

Comments
 (0)