-
-
Notifications
You must be signed in to change notification settings - Fork 195
LONDON | May-2025 | Anuar Duisenbek | Module-Structuring-and-Testing-Data | Sprint-2 #559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, you've demonstrated your understanding of the topics well and your answers which I didn't comment on were all correct.
I have left a few comments with requests - Please let me know if you have any questions.
@@ -1,13 +1,29 @@ | |||
// Predict and explain first... | |||
// =============> write your prediction here | |||
// | |||
// I predict we will make mistake because str has been already declared in body of function | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes: The variable "str" is declared in the function signature as a parameter, it is then illegally redeclared in the body of the same function.
// Finally, correct the code to fix the problem | ||
// =============> write your new code here | ||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great but I think you left your code commented out.
|
||
function makeAllCaps(text) { | ||
return text.toUpperCase().split(" ").join("_"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works functionally but it could be improved regarding it's time and space complexity.
You are creating a new array when you call split() on a string. Imagine the input String was the size of a chapter in "lord of the rings" and you called split(" ") on the string? The array would be very large and use up memory.
You could instead, use a different single method that replaces characters without using split() and join().
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
@@ -4,3 +4,22 @@ | |||
// You will need to declare a function called toPounds with an appropriately named parameter. | |||
|
|||
// You should call this function a number of times to check it works for different inputs | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function only logs the result. It should ideally return the formatted string to make it "reusable" in other areas of your program. For example: when using the function in the rest of the program you might want to pass the result into another function instead of just logging it.
if (hours > 12) { | ||
return `${hours - 12}:00 pm`; | ||
const newHours = String(hours - 12).padStart(2, "0"); | ||
return `${newHours}:${minutes} pm`; | ||
} | ||
return `${time} am`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You didn't write any new tests that provide coverage for the issues you found in the code.
Please also include them. In TDD we write tests first and write the code later. It's a common strategy for ensuring requirements and edge-cases are considered before time is spent solving the problem. Your tests should initially all fail before you start working on the code to make them pass.
Self checklist
Changelist
-Fixed bugs in
1-key-errors
and2-mandatory-debug
-Implemented functions in
3-mandatory-implement
(BMI, unit conversions)-Interpreted code and added explanation in
4-mandatory-interpret/time-format.js
Completed stretch task
5-stretch-extend/format-time.js
Questions
Ask any questions you have for your reviewer.