-
-
Notifications
You must be signed in to change notification settings - Fork 197
London | 25-ITP-Sept | Gislaine Della Bella | Sprint 2 | Sprint 2 -Final #933
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?
London | 25-ITP-Sept | Gislaine Della Bella | Sprint 2 | Sprint 2 -Final #933
Conversation
// It is not my solution I got help with AI. I confess I need to undestand more those 3 methodos to think how to get to this. // I will come back to it later. For now i will keep practicing more katas because they are help me.
|
Your PR's title isn't in the expected format. Please check the expected title format, and update yours to match. Reason: Wrong number of parts separated by |s If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above. |
|
Your PR's title isn't in the expected format. Please check the expected title format, and update yours to match. Reason: Wrong number of parts separated by |s If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above. |
|
Your PR's title isn't in the expected format. Please check the expected title format, and update yours to match. Reason: Wrong number of parts separated by |s If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above. |
| @@ -1,3 +1,11 @@ | |||
| function contains() {} | |||
| function contains(someObject, propertyName) { | |||
| let whatTheRobotFound = someObject[propertyName]; | |||
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.
What's this variable for?
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.
I realize now that I’m not actually using this variable, so I’ll remove it to keep the code clean.
| function contains() {} | ||
| function contains(someObject, propertyName) { | ||
| let whatTheRobotFound = someObject[propertyName]; | ||
| if (someObject[propertyName] === undefined) { |
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.
We can store the value undefined in objects. What would you expect to be returned in this case? What does your code do?
contains({"name": undefined}, "name");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.
I see...my code returns false even if the property exists but is set to undefined. I’ll use the in operator to fix this so it checks for the property instead of its value
| function contains(someObject, propertyName) { | ||
| let whatTheRobotFound = someObject[propertyName]; | ||
| if (someObject[propertyName] === undefined) { | ||
| return false; |
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 should never have to write:
if (something) {
return true;
} else {
return false;
}Because the condition in an if statement evaluates to a boolean, you can just return it directly:
return something;which does the same. If you need to negate it, you can
return !something;| // Then it should return false | ||
| test.todo("contains on empty object returns false"); | ||
| test("contains on empty object returns false", () => { | ||
| const inputEmpty = []; |
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 isn't an empty object, it's an array. It may be interesting to test what happens when passed an array, but it's not quite what the test name describes.
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.
I used the symbol for an array [] by mistake. I’ll change it to {}
| test("give a object with proprieties when pass contains with non-exist proprity name it should return false", () => { | ||
| const inputProprieties2 = ["f", "g", "h"]; | ||
| const result = contains(inputProprieties2); | ||
| expect(result).toEqual(false); | ||
| }); |
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.
I'm not quite sure what this test description is trying to convey, or what the test is trying to test... Can you explain?
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.
I meant to pass an object (like {a: 1}) and a property name to check if it exists. I error used an array instead
| const invalidParameters = ("f", "g", "h"); | ||
| const result = contains(invalidParameters); |
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.
Not specifying a second parameter is an interesting case here, but the test name isn't very descriptive of this... Also, what is the type of invalidParameters 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.
It is a string. Because I used () instead of square brackets, JavaScript only looks at the last item. I also forgot the second parameter. I’ll fix it to be a proper test
| for (let i = 0; i < countryCurrencyPairs.length; i++) { | ||
| const countryCode = countryCurrencyPairs[i][0]; |
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, but probably isn't the most clear way of iterating across this array.
Can you think how other looping constructs, or destructuring, could help you make this more clear and easy to read?
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.
i ffor...of loop would work better there.
| expect(parseQueryString("equation=x=y+1")).toEqual({ equation: "x=y+1" }); | ||
| }); | ||
|
|
||
| // Special characters |
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.
What's special about %20?
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.
It’s the code for a space
| // a) What is the current return value when invert is called with { a : 1 } | ||
| // 1 | ||
|
|
||
| // b) What is the current return value when invert is called with { a: 1, b: 2 } | ||
| ///2 |
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.
I don't think the function currently returns numbers. Can you talk through why you think it does?
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.
I was looking at the values inside the object instead of the object I see now that invert should return a new object with keys and values swapped, like { 1: 'a' } instead of just the number 1..
|
|
||
| // d) Explain why the current return value is different from the target output | ||
|
|
||
| // The bug is invertedObj.key = value — this literally creates a property named "key" |
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.
Good identification of the problem and the fix!
|
Your self-checklist isn't currently correctly filled out - you need to tick boxes with On the first commits - you should be able to remove with any of:
|
|
thnk you Daniel for your time |
Self checklist
Changelist
Hi Volunteer,
Please ignore my first commits on this PR. I have tried to clean it up, but for some reason, it is not working, and I will go back to it.
The commits to be revised here are from 'Commits on Dec 16, 2025 - Sprint 2- Lookup.js' "d7ce32bf522dd240741bac5ce9bfc5cc6845e3ae".
Please ignore my first comments on this PR. I have tried to clean but for some reason it is not working, and I will go back to it.
The commits to be revised here are from Commits on Dec 16, 2025 - Sprint 2- Lookup.js
"d7ce32bf522dd240741bac5ce9bfc5cc6845e3ae"
thank you for yout time