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

North-West 4-Anza-Azam- JS2-Module-week1 (Mandatory exercises) #93

Closed
Anza-Azam wants to merge 20 commits into
CodeYourFuture:mainfrom
Anza-Azam:main
Closed

North-West 4-Anza-Azam- JS2-Module-week1 (Mandatory exercises) #93
Anza-Azam wants to merge 20 commits into
CodeYourFuture:mainfrom
Anza-Azam:main

Conversation

@Anza-Azam
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: Anza Azam
  • Your City: Northwest 4
  • Your Slack Name: Anza Azam

Homework Details

  • Module: JS core2
  • Week:1

Notes

  • What did you find easy?
    objects
  • What did you find hard?
    looping through array of objects for specific key value pair
  • What do you still not understand?
  • Any other notes?

Comment thread mandatory/1-writers.js
"Writer {firstName} {lastName} died at {age} years old."
*/
const ageLowerLimit = 40,
ageHigherLimit = 49;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good reuse of values in both methods.

Comment thread mandatory/10-cheap-diner.js Outdated
for (i = 0; i < mealArray.length; i++) {
numberOfChoice.push(mealArray[i].price)
}
numberOfChoice.sort((a, b) => a - b)
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 can do the sort using the whole objects, you can use a.price and b.price in your comparison

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

Comment thread mandatory/10-cheap-diner.js Outdated
let chosenMeal = []
mealArray.forEach(element => {
if (element.price === numberOfChoice[1]) chosenMeal.push(element.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.

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()
}
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 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.

Comment thread mandatory/2-eligible-students.js Outdated

return attendances
.filter(element => element.attendance >= passingMarksThreshold)
.map(element => element.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.

Maybe use "student" rather than "element" to make your code more readable

Comment thread mandatory/3-journey-planner.js Outdated
const location = Object.keys(locations)
const specificLocations = []
location.forEach(element => { if(locations[element].includes(transportMode))
specificLocations.push(element)
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 could use .filter here

Comment thread mandatory/4-water-bottle.js Outdated
// 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)
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 don't need to return a value for fillUp, pour or drink.

Comment thread mandatory/5-groceries.js Outdated
numberOfItems.forEach(
(element, index) =>
(numberOfItemsPerWeek[element] = numberOfGroceryItems[index])
)
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 use Object.entries rather than Object.keys, you can have access to the key and value and only do one iteration.

Comment thread mandatory/7-recipes.js Outdated
console.log(`${element}`)
})
}
}
Copy link
Copy Markdown

@KarenPudner KarenPudner Jul 23, 2021

Choose a reason for hiding this comment

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

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

Comment thread mandatory/6-people-I-know.js Outdated
for (let i = 0; i < element.colleagues.length; i++)
isColleague = element.colleagues.some(
element => element.name === 'Stacie Villarreal'
)
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 could this by passing a function into .filter.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Sep 5, 2021

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.

@github-actions github-actions Bot added the Stale label Sep 5, 2021
@github-actions github-actions Bot closed this Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants