North-West 4-Anza-Azam- JS2-Module-week1 (Mandatory exercises) #93
North-West 4-Anza-Azam- JS2-Module-week1 (Mandatory exercises) #93Anza-Azam wants to merge 20 commits into
Conversation
| "Writer {firstName} {lastName} died at {age} years old." | ||
| */ | ||
| const ageLowerLimit = 40, | ||
| ageHigherLimit = 49; |
There was a problem hiding this comment.
Good reuse of values in both methods.
| for (i = 0; i < mealArray.length; i++) { | ||
| numberOfChoice.push(mealArray[i].price) | ||
| } | ||
| numberOfChoice.sort((a, b) => a - b) |
There was a problem hiding this comment.
You can do the sort using the whole objects, you can use a.price and b.price in your comparison
| let chosenMeal = [] | ||
| mealArray.forEach(element => { | ||
| if (element.price === numberOfChoice[1]) chosenMeal.push(element.name) | ||
| }) |
There was a problem hiding this comment.
If you sort the whole objects, then you can use .name on the second object in the sorted array.
| this.currentRoom = this.currentRoom.north() | ||
| else if (direction === 'south' && this.currentRoom.south()) | ||
| this.currentRoom = this.currentRoom.south() | ||
| } |
There was a problem hiding this comment.
You can make this simpler by using currentRoom[direction] - this is quite advanced, so don't worry if you can't do it. Maybe see if any other students have done it, but I think they've not all done the advanced questions.
|
|
||
| return attendances | ||
| .filter(element => element.attendance >= passingMarksThreshold) | ||
| .map(element => element.name) |
There was a problem hiding this comment.
Maybe use "student" rather than "element" to make your code more readable
| const location = Object.keys(locations) | ||
| const specificLocations = [] | ||
| location.forEach(element => { if(locations[element].includes(transportMode)) | ||
| specificLocations.push(element) |
| // calling this function should decrease your bottle volume by 10 units; | ||
| if (this.volume >= 10) | ||
| // calling this function should decrease your bottle volume by 10 units; | ||
| return (this.volume -= 10) |
There was a problem hiding this comment.
You don't need to return a value for fillUp, pour or drink.
| numberOfItems.forEach( | ||
| (element, index) => | ||
| (numberOfItemsPerWeek[element] = numberOfGroceryItems[index]) | ||
| ) |
There was a problem hiding this comment.
If you use Object.entries rather than Object.keys, you can have access to the key and value and only do one iteration.
| console.log(`${element}`) | ||
| }) | ||
| } | ||
| } |
There was a problem hiding this comment.
You should't be using a get method to set the properties. You need to create some hardcoded recipes, in the same format as the "recipe" example, and then you code simply needs to get and output the properties
| for (let i = 0; i < element.colleagues.length; i++) | ||
| isColleague = element.colleagues.some( | ||
| element => element.name === 'Stacie Villarreal' | ||
| ) |
There was a problem hiding this comment.
You could this by passing a function into .filter.
|
Your coursework submission has been closed because nobody has interacted with it in six weeks. You are welcome to re-open it to get more feedback. |
Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in
HOW_TO_MARK.mdin the root of this repositoryYour Details
Homework Details
Notes
objects
looping through array of objects for specific key value pair