// const fetchPokemon = async (id) => {
// const response = await fetch(`https://pokeapi.co/api/v2/pokemon/${id}`);
// if (!response.ok) {
// throw new Error(`Network response was not ok: ${response.statusText}`);
// }
// const data = await response.json();
// return data;
// };
 
// const getStarterPokemon = () => {
// const ids = [1, 2, 3]
// const pokemon = [];
 
// ids.forEach(async (id) => {
// const result = await fetchPokemon(id);
// pokemon.push(result);
// });
 
// return pokemon
// }
// let poc = getStarterPokemon();
// console.log(poc);
 
 
const fetchPokemon = async (id) => {
const response = await fetch(`https://pokeapi.co/api/v2/pokemon/${id}`);
if (!response.ok) {
throw new Error(`Network response was not ok: ${response.statusText}`);
}
const data = await response.json();
return data;
};
 
const getStarterPokemon = async () => {
const ids = [1, 2, 3]
const pokemon = [];
 
for (const id of ids) {
const result = await fetchPokemon(id);
pokemon.push(result);
};
 
return pokemon
}
 
await getStarterPokemon()
 
Click Run to execute JavaScript.
Code runs in an isolated environment.