Help with weather api project

Help with weather api project


When calling the weather type from api, why do I have to use the array of 0?

var api =“”;
var weatherType =[0].main;

Instead of

var weatherType =;


Because the weather property has a value of an array that encloses the object, and to get the contents of an array you have to refer to the indices of an array. Your example (var weatherType = would work if the weather property had an object value that was not enclosed in an array, i.e. if you had

data = {
id: 800,
main: "Clear",
description: "clear sky",
icon: ""