I'm working on an assignment and I have to make a weather app that has a changing background image on the weather in each city. I'm using the OpenWeatherMap API and I have this code for the images so far
var clearsky = new Image();
clearsky.src = "clearsky.jfif";
var clouds = new Image();
clouds.src = "fewclouds.jfif";
var fog = new Image();
fog.src = "fog.jpg";
var rain = new Image();
rain.src = "moderaterain.jpg";
var overcast = new Image();
overcast.src = "overcast.jpg";
var snow = new Image();
snow.src = "snow.jfif";
I don't know how to link the images to the weather description from the API. This is what my page looks like example of the web page that needs image background so ideally, the overcast image from my code would be displayed in the bg there since the weather description is "overcast clouds"
If I understood correctly, then you need use HasMap. For example:
HashMap<String, Image> hashMap = new HashMap();
hashMap.put("overcastClouds", overcast)