Birmingham | 26-ITP-May | Ogbemi Mene | Sprint 2 | coursework #1439
Birmingham | 26-ITP-May | Ogbemi Mene | Sprint 2 | coursework #1439meneogbemi42-bit wants to merge 17 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
||
| return `${str[0].toUpperCase()}${str.slice(1)}`; | ||
|
|
||
| } |
There was a problem hiding this comment.
Really good explanation of scope and variable declarations here, just wanted to highlight the extra if statement you added. Are you sure it handles the empty string case like you describe?
There was a problem hiding this comment.
this is the best explanation i could come up with.
By checking typeof str !== "string", you are asking: "If the input is anything other than a string, stop processing and just return the input exactly as it is." If you send a string: It skips the if block and proceeds to do the work.
If you send a number: The if condition is true, so it returns the number and ignores the rest of the function.
| // =============> the explanation: | ||
| // The function sum has a return statement before the addition operation, which causes the function to return undefined immediately. | ||
| // To fix this, the return statement should be placed after the addition operation. | ||
| // because the function is not a string i have to remove the backticks and use a normal string concatenation to print the result correctly. |
There was a problem hiding this comment.
// because the function is not a string i have to remove the backticks and use a normal string concatenation to print the result correctly.
What happens if you tried to use the backticks here with a function that returns a number?
There was a problem hiding this comment.
If you use backticks with a function that returns a number, JavaScript will automatically convert that number into a string so it can be combined with the rest of your text. just wanted to indicate that i was not working with string functions
| .padEnd(2, "0"); | ||
|
|
||
| return `£${pounds}.${pence}`; | ||
| } |
There was a problem hiding this comment.
Be wary of code formatting - because you copied and pasted this code from another file, none of the code within the function body is indented, which makes it harder to read.
Prettier is a really useful extension to help with formatting. You don't have to use it, but either way - please fix the formatting here!
There was a problem hiding this comment.
done and corrected. thanks for the correction.
|
|
||
| console.assert(formatAs12HourClock("15:00") === "03:00 pm", `Failed Case D: 03:00 pm`); | ||
| console.assert(formatAs12HourClock("13:00") === "01:00 pm", `Failed Case E: 01:00 pm`); | ||
| console.assert(formatAs12HourClock("15:45") === "03:45 pm", `Failed Case D: 03:45 pm`); | ||
| console.assert(formatAs12HourClock("13:45") === "01:45 pm", `Failed Case E: 01:45 pm`); | ||
| console.assert(formatAs12HourClock("08:45") === "08:45 am", `Failed Case F: 08:45 am`); | ||
|
|
||
| console.log("All current assertions completed!"); No newline at end of file |
There was a problem hiding this comment.
Looks great so far but there's a couple of edge cases I think you should consider: midnight and midday. Think about how you they'd be displayed on both a 24-hour and 12-hour setup and make sure they are included in your test coverage.
Note: these are the kinds of "edge cases" referred to in the instructions.
There was a problem hiding this comment.
i have sent the correct code to address the edge case
|
Really nice explanations Ogbemi! Just a few comments but good work overall. |
This PR contains debugging, implementation, and interpretation work across multiple coding exercises focusing on function parameters, return values, and string manipulation in JavaScript.