Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

493
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda