text: window.addEventListener("load", () => {
    let long;
    let lat;
    let temperatureDescription = document.querySelector(
      ".temperature-description"
    );
    let temperatureDegree = document.querySelector(".temperature-degree");
    let locationTimezone = document.querySelector(".location-timezone");
    const temperatureSection = document.querySelector(".temperature");
    const temperatureSpan = document.querySelector(".temperature span");
  
    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(position => {
        //console.log(position);
        long = position.coords.longitude;
        lat = position.coords.latitude;
  
        //proxy to solve cors issue with the api req
        const proxy = "https://cors-anywhere.herokuapp.com/";
        const api = `${proxy}https://api.darksky.net/forecast/0b39a5e6cc5d005b1dfbfb5120db47b5/${lat},${long}`;
        fetch(api)
          .then(response => {
            return response.json();
          })
          .then(data => {
            //console.log(data);
            const { temperature, summary, icon } = data.currently;
  
            //set DOM Elements from API
            temperatureDegree.textContent = temperature;
            temperatureDescription.textContent = summary;
            locationTimezone.textContent = data.timezone;
  
            //C to F conversion formula
            let celcius = (temperature - 32) * (5 / 9);
  
            //set Icon
            setIcons(icon, document.querySelector(".icon"));
  
            //change temp from F to C
            temperatureSection.addEventListener("click", () => {
              if (temperatureSpan.textContent === "°F") {
                temperatureSpan.textContent = "°C";
                temperatureDegree.textContent = Math.floor(celcius);
              } else {
                temperatureSpan.textContent = "°F";
                temperatureDegree.textContent = temperature;
              }
            });
          });
      });
    }
    /*else {
      const invalid = prompt("Please give permission to your location");
    }*/
  
    function setIcons(icon, iconID) {
      const skycons = new Skycons({ color: "white" });
      const currentIcon = icon.replace(/-/g, "_").toUpperCase();
      skycons.play();
      return skycons.set(iconID, Skycons[currentIcon]);
    }
  });
  