Skip to content

Instantly share code, notes, and snippets.

View jccdev45's full-sized avatar
💖
What IS happening? I never know anymore.

Jordan Cruz-Correa jccdev45

💖
What IS happening? I never know anymore.
View GitHub Profile
@jccdev45
jccdev45 / Create.jsx
Created November 26, 2019 04:57
Update Avatar
updateAvatar(e) {
// Grab the name + value from the select
const target = e.target;
const { name, value } = target;
// Spread + destructure the options from state
const { options } = { ...this.state };
// Update the matching option with
// the value of the select and set state
const currentState = options;
currentState[name] = value;
@jccdev45
jccdev45 / Create.jsx
Created November 26, 2019 04:52
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("");