Skip to content

Completed Week 4 Exercises#55

Open
Blaiselubuma wants to merge 6 commits intorarmatei:masterfrom
Blaiselubuma:week-4
Open

Completed Week 4 Exercises#55
Blaiselubuma wants to merge 6 commits intorarmatei:masterfrom
Blaiselubuma:week-4

Conversation

@Blaiselubuma
Copy link

No description provided.

Copy link
Collaborator

@tekul tekul left a comment

Choose a reason for hiding this comment

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

Good work 👍 . Be careful with naming. Parameters and variables should be named to match the data they represent (the object in these examples - person, destination, restaurant etc). Use plural names for lists of objects and singular names for single objects. If you name them after the field you are looking up, then the code will be confusing for people to read.

console.log(
(writers[i].firstName + " " + writers[i].lastName).toUpperCase()
);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Try to stick to the array methods we have taught (foreach, map, filter etc), rather than using for loops and explicitly indexing into the array.

bottle.drink();
bottle.drink();
bottle.drink();
bottle.drink();
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you are just messing about, then it's fine to add things like this, but try to make sure your submitted code matches the expected result ("70" in this case).

team: "Real Madrid",
country: "Spain",
isQualifiedChampionsLeague: false
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

var phoneBrand = phone.bbrand;
var phoneLaunchYear = phone[launchYear];
var phoneBrand = phone.brand;
var phoneLaunchYear = phone["launchYear"];
Copy link
Collaborator

Choose a reason for hiding this comment

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

phone.launchYear is better (more standard) syntax.


function getEmailAddresses(house1, house2) {
var emailAdress = [house1.currentOwner.email, house2.currentOwner.email];
return emailAdress;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Try not to use singular names for things which are lists/arrays (and vice versa). Since this is an array of addresses, it would be better named emailAddresses. For such a small function though, I'd probably skip the use of a variable and just return the array directly.

return "Please take your " + coffee;
}
return "Sorry you don't have enough money for a " + coffee;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

}); // Complete here
function destinationByTrain(distance) {
return (
distance.transportations.includes("train") && distance.distanceKms > 300
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is good 👍 . But why name the parameter here distance ? What does it actually represent? Similarly for ferry above. The function is not just checking whether the destination can be reached by train, so its name is also slightly misleading.

Also try to leave some blank space between your function and variable declarations to make the code easier to read.

var personNames = // Complete here

var personsYoungerThan28YearsOld = // Complete here
function namesOfPerson(person) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be nameOfPerson since it only returns a single name.

findAvailableRestaurants: function(numberOfPeople) {
return restaurants
.filter(
number => number.totalSeats - number.numberOfCustomers >= numberOfPeople
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did you call this parameter number ?

findRestaurantServingDish: function(dishName) {
// Complete here
return restaurants
.filter(dish => dish.menu.includes(dishName))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar thing here. What kind of object is dish ? What would be a better name for the parameter?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants