Skip to content

Commit 0422ff0

Browse files
Avoid mutating time parameter and store converted hours in a new variable
1 parent 5cf8a5a commit 0422ff0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sprint-2/5-stretch-extend/format-time.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
function formatAs12HourClock(time) {
66
const hours = Number(time.slice(0, 2));
77
if (hours > 12) {
8-
time = hours - 12;
9-
return `${time.toString().padStart(2 , "0")}:00 pm`
8+
const convertedHours= hours - 12;
9+
return `${convertedHours.toString().padStart(2 , "0")}:00 pm`
1010
}
1111
return `${time} am`;
1212
}

0 commit comments

Comments
 (0)