Skip to content

Instantly share code, notes, and snippets.

@mornir mornir/challenge-1.js

Last active Jan 3, 2020
Embed
What would you like to do?
GROQ Pokédex Challenges
// Find the weakest Pokémon overall
*[]{
"overall": base.HP + base.Attack + base.Defense + base["Sp. Attack"] + base["Sp. Defense"] + base.Speed,
"name": name.english,
}|order(overall)[0]
// Return an array containing all and only the Pokémon names
*[].name.english
// Return counts for grass, fire and water types
{
"Grass": count(*["Grass" in type]),
"Fire": count(*["Fire" in type]),
"Water": count(*["Water" in type]),
}
// Return all water type Pokémon
*['Water' in type && length(type) == 1]{
id,
"name": name.english,
base
}|order(base.HP desc)
// Return the percentage of single type Pokémon
{
"percentage": count(*[length(type) == 1]) * 100 / count(*[])
}
// List the Pokémon based on the number of letters in their English name
*[]{
"name": name.english,
"length": length(name.english)
}|order(length desc)
// Group the Pokémon in three categories
*[]|order(base.Attack){
"name": name.english,
"attack": base.Attack,
"evaluation": select(
base.Attack > 124 => "strong",
base.Attack > 83 => "average",
"weak"
)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.