We'll be exploring a 2D Array to see how that feels before we start using them in a bigger app.
- You'll be running
jest --watch-all
, but working in two separate files, one per function. Each one has a corresponding test file you can check out to see how each test is working. - Don't forget to check out the
pokemon.js
file to see what our data looks like! - And this README looks a LOT better on GitHub, so check it out there.
You'll only need two functions to pass these tests.
getRow
- given a string, looks through thepokemon
array and returns the sub-array that contains it
getRow('pikachu') //-> ['pikachu', 'https://pokeapi.co/api/v2/pokemon/25/']
getRow('charmander') //-> ['charmander', 'https://pokeapi.co/api/v2/pokemon/4/']
getUrl
- given a row sub-array (like the example outputs above), returns the URL from it.
getUrl(['pikachu', 'https://pokeapi.co/api/v2/pokemon/25/']) //-> 'https://pokeapi.co/api/v2/pokemon/4/'
getUrl(['charmander', 'https://pokeapi.co/api/v2/pokemon/4/']) //-> 'https://pokeapi.co/api/v2/pokemon/4/'
- Pay careful attention to what type of data your inputs and outputs are supposed to be!
- Also important:
getRow
will need to pull in thepokemon
data frompokemon.js
. That's our "database"!