Write a function to take pokemon’s name as argument and display the information of that pokemon | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Write a function to take pokemon’s name as argument and display the information of that pokemon

i am not able to finding any output ..please help

29th Jun 2018, 7:49 AM
ashwini prasad
ashwini prasad - avatar
4 Answers
+ 4
Please show your attempts.
29th Jun 2018, 7:55 AM
Hatsy Rei
Hatsy Rei - avatar
0
ok
29th Jun 2018, 8:13 AM
ashwini prasad
ashwini prasad - avatar
0
//json data var pokemonData= [{ "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" }]
29th Jun 2018, 8:19 AM
ashwini prasad
ashwini prasad - avatar
0
//my code var findPokemon=window.prompt("Input the name you want to find") for(x in pokemonData){   if ( pokemonData[x].name==findPokemon){ alert("id:"+pokemonData[x].id+"\n"+"Num:"+ pokemonData[x]['num']+"\n"+"Name:"+ pokemonData[x].name+"\n"+"Img:"+ pokemonData[x].img+"\n"+"type:"+ pokemonData[x].type+"\n"+"Height:"+ pokemonData[x].height+"\n"+"Weight:"+ pokemonData[x]['weight']+"\n"+"Candy:"+pokemonData[x]['candy']+"\n"+"Candy_count:"+ pokemonData[x]['candy_count']+"\n"+"Egg:"+ pokemonData[x]['egg']+"\n"+"Spawn_chance:"+ pokemonData[x]['spawn_time']+"\n"+ "Avg_spawns:"+pokemonData[x]['avg_spawns']+"\n"+"Spawn_time:+"pokemonData[x]['spawn_time']+"\n"+"Multipliers:" pokemonData[x]['multipliers']+"\n"+ "Weaknesses:" pokemonData[x]['weaknesses']) alert("Next_evolution:"+"\n" "num:" pokemonData[x].next_evolution[0].num+"\n"+ "name:"+pokemonData[x].next_evolution[0].name+"\n"+"num:"+pokemonData[x].next_evolution[1].num+"\n"+"name:"+pokemonData[x].next_evolution[1].name)   } }
29th Jun 2018, 8:19 AM
ashwini prasad
ashwini prasad - avatar