Week5 Homework Submission#2
Open
wandrew8 wants to merge 15 commits into
Open
Conversation
t1mwillis
reviewed
Jun 10, 2020
| <Switch> | ||
| <Route exact path="/" component={Home} /> | ||
| <Route path="/hero/:heroId" component={Single} /> | ||
| <Route path="/favorites" component={Favorites} /> |
t1mwillis
reviewed
Jun 10, 2020
| } | ||
|
|
||
| // Many of the image links from the api are broken. This sets a default image source when image fails to load | ||
| addDefaultSrc = (e) => { |
t1mwillis
reviewed
Jun 10, 2020
|
|
||
| const renderAliases = () => { | ||
| const { aliases } = this.props.hero.biography; | ||
| if (aliases) { |
There was a problem hiding this comment.
Consider something like:
if (aliases.length > 1) {
[aliases.slice(0, aliases.length - 2).join(', '), aliases.slice(aliases.length - 2, aliases.length - 1)].join(' and ')
} else {
...aliases
}
I know that's kinda hard to read, but basically if the list larger than 1, take the last element and join the beginning elements with commas and append the last element with and.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Week 5 HW Submission
Please fill out the information below in order to complete your assignment. Feel free to update this comment later if necessary.
I used the superhero API for this assignment. You can find the deployed site at https://wandrew8.github.io/week5-assignment/#/ or run it from local with the following environment variables set in a .env file in the root menu:
REACT_APP_API_KEY=3036462383041704