title: How to return the coordinates of a getLocation function, return latitude and longitude
body: <p>I am attempting to build a weather API using the freeCodeCamp API for the weather project.</p>
  
  <p>What I want to do is use the getLocation function to get the latitude and longitude and then return them as a variables that I can use to then concat to a URL.
  By using the URL I can obtain the json information I need to output the Fahrenheit and any other info I need.
  Since I require an https connection I am using codepen for testing purposes. </p>
  
  <p>additional info:
      <br>Codepen:
      <a href="https://codepen.io/rogercodes/pen/gXvOoO" rel="nofollow noreferrer">https://codepen.io/rogercodes/pen/gXvOoO</a>
      <br>freeCodeCamp API:
      <a href="https://fcc-weather-api.glitch.me/" rel="nofollow noreferrer">https://fcc-weather-api.glitch.me/</a></p>
  
  <p>HTML</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  
    &lt;!-- &lt;link rel="stylesheet" type="text/css" 
  href="css/quoteStyles.css"&gt; --&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;button onclick="getWeather(finalLat,finalLon)"&gt;getWeather&lt;/button&gt;
  &lt;p&gt;What is&lt;/p&gt;
  
  &lt;button onclick="getLocation()"&gt;Try It&lt;/button&gt;
  
  
  &lt;p id='geoAPI'&gt;Geo API&lt;/p&gt;
  &lt;p id="lan"&gt;Test Lan: &lt;/p&gt;
   &lt;p id='geo'&gt;geoLocal&lt;/p&gt;&lt;script&gt;
  
   &lt;/script&gt;
  &lt;/body&gt;
  &lt;script src="javascript/weatherTest.js"&gt;&lt;/script&gt;
  &lt;!-- &lt;script src="JSON/weather.json"&gt;&lt;/script&gt; --&gt;
  </code></pre>
  
  <p>Javascript</p>
  
  <pre><code>var api= "https://fcc-weather-api.glitch.me/api/current?";
  var googleApi="https://www.googleapis.com/geolocation/v1/geolocate?
  key=AIzaSyCOMzDSyP4RkXwp7mSiFiuAZroyrazU5eM";
  
  var lat, lon;
  var x= document.getElementById("geoLocal");
  var tempX= document.getElementById("temp");
  var geoLocal=document.getElementById("geo");
  var xLat= document.getElementById("lat");
  // Following functions will get the latitude and longitude
  
  function getLocation() {
      if (navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(showPosition);
      } else {
          geoLocal.innerHTML = "Geolocation is not supported by this 
   browser.";
      }
  }
  var finalLat=finalCoords[0];
  var finalLon=finalCoords[1];
  function showPosition(position){
    geoLocal.innerHTML="Latitude:" + position.coords.latitude +
    "&lt;br&gt; Longitude: " + position.coords.longitude;
    lat= position.coords.latitude;
    lon=position.coords.longitude;
    var finalCoords=[lat,lon]
    return finalCoords;
  }
  showPosition(position);
  console.log(api,lon);
  xLat.innerHTML="testLat: " + finalCoords[0];
  finalLat=finalCoords[0];
  finalLon=finalCoords[1];
  
  function getWeather(finalLat,finalLon){
    var completeApi=api+lon+"&amp;"+lat;
    // lon="lon="+ position.coords.longitude;
    // lat='lat='+ position.coords.latitude;
    xLat.innerHTML="testLatitude: " +completeApi;
  
    return completeApi;
    }
  getWeather(finalLat,finalLon);
  </code></pre>
  
  <p>The commented information below is the additional work I am going to be using to complete outputting the weather for any user location.</p>
  
  <pre><code>// var completeApi="getWeather(lat,lon)";
  // JSON request for API to get temperature
  // var ourRequest= new XMLHttpRequest();
  // ourRequest.open('GET',completeApi);
  // ourRequest.onload= function() {
  //   if (ourRequest.status&gt;= 200 &amp;&amp; ourRequest.status&lt;400){
  //     var ourData= JSON.parse(ourRequest.responseText);
  //     renderHTML(ourData);
  //     console.log("ourData",ourData);
  // } else{
  //   console.log("Connection Error, Please try again.")
  // }
  // };
  
  // ourRequest.send();
  // console.log(ourRequest)
  
  // var jsonWeather= JSON.stringify(ourData);
  // document.body.innerHTML=jsonWeather;
  // function renderHTML(data){
  //   var htmlString="";
  //   for (i=0;i&lt;data.lenth;i++){
  //     htmlString=data[i].coord;
  //     console.log(data[i].coord)
  //     tempX.textContent= data;
  
  //   }
  //   // htmlString.textContent=data[0];
  //   tempX.textContent= data;
  //   // return data;
  // }
  // console.log(ourRequest)
  // var geoLocation= document.getElementById("geoAPI");
  // geoLocation.innerHTML=completeApi;
  </code></pre>