Conversation
tekul
left a comment
There was a problem hiding this comment.
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() | ||
| ); | ||
| } |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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 | ||
| }; |
| var phoneBrand = phone.bbrand; | ||
| var phoneLaunchYear = phone[launchYear]; | ||
| var phoneBrand = phone.brand; | ||
| var phoneLaunchYear = phone["launchYear"]; |
There was a problem hiding this comment.
phone.launchYear is better (more standard) syntax.
|
|
||
| function getEmailAddresses(house1, house2) { | ||
| var emailAdress = [house1.currentOwner.email, house2.currentOwner.email]; | ||
| return emailAdress; |
There was a problem hiding this comment.
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; | ||
| } |
| }); // Complete here | ||
| function destinationByTrain(distance) { | ||
| return ( | ||
| distance.transportations.includes("train") && distance.distanceKms > 300 |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
This should be nameOfPerson since it only returns a single name.
| findAvailableRestaurants: function(numberOfPeople) { | ||
| return restaurants | ||
| .filter( | ||
| number => number.totalSeats - number.numberOfCustomers >= numberOfPeople |
There was a problem hiding this comment.
Why did you call this parameter number ?
| findRestaurantServingDish: function(dishName) { | ||
| // Complete here | ||
| return restaurants | ||
| .filter(dish => dish.menu.includes(dishName)) |
There was a problem hiding this comment.
Similar thing here. What kind of object is dish ? What would be a better name for the parameter?
No description provided.