css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <!--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("http://ip-api.com/json", function(data) {
    lat = data["lat"];
    lon = data["lon"];
 // add the visitors lat and lon to an api call to openweather
  var link =   "http://api.openweathermap.org/data/2.5/weather?lat=" + 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 = "http://openweathermap.org/img/w/" + icon + ".png";
     var html = "<img src = '" + iconURL + "' " + "alt='Weather Icon'>";


🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................