-
-
Notifications
You must be signed in to change notification settings - Fork 220
Sheffield | 25-ITP-Sep | Xiayidan Abuxuukuer | Sprint 2 | Coursework #874
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
Conversation
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. 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. |
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.
Reviewed
Note: Do not have the access to change the label, have request, change tomorrow.
| }; | ||
|
|
||
| for (const value of author) { | ||
| for (const value of of Object.values(author)) { |
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, however please note there are more cleaner ways to achieve this. Knowing those will definitely help in the future.
| @@ -1,3 +1,20 @@ | |||
| function contains() {} | |||
| function contains(obj, prop) { | |||
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 fulfils the requirements, now think of the below:
- What will happen if we inverse the
if conditioncheck. - What does
hasOwnPropertymethod return, do we need explicit return statement
This will help make this more better and less cluttered!
| for (let i = 0; i < pairs.length; i++){ | ||
|
|
||
| const country = pairs[i][0]; | ||
| const country = pairs[i][1]; |
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.
Maybe a typo here, country is a constant, can it be redeclared?
|
|
||
| const country = pairs[i][0]; | ||
| const country = pairs[i][1]; | ||
| lookup[country] = currency; |
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.
Does currency exist in the global and local scope?
|
|
||
| for (let i = 0; i < pairs.length; i++){ | ||
|
|
||
| const country = pairs[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.
There is cleaner way de-structuring of accessing the values, if we expect the array to have fixed number of items,
| for (let i = 0; i < keyValuePairs.length; i++){ | ||
| const pair = keyValuePairs[i]; | ||
| const indexOfEquals = pair.indexOf("="); | ||
| if(indexOfEquals === -1){ |
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.
Should we handle key with no value?
| function tally() {} | ||
| function tally(array) { | ||
|
|
||
| if (!Array.isArray(arr)) { |
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.
Maybe a typo, does arr exist?
| if (counts[item]) { | ||
|
|
||
| counts[item]= counts[item] + 1; | ||
| } | ||
| else { | ||
| counts[item]= 1; | ||
| } |
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 if we start at 0 when the key is undefined and then increment by 1 if exists. Will shorten the code for sure.
| // c) What does Object.entries return? Why is it needed in this program? | ||
| [["a", 1], ["b", 2]] | ||
|
|
||
| // d) Explain why the current return value is different from the target output |
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 asking why does the current invert function returns {key: 2} when { a: 1, b: 2 } is passed as argument. Shouldn't the function return {"1": "a", "2": "b"}?
| const invertedObj = {}; | ||
|
|
||
| for (const [key, value] of Object.entries(obj)) { | ||
| invertedObj.key = value; |
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 will create key key in the object invertedObj, is that our goal (make key to value and value to key).
Learners, PR Template
Self checklist
Changelist
Questions
none for now. Thanks.