Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completed homework #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sad3xoxo
Copy link

yay

Comment on lines +110 to +111
const presidentialParties = presidents.map(presidentObj => presidentObj.party)
console.log(presidentialParties)
Copy link

@Tech-J Tech-J Oct 13, 2019

Choose a reason for hiding this comment

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

@sad3xoxo Good Job here using the map function to return only the president's party names.

Take a look at this approach here

Comment on lines +74 to +81
// Get a list of presidents whos first name is James
const presidentsNamedJames = presidents.filter(presidentObj => {
// presidentObj.president.split(' ') is the president name split into an array
// first name is stored at [0] index
return presidentObj.president.split(' ')[0] === 'James'
})

console.log(presidentsNamedJames)
Copy link

Choose a reason for hiding this comment

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

@sad3xoxo Great work here using the filter method, splitting each president's name to and returning the first name that starts with James.

Take a look at this approach here

Comment on lines +46 to +50
// find the first president that was a member of the party named Whig
const firstWhigPresident = presidents.find(selectedPresidentObj => selectedPresidentObj.party === 'Whig')
// print to console
console.log(firstWhigPresident.president)

Copy link

Choose a reason for hiding this comment

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

@sad3xoxo Great work here on this solution using the find method to return the first president of the whig party.

Take a look at this solution here

Comment on lines +135 to +141
const presidentsBetween1850and1900 = presidents.filter(presidentObj => {
// presidentObj.took_office.split('-')[0] = year the president took office
return (presidentObj.took_office.split('-')[0] > 1850) & (presidentObj.took_office.split('-')[0] < 1900)
})

// print to console
console.log(presidentsBetween1850and1900)
Copy link

Choose a reason for hiding this comment

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

@sad3xoxo Good Job here using the filter method on this solution and returning the presidents between 1850 and 1900. Good work splitting the took_office and returning the value if it is greater than 1850 & less than 1900.

Take a loop at this approach here

Comment on lines +166 to +169
const livingPresidents = presidents.filter(presidentObj => presidentObj.death_year === null)

// print to console
console.log(livingPresidents)
Copy link

Choose a reason for hiding this comment

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

@sad3xoxo Good job here using the filter method to find all the president's whose death year equal null.

Take a look at this approach here

Comment on lines +224 to +237
const shortTermPresidents = presidents.filter(presidentObj => {
if (presidentObj.left_office === null) {
// if the president never left office, calculate based off the cufrent year (2019)
return (2019 - presidentObj.took_office.split('-')[0]) < 4
} else {
// below line calculates the year the president took office minus
// the year the president left office and retuns the object if the Result
// is less than 4
return (presidentObj.left_office.split('-')[0] - presidentObj.took_office.split('-')[0]) < 4
}
})

// print to console
console.log(shortTermPresidents)
Copy link

Choose a reason for hiding this comment

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

@sad3xoxo Good work here on this problem using the filter method. Good job utilizing the conditional to determine the outcomes for the current president and past presidents

Take a look at this approach here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants