Cape Town | 26-ITP-May | Shafiek Walker | Sprint 2 | Coursework Exercises - #1388
Cape Town | 26-ITP-May | Shafiek Walker | Sprint 2 | Coursework Exercises#1388shafiekwalker7861 wants to merge 8 commits into
Conversation
|
|
||
| function calculateBMI(weight, height) { | ||
| // return the BMI of someone based off their weight and height | ||
| return (weight / (height * height)).toFixed(1); |
There was a problem hiding this comment.
What type of value do you expect your function to return? A number or a string?
Does your function return the type of value you expect?
There was a problem hiding this comment.
Thanks for the feedback! I updated the function so it now returns a number instead of a string by using Number(...) around the toFixed() result.
| const currentOutput3 = formatAs12HourClock("12:00"); | ||
| const targetOutput3 = "12:00 pm"; | ||
| console.assert( | ||
| currentOutput3 === targetOutput3, | ||
| `current output: ${currentOutput3}, target output: ${targetOutput3}` | ||
| ); |
There was a problem hiding this comment.
What do you expect from the following function calls?
formatAs12HourClock("00:34");
formatAs12HourClock("12:34");
formatAs12HourClock("01:01");
formatAs12HourClock("13:01");
- Does your function return the value you expected?
- Are the return values consistently formatted?
There was a problem hiding this comment.
Thanks! I added tests for these edge cases, updated the function to preserve the minutes, and made the formatting consistent for all the cases you mentioned.
|
Changes look good. |
|
Thanks @cjyuan , Much apprciated. |
|
Closing PR because the May ITP run has finished. Feel free to re-open if you're still working on it. |
Learners, PR Template
Self checklist
Changelist
Completed all Sprint 2 mandatory exercises, including debugging, implementing functions, interpreting code, and stretch exercises. All code was tested before submission.