xxxxxxxxxx
31
let cityWeather; //variable for json object
//use the preload function to load the json into the variable
function preload(){
//change the city at the end of the url, no spaces
cityWeather = loadJSON("https://goweather.herokuapp.com/weather/chicago")
}
//the setup function runs one time
function setup() {
createCanvas(400, 400)
noLoop();
}
function draw() {
background('white') //canvas background color
fill('lightblue')
rect(0,100,width,200) //blue area
textSize(20);
textWrap(WORD);
textFont('Georgia');
fill('black')
text("Chicago",width/2-30,30)
text("Temp: "+cityWeather.temperature,width/2-50,50)
//add other information from the weather object to the screen
}