Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

488
Views
Change the background image based on data from api (javascript)

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"

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If I understood correctly, then you need use HasMap. For example:

HashMap<String, Image> hashMap = new HashMap();
hashMap.put("overcastClouds", overcast)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!