Skip to content

Commit e21bdb3

Browse files
committed
updated changes based on reviewers feedback
1 parent 9bfb891 commit e21bdb3

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Sprint-2/3-mandatory-implement/1-bmi.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616

1717
function calculateBMI(weight, height) {
1818
// return the BMI of someone based off their weight and height
19-
return (weight / (height * height)).toFixed(1);
19+
20+
return Number(weight / (height * height)).toFixed(1);
2021
}

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,20 @@ console.assert(
3737
`current output: ${currentOutput7}, target output: ${targetOutput7}`
3838
);
3939

40+
function formatAs12HourClock(time) {
41+
const hours = Number(time.slice(0, 2));
42+
const minutes = time.slice(2); // ":MM"
43+
44+
if (hours === 0) return `12${minutes} am`;
45+
if (hours === 12) return `12${minutes} pm`;
46+
if (hours > 12) return `${String(hours - 12).padStart(2, "0")}${minutes} pm`;
47+
48+
return `${time} am`;
49+
}
50+
4051
// I tested the function with edge cases around midnight and noon.
4152
// I found that the original function handled times like "08:00" and "23:00",
42-
// but it did not correctly handle "00:xx" (midnight times) or "12:xx" (noon times).
53+
// but it did not correctly handle "00:xx" (midnight times) or "12:xx" (noon times).
4354

4455
// Bugs found:
4556
// - "00:00" returned "00:00 am" instead of "12:00 am"

0 commit comments

Comments
 (0)