Created
November 26, 2019 04:52
-
-
Save jccdev45/3ee7b0b066348c846b8d452bb170ab47 to your computer and use it in GitHub Desktop.
Display Avatar
This file contains 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
displayAvatar() { | |
// Object.keys / values creates an array | |
const keys = Object.keys(this.state.options); | |
const values = Object.values(this.state.options); | |
// Map through the keys array and pair each result with | |
// the matching index of the values array, adding in | |
// necessary symbols where | |
const keyValue = keys.map((e, i) => e + "=" + values[i] + "&"); | |
// Use .join('') to convert into a string | |
const joined = keyValue.join(""); | |
this.setState({ | |
// Set the avatar URL in state to the new result | |
avatar: this.state.avatar + joined | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment