Я не могу выполнить приведенный ниже код, так как он не возвращает вывод при вводе данных.
var pokemongo= { "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" ] }] }; var pokeinfo=function(name) { var isfound=false; for(x in pokemongo){ if(pokemongo[x]['name']==name){ isfound=true; break; } else{ isfound=false; } }// end of for in loop if(isfound==true){ alert(pokemongo.pokemon[x]) } else{ alert(" info not available ") } } var name=prompt('Enter the name of pokemon') pokeinfo(name)
Что я уже пробовал:
<pre>var pokemongo= { "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" ] }] }; var pokeinfo=function(name) { var isfound=false; for(x in pokemongo){ if(pokemongo[x]['name']==name){ isfound=true; break; } else{ isfound=false; } }// end of for in loop if(isfound==true){ alert(pokemongo.pokemon[x]) } else{ alert(" info not available ") } } var name=prompt('Enter the name of pokemon') pokeinfo(name)