Weather App - Description Not Displaying

Weather App - Description Not Displaying
0

#1

I’ve had some luck lately with my weather app with being able to actually have some of the JSON data show up on the screen. Right now, I’m having trouble getting the weather description to display. It’s an array in the JSON object, so I know I need to access it a certain way, but it seems like all of my methods either return “undefined” or nothing. Not going to lie, it’s a little annoying. :unamused:

Here’s my codepen - it’s not much at the moment since I’m still getting things to show up on screen, but it’s something. http://codepen.io/Qwicksilver/pen/kkZBrj?editors=1010


#2

Hi,

You need to specify an index in the weather since it is an array, example below:

console.log(json.weather[0].description);

so to display you’re weather description you need to use loop, example below:

for (i = 0; i < json.weather.length; i++) { 
        $("#description").html("<p class='text-center>" + json.weather[i].description + "</p>");
}

Hope this helps…


#3

Yes! That did it! Thank you! That was driving me crazy for a while! :joy: