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

London_10-Saliha_Popal-JavaScript-Core-2-Coursework-Week1#244

Open
SalihaPopal wants to merge 1 commit intoCodeYourFuture:mainfrom
SalihaPopal:main
Open

London_10-Saliha_Popal-JavaScript-Core-2-Coursework-Week1#244
SalihaPopal wants to merge 1 commit intoCodeYourFuture:mainfrom
SalihaPopal:main

Conversation

@SalihaPopal
Copy link

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?

@SalihaPopal SalihaPopal added the review requested I would like a mentor to review my PR label Mar 23, 2023
let dogName; // complete the code
let dogBreed; // complete the code
let dogName = "Spot"; // complete the code
let dogBreed = "Dalmatian"; // complete the code
Copy link

Choose a reason for hiding this comment

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

for these two you should access the dog object by doing dog.name or dog.breed


let myCountry = "UnitedKingdom";
let myCapitalCity; // complete the code
let myCapitalCity = "London"; // complete the code
Copy link

Choose a reason for hiding this comment

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

here you should use the alternate method of accessing object data, which would be capitalCities[myCountry]

@jxz12 jxz12 added the reviewed A mentor has reviewed this code label Mar 29, 2023

// write code here

console.log(basketballTeam.topPlayers)
Copy link

Choose a reason for hiding this comment

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

here you are expected to sort through this list of basketballTeam.topPlayers and then print each of the players on a new line. You can do that with array methods .sort() and .forEach()

console.log("Ingredients:");
for (let i = 0; i < recipe5.ingredients.length; i++) {
console.log(recipe5.ingredients[i]);
}
Copy link

Choose a reason for hiding this comment

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

you can avoid repeating yourself here by moving these console.log and for loop into another function which takes a recipe as an argument. e.g. function logRecipe(recipe) { ... }

words.forEach((word) => {

if(string == ""){
return wordCount
Copy link

Choose a reason for hiding this comment

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

there is no need to use return when using forEach because the return value is discarded anyway (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)

@jxz12
Copy link

jxz12 commented Mar 29, 2023

good work!

Copy link
Author

@SalihaPopal SalihaPopal left a comment

Choose a reason for hiding this comment

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

I learned some new and interesting refactor methods.

for (let i = 0; i < recipe1.ingredients.length; i++) {
console.log(recipe1.ingredients[i]);
}

Copy link
Author

Choose a reason for hiding this comment

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

.forEch() is also the best mothod.
recipe1.ingredients.forEach(ingredient) => {
console.log(ingredient);
}

return lookup
}
console.log(createLookup(COUNTRY_CURRENCY_CODES));

Copy link
Author

Choose a reason for hiding this comment

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

Or we can write the code as following:
function createLookup(countryCurrencyCodes) {
let currencyCodeLookup = {};

for (let countryCurrencyCode of countryCurrencyCodes) {
let countryCode = countryCurrencyCode[0];
let currencyCode = countryCurrencyCode[1];
currencyCodeLookup[countryCode] = currencyCode;
};

return currencyCodeLookup;
}

Copy link

Choose a reason for hiding this comment

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

I think your original solution is better, but this other solution is also nice and clear.

return balance;
}
}

Copy link
Author

Choose a reason for hiding this comment

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

const MENU = {
burger: 6.5,
falafel: 7.25,
};

let cashRegister = {
orderBurger: function(balance) {
let finalBalance = balance;
let isBalanceBigEnough = balance - MENU.burger >= 0;
if (isBalanceBigEnough) {
finalBalance = balance - MENU.burger;
}
return finalBalance;
},
orderFalafel: function(balance) {
let finalBalance = balance;
let isBalanceBigEnough = balance - MENU.falafel >= 0;
if (isBalanceBigEnough) {
finalBalance = balance - MENU.falafel;
}
return finalBalance;
},
};

Copy link

Choose a reason for hiding this comment

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

I like your original solution better here too

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

review requested I would like a mentor to review my PR reviewed A mentor has reviewed this code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants