chore(02): correction step 2 - algorithmics#4
chore(02): correction step 2 - algorithmics#4fabernovel-fnguyen wants to merge 1 commit into02_algorithmicsfrom
Conversation
| this.httpClient | ||
| .get(`type/${pokemonType}`) | ||
| .then( | ||
| (response) => response.body as unknown as GetPokemonTypeResponse, |
There was a problem hiding this comment.
Pour éviter le as unknown as GetPokemonTypeResponse ici, on peut mettre le type dans le .get 🙂
const pokemonWithCommonTypes = await Promise.all(
types.map((pokemonType) =>
this.httpClient
.get<GetPokemonTypeResponse>(`type/${pokemonType}`)
.then((response) => response.body),
),
);et on peut extraire le body directement dans le then 🙂
.then(({ body }) => body),|
|
||
| type GetPokemonTypeResponse = { | ||
| pokemon: { | ||
| pokemon: { |
There was a problem hiding this comment.
Question: Pourquoi pokemon dans pokemon ? 🤔 Est-ce qu'on ne peut pas faire autrement ? 🤔
Ce serait bien si on pouvait avoir:
type GetPokemonTypeResponse = {
pokemon: {
name: string;
url: string;
}[];
};Si on change dans cette PR, il faudra modifier aussi dans l'énoncé de la 1ère PR d'algo 🙂
| ); | ||
|
|
||
| // Step 2: Remove any non-first generation pokemon from the array of pokemons | ||
| const firstGenerationPokemons = pokemonWithCommonTypes.map(({ pokemon }) => |
There was a problem hiding this comment.
Might have: On pourrait remplacer le map par un flatMap ici, pour éviter de faire le flat plus bas 🙂
| const numberOfSameTypePokemons = sameTypePokemonStats.length; | ||
|
|
||
| return sameTypePokemonStats.reduce( | ||
| (acc: PokemonStats, pokemon) => ({ |
There was a problem hiding this comment.
là aussi, on peut extraire stats de pokemon pour réduire le nombre de pokemon.stats. plus bas 🙂
(acc: PokemonStats, { stats }) => ({
cec1faa to
961ffb9
Compare
c812232 to
161b29f
Compare
961ffb9 to
bd2e04c
Compare
161b29f to
777c56f
Compare
bd2e04c to
3475f96
Compare
777c56f to
555c4d4
Compare
3475f96 to
3593cf1
Compare
555c4d4 to
fa33dfa
Compare
No description provided.