Skip to content

Instantly share code, notes, and snippets.

@MidasXIV
Created October 22, 2019 05:22
Show Gist options
  • Save MidasXIV/fa919b503c95d10f6d94f3d4a3aa39c3 to your computer and use it in GitHub Desktop.
Save MidasXIV/fa919b503c95d10f6d94f3d4a3aa39c3 to your computer and use it in GitHub Desktop.
let pokemon = {
"name": "Pikachu",
"id": 25,
"type": "electric",
"ability": {
"primary": "Static",
"hidden": "Lightning rod"
},
"moves": [
"Quick Attack", "Volt Tackle", "Iron Tail", "Thunderbolt"
],
"competative": {
"weakness": ["ground"],
"strengths": ["water", "flying"],
"resistances": ["electric", "flying", "water", "steel"]
}
};
const getWeakness = ({ competative: { weakness: isWeakTo } }) => {
return isWeakTo;
};
const getStrengths = ({ competative: { strengths: isStrongTo } }) => {
return isStrongTo;
}
const getResistances = ({ competative: { resistances: isResistantTo } }) => {
return isResistantTo;
}
const getMoves = ({ moves }) => {
return moves;
}
const stat = ({ name = 'NOT DEFINED', competative: { weakness } }) => {
return `${name} is weak to - ${weakness}`;
}
console.log(`Weakness :: ${getWeakness(pokemon)}`);
console.log(`Strengths :: ${getStrengths(pokemon)}`);
console.log(`Resistances :: ${getResistances(pokemon)}`);
console.log(`Moves :: ${getMoves(pokemon)}`);
console.log(stat(pokemon));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment