Skip to content

Commit 3af98be

Browse files
committed
fixing errors using mentor feedback
1 parent b8b3278 commit 3af98be

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ function calculateBMI(weight, height) {
1919
// return the BMI of someone based off their weight and height
2020
const squaringHeight = height * height;
2121
const resultBMI = weight / squaringHeight;
22-
return resultBMI.toFixed(1);
22+
return Number(resultBMI.toFixed(1));
2323
}
2424
console.log(calculateBMI(weight, height));

Sprint-2/4-mandatory-interpret/time-format.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ console.log(formatTimeDisplay(61));
2525
// =============> write your answer here :0
2626

2727
// c) What is the return value of pad is called for the first time?
28-
// =============> write your answer here:00
28+
// =============> write your answer here:"00"
2929

3030
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3131
// =============> write your answer here: pad(00):pad(01):pad(01) because it will take the value of totalHours,remainingMinutes,remainingSeconds.
3232

3333
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
34-
// =============> write your answer here: the return value will be 00:01:01 because it is the final argument passed to pad() in the return statement.
34+
// =============> write your answer here: the return value will be "01" because 61 seconds has 1 second left after converting to minutes.

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,49 @@
44

55
function formatAs12HourClock(time) {
66
const hours = Number(time.slice(0, 2));
7-
const minutes = time.slice(3, 5);
7+
const minutes = time.slice(-2);
88
if (hours > 12) {
9-
return `${hours - 12}:${minutes} pm`;
9+
return `${String(hours - 12).padStart(2, "0")}:${minutes}pm`;
1010
} else if (hours == 12) {
11-
return `12:${minutes} pm`;
11+
return `12:${minutes}pm`;
1212
} else if (hours === 0) {
13-
return `12:${minutes} am`;
13+
return `12:${minutes}am`;
1414
}
15-
return `${String(hours).padStart(2, "0")}:${minutes} am`;
15+
return `${String(hours).padStart(2, "0")}:${minutes}am`;
1616
}
1717
let currentOutput = formatAs12HourClock("00:01");
18-
let targetOutput = "12:01 am";
18+
let targetOutput = "12:01am";
1919
console.assert(
2020
currentOutput === targetOutput,
2121
`current output: ${currentOutput}, target output: ${targetOutput}`
2222
);
2323

2424
const currentOutput2 = formatAs12HourClock("11:59");
25-
const targetOutput2 = "11:59 am";
25+
const targetOutput2 = "11:59am";
2626
console.assert(
2727
currentOutput2 === targetOutput2,
2828
`current output: ${currentOutput2}, target output: ${targetOutput2}`
2929
);
3030
const currentOutput3 = formatAs12HourClock("12:00");
31-
const targetOutput3 = "12:00 pm";
31+
const targetOutput3 = "12:00pm";
3232
console.assert(
3333
currentOutput3 === targetOutput3,
3434
`current output: ${currentOutput3}, target output: ${targetOutput3}`
3535
);
3636
currentOutput = formatAs12HourClock("00:00");
37-
targetOutput = "12:00 am";
37+
targetOutput = "12:00am";
3838
console.assert(
3939
currentOutput === targetOutput,
4040
`current output: ${currentOutput}, target output: ${targetOutput}`
4141
);
4242
currentOutput = formatAs12HourClock("04:12");
43-
targetOutput = "04:12 am";
43+
targetOutput = "04:12am";
44+
console.assert(
45+
currentOutput === targetOutput,
46+
`current output: ${currentOutput}, target output: ${targetOutput}`
47+
);
48+
currentOutput = formatAs12HourClock("16:12");
49+
targetOutput = "04:12pm";
4450
console.assert(
4551
currentOutput === targetOutput,
4652
`current output: ${currentOutput}, target output: ${targetOutput}`

0 commit comments

Comments
 (0)