London | 25-ITP-Sept | Gislaine Della Bella | Sprint 2 | Sprint 2 -Final#933
London | 25-ITP-Sept | Gislaine Della Bella | Sprint 2 | Sprint 2 -Final#933Della-Bella wants to merge 12 commits intoCodeYourFuture:mainfrom
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
i ffor...of loop would work better there.
| expect(parseQueryString("equation=x=y+1")).toEqual({ equation: "x=y+1" }); | ||
| }); | ||
|
|
||
| // Special characters |
| // 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.
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.
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.
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