-
-
Notifications
You must be signed in to change notification settings - Fork 219
London | 25-ITP-SEP | Shaghayegh Shirinfar | Sprint 2 | Sprint2 exersices #816
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
ckirby19
left a comment
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! Most of my comments are just extensions to test your knowledge :)
| // console.log(value); | ||
| // } | ||
|
|
||
| for (const value 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.
Just as an extension, what could you do instead if you wanted to console.log key:value together?
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.
for (const [key, value] of Object.entries(author)) {
console.log(${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.
Very good! Don't forget the brackets around the $ sign, console.log(${key}: ${value});
|
|
||
| // ${recipe.serves} → 2 | ||
|
|
||
| // ${recipe} → wrong! = > because recipe is an object, and when you interpolate it into a string, it becomes: |
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.
Just as an extension: in javascript every object will have a toString() method which is what is called here when we interpolate it as a string. This method can actually be modified directly so that you customise what happens when console.log is called on it. Could you show me how you would add this method to this object?
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.
recipe.toString = function () {
return ${this.title} serves ${this.serves}. Ingredients: ${this.ingredients.join(", ")};
};
console.log(String(recipe));
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.
Nice one, just missing the quotes as above
| // Loop through each pair in the array | ||
| for (let i = 0; i < pairs.length; i++) { | ||
| const pair = pairs[i]; // e.g. ['US', 'USD'] | ||
| const country = pair[0]; // first element is country code |
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.
As an extension: could you show me how you can use array destructuring to define country and currency in one line?
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.
const [country , currency] = pair[i];
|
|
||
| //invertedObj.key = value; → sets the literal property "key" instead of using the variable value as the | ||
|
|
||
| // e) Fix the implementation of invert (and write tests to prove it's fixed!) |
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.
Am I missing the tests and implementation fix somewhere? I don't see it
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.
sorry I forgot to do this part, I sort it out and I push my changes . thanks again
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, let me know when you add this and I will review it
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.
@ckirby19
Dear Conor ,
thank you for your time, I added the code and pushed it .
thanks again for all of your help and support.
Learners, PR Template
Self checklist
Changelist
In this exercise we were asked to change some parts in our functions and test files, i changed the codes where ever i was asked and then test them to make sure all of the test passes.