Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <!--Make divs to display the weather conditions, and the temprature, as well as an icon-->
<div class="page">
  <h1 id="title">Free Code Camp</h1>
  <h2 id="subtitle">Local Weather App</h2>
  <div class="location"><h3>Your     Location</h3></div>
  <div class="temp"><h3 class="fahr">0 °F</h3></div>
  <div class="weather"><h3>No Info</h3></div>
  <div class="weather-icon"></div>
  <input type="button" class="btn" id="temp-btn" value="Celsius/Fahrenheit">



                body {
  background-color: black;

  color: #D9853B;
  text-align: center;

  color: #74AFAD;

  color: #558C89;

  color: black;




$.ajaxSetup({ cache: false });

  //variables to store the visitors latitude and longitude, and the temperature in Celsius and Fahrenheit
var lat = "";
var lon = "";
var cels = 0;
var fahr = 0;
  //Get the visitors lat and lon and store them to the variables. This actually gets their IP's location, so it's not necessarily accurate
$.getJSON("", function(data) {
    lat = data["lat"];
    lon = data["lon"];
 // add the visitors lat and lon to an api call to openweather
  var link =   "" + lat + "&lon=" + lon + "&APPID=312986e3f1efaf26b7621838c022de56";
  //call the getWather function to get the weather, to make sure that the api only gets called once the visitors lat and lon are known
  //If the button is pressed, change the temp from fahrenheit to celsius or vice versa
  current = 0;
   if (current === 0){
     $(".temp").html("<h3 class='cels'>" + Math.round(cels) + " " + "°C" + "</h3>");
     current = 1;
   } else if (current === 1){
     $(".temp").html("<h3 class='fahr'>" + Math.round(fahr) + " " + "°F" + "</h3>");
     current = 0; }

  //get the weather data, extract the bits we want, and add them to the DOM
function getWeather (link){
   $.getJSON(link, function(data){
     //get the temprature in Kelvin and convert it to Fahrenheit and Celsius, remember to round them before displaying
     var temp = JSON.stringify(data["main"]["temp"]);
        cels = temp - 273.15;
        fahr = (temp * (9/5)) -459.67;
       $(".temp").html("<h3 class='fahr'>" + Math.round(fahr) + " " + "°F" + "</h3>");
      //Weather is lowercase, let's change this up
     var weather = (data["weather"][0]["description"]);
        $(".weather").html("<h3>" + weather + "</h3>");
     //name and country,  maybe expand the country code to the full name
     var city =(data["name"]);
     var country =(data["sys"]["country"]);
     $(".location").html("<h3>" + city + ", " + country + "</h3>");
     //find and display an icon for the weather
     var icon = data["weather"][0]["icon"];
     var iconURL = "" + icon + ".png";
     var html = "<img src = '" + iconURL + "' " + "alt='Weather Icon'>";