var pokemonName = window.prompt("Enter the pokemon details")
var pokemon = [{
"id": 1,
"num": "001",
"name": "Bulbasaur",
"img": "http://www.serebii.net/pokemongo/pokemon/001.png",
"type": [
"Grass",
"Poison"
],
"height": "0.71 m",
"weight": "6.9 kg",
"candy": "Bulbasaur Candy",
"candy_count": 25,
"egg": "2 km",
"spawn_chance": 0.69,
"avg_spawns": 69,
"spawn_time": "20:00",
"multipliers": [1.58],
"weaknesses": [
"Fire",
"Ice",
"Flying",
"Psychic"
],
"next_evolution": [{
"num": "002",
"name": "Ivysaur"
}, {
"num": "003",
"name": "Venusaur"
}]
}, {
"id": 2,
"num": "002",
"name": "Ivysaur",
"img": "http://www.serebii.net/pokemongo/pokemon/002.png",
"type": [
"Grass",
"Poison"
],
"height": "0.99 m",
"weight": "13.0 kg",
"candy": "Bulbasaur Candy",
"candy_count": 100,
"egg": "Not in Eggs",
"spawn_chance": 0.042,
"avg_spawns": 4.2,
"spawn_time": "07:00",
"multipliers": [
1.2,
1.6
],
"weaknesses": [
"Fire",
"Ice",
"Flying",
"Psychic"
],
"prev_evolution": [{
"num": "001",
"name": "Bulbasaur"
}],
"next_evolution": [{
"num": "003",
"name": "Venusaur"
}]
}]
function pokemonDetails(name) {
for (var i = 0; i <= pokemon.length; i++) {
if (name == pokemon[i].name) {
y = pokemon[i]
for (var x in y) {
console.log(x + " = " + y[x] + "\n")
}
}
}
}
pokemonDetails(pokemonName);
我正在尝试获取 pokemon 详细信息,但无法使用上述代码获取 next_evolution 和 pre_evolution 详细信息,因此代码应该是我必须在警报窗口提示中提供 pokemon 名称。该函数将检查口袋妖怪的名称,它应该提供该口袋妖怪的全部细节,包括它是否包含下一次进化和以前的进化细节,任何人都可以帮我解决这个问题.... 输出上述代码