Skip to content

Instantly share code, notes, and snippets.

@jccdev45
Created November 26, 2019 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jccdev45/3ee7b0b066348c846b8d452bb170ab47 to your computer and use it in GitHub Desktop.
Save jccdev45/3ee7b0b066348c846b8d452bb170ab47 to your computer and use it in GitHub Desktop.
Display Avatar
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