Quick question on my weather project

Project Link - http://codepen.io/codejsp/pen/YNxBmg
for

var weatherType = data.weather[0].description;

Why do i need that [0]? It wouldn’t work without it.

Always console.log(json_data). You will see that data.weather is an array that contains one object.

ahhh, i get it.
so for everything inside { } is considered 1 object?

"weather": [
{
"id": 500,
"main": "Rain",
"description": "light rain",
"icon": "10n"
}
]

Yes, that is correct.

thank you again :grinning:

1 Like