I want to display a background image in the background depending on the current weather condition.When I write the following lines in my javascript the code seems to fail:
if(ftemp>=0){
document.body.style.backgroundImage =
"url('https://images.pexels.com/photos/412462/pexels-photo-412462.jpeg?w=940&h=650&auto=compress&cs=tinysrgb')";
}
I am getting the data(ftemp) from an API call and using the condition statement displaying the respective background image. I tried running just this
document.body.style.backgroundImage =
"url('https://images.pexels.com/photos/412462/pexels-photo-412462.jpeg?w=940&h=650&auto=compress&cs=tinysrgb')";
and the code runs.I believe that there is some problem with the if statement. Here is the link to my work if it helps: https://codepen.io/ryoko1/pen/eRvxKb?editors=0110 Thanks.