Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.

London 9-Lovelace-Yigit Senoglu- JavaScript-Core-2-Coursework-Week1 - #188

Open
ys35code wants to merge 12 commits into
CodeYourFuture:mainfrom
ys35code:main
Open

London 9-Lovelace-Yigit Senoglu- JavaScript-Core-2-Coursework-Week1 #188
ys35code wants to merge 12 commits into
CodeYourFuture:mainfrom
ys35code:main

Conversation

@ys35code

@ys35code ys35code commented Jan 5, 2023

Copy link
Copy Markdown

Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in HOW_TO_MARK.md in the root of this repository

Your Details

  • Your Name:
  • Your City:
  • Your Slack Name:

Homework Details

  • Module:
  • Week:

Notes

  • What did you find easy?

  • What did you find hard?

  • What do you still not understand?

  • Any other notes?

@maxf maxf left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. You've got this.
At this point, the comments I put are "extras" in order to make the code even better, but they don't matter so much as you've got the main questions almost perfect.
Just one thing: don't forget to complete the README

UnitedKingdom: "London",
China: "Beijing",
Peru: "Lima"
Peru: "Lima",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While trailing commas don't make a difference to your object definition, they have their pros and cons. In the end it's often down to the JS style guide your project will use, but it's good to understand the consequences

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here (and below) for instance, you probably don't want to add them, because not only they weren't there in the first place and there's probably a reason, but more importantly they introduce changes in your PR that aren't related to what the PR is about. So it makes the "diff" longer by adding unrelated changes.

// write code here
}
getName: function (name) {
console.log("Student name: " + "" + name);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slightly better to use string interpolation here

Comment thread 2-mandatory/1-recipes.js
};

console.log(cake.title);
console.log("Serves:" + " " + cake.servings);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, string interpolation is preferred. It's more readable.

Comment thread 2-mandatory/1-recipes.js
console.log("Serves:" + " " + cake.servings);
console.log("Ingredients:" + " " + cake.ingredients.join(", "));

let yogurt = {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're not going to change your object, use const. It's a good habit to have and leads to safer code

function createLookup(countryCurrencyCodes) {
// write code here
const lookup = {};
for (const [country, currency] of countryCurrencyCodes) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one. Object.fromEntries is a nice little function you can also use here.


let players = basketballTeam.topPlayers;
players.sort();
players.forEach(function (topPlayers) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works as intended, but 2 small things:

  • the name of the parameter topPlayers is misnamed. It will contain the name of a single player. So it's better names topPlayer or player or playerName. It's important (maybe not here, but in more complex code) to use variable and parameter names that reflect as precisely as possible what they're going to contain.
  • you can use the arrow notation to make your code shorter and easier to read

function createShoppingList(recipe) {
// write code here
const shoppingList = { name: recipe.name, items: [] };
for (const ingredient of recipe.ingredients) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you run the tests? ingredient will change at each iteration so using const will give you an error

Comment on lines +55 to +62
ingredients: [
"flour",
"salt",
"yeast",
"tinned tomatoes",
"oregano",
"mozarella",
],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know what I'm going to say here :)
Try not to change the parts of the code you're not asked to change to keep the commits focused on the task at hand, and not formatting changes for the code you're given.
If you think that code needs to be changed for readability (and in this case I agree) do it in a separate commit labeled "code cleanup" or something like that. And make a real PR so that the source repository gets fixed!

@ellietms ellietms added the reviewed A mentor has reviewed this code label Jan 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

reviewed A mentor has reviewed this code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants