function uvIndexDetails(lat, lon) {
  var requestUrl = "https://api.openweathermap.org/data/2.5/uvi?lat=" + lat + "&lon=" + lon + "&appid=" + key;

  fetch(requestUrl)
    .then(function (response) {
      return response.json();
    })
    .then(function (data) {
      let markEl = document.createElement("mark");
      $(".uv-index").html("UV Index: ");
      markEl.textContent = data.value;
      if (data.value >= 3 && data.value <= 5) {
        //yellow = #FFFF00
        markEl.setAttribute("style", "background-color: #FFFF00");
      } else if (data.value >= 6 && data.value <= 7) {
        //orange = #FFA500
        markEl.setAttribute("style", "background-color: #FFA500");
      } else if (data.value >= 8 && data.value <= 10) {
        //red = #FF0000
        markEl.setAttribute("style", "background-color: #FF0000");
      } else {
        //violet = #EE82EE
        markEl.setAttribute("style", "background-color: #EE82EE");
      }
      $(".uv-index").append(markEl);
    });
}
//Function call to get the uv index values based on latitude and logitude
Function call to get the uv index values based on latitude and logitude
Function call to get the uv index values based on latitude and logitude
function uvIndexDetails(lat, lon) {
  var requestUrl = "https://api.openweathermap.org/data/2.5/uvi?lat=" + lat + "&lon=" + lon + "&appid=" + key;
  fetch(requestUrl)
    .then(function (response) {
      return response.json();
    })
    .then(function (data) {
      let markEl = document.createElement("mark");
      $(".uv-index").html("UV Index: ");
      markEl.textContent = data.value;
      if (data.value >= 3 && data.value <= 5) {
        markEl.setAttribute("style", "background-color: #FFFF00");
      } else if (data.value >= 6 && data.value <= 7) {
        markEl.setAttribute("style", "background-color: #FFA500");
      } else if (data.value >= 8 && data.value <= 10) {
        markEl.setAttribute("style", "background-color: #FF0000");
      } else {
        markEl.setAttribute("style", "background-color: #EE82EE");
      }
      $(".uv-index").append(markEl);
    });
}
function uvIndexDetails ( lat , lon ) { var requestUrl = "https://api.openweathermap.org/data/2.5/uvi?lat=" + lat + "&lon=" + lon + "&appid=" + key ; fetch ( requestUrl ) . then ( function ( response ) { return response . json ( ) ; } ) . then ( function ( data ) { let markEl = document . createElement ( "mark" ) ; $ ( ".uv-index" ) . html ( "UV Index: " ) ; markEl . textContent = data . value ; if ( data . value >= 3 && data . value <= 5 ) { markEl . setAttribute ( "style" , "background-color: #FFFF00" ) ; } else if ( data . value >= 6 && data . value <= 7 ) { markEl . setAttribute ( "style" , "background-color: #FFA500" ) ; } else if ( data . value >= 8 && data . value <= 10 ) { markEl . setAttribute ( "style" , "background-color: #FF0000" ) ; } else { markEl . setAttribute ( "style" , "background-color: #EE82EE" ) ; } $ ( ".uv-index" ) . append ( markEl ) ; } ) ; }
Function call to get the uv index values based on latitude and logitude
Function call to get the uv index values based on latitude and logitude
//yellow = #FFFF00 //orange = #FFA500 //red = #FF0000 //violet = #EE82EE