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.

              <div class="container-fluid">
  <div class="row">
    <div class="col text-center">
      <h1>Local Weather App</h1>
  <div class="col text-center">
    <div class="weather-box">
      <div id="icon"></div>
      <p>Location: <span id="location"></span></p>
        <p>Temperature: <span class="temp" id="temp"></span></p>
        <p>Humidity: <span id="hum"></span></p>
        <p>Weather: <span id="over"></span></p>
        <p>Description: <span id="script"></span></p>
        <p>Wind Speed: <span id="wind"></span></p>

<div class="container-fluid footer">
  <div class="row">
    <div class="col-xs-auto">
      <a href="https://github.com/Jamiemufu" target="_blank"><image class="footer-icons" src="https://image.flaticon.com/icons/png/512/25/25231.png"></image></a>
<a href="https://www.freecodecamp.org/jamiemufu" target="_blank"><image class="footer-icons" src="https://cdn.rawgit.com/Deftwun/e3756a8b518cbb354425/raw/6584db8babd6cbc4ecb35ed36f0d184a506b979e/free-code-camp-logo.svg"></image></a>
<a href="http://gmail.com" target="_blank"><image class="footer-icons" src="http://www.free-icons-download.net/images/email-icon-82461.png"></image></a><b><i> Jamiemufu</b></i>

              body {
  background-color: black;
  font-family: verdana;
  color: white;
h1 {
  font-size: 45px;
  text-align: center;
  color: limegreen;
  font-family: "Audiowide", cursive;
  margin-top: 2%;

.weather-box {
  margin: 10px auto auto auto;
  text-align: center;
  width: 40%;
  font-size: 18px;
  margin-bottom: 5em;
span {
  color: limegreen;
  font-size: 20px;
  font-style: italic;

.temp:hover {
  cursor: pointer;
#script {
  text-transform: capitalize;

h3 {

.footer-icons {
  height: 50px;
  width: 50px;
  background-color: limegreen;
  padding: 10px;
  margin-left: -3px;
.footer {
  bottom: 0;
  width: 100%;
  color: limegreen;
  font-family: verdana;
  font-size: 12px;
              //decalre some global variables
var api = "https://fcc-weather-api.glitch.me/api/current?lat=";
var lat;
var long;
var currentTemp;
var far;

$(document).ready(function() { //on document load
  if (navigator.geolocation) { //if geolocation allowed
    navigator.geolocation.getCurrentPosition(function(position) { 
      var lat = position.coords.latitude; //store lat position
      var long = position.coords.longitude; //store long position
      getInfo(lat, long); //call getInfo function
  } else {
    console.log("geolocation not supported"); //if not supported

//function to get all the data and use it on the screen
function getInfo(lat, long) { //pass lat and long thrugh function
  var urlstring = api + lat + "&&lon=" + long; //decalre url variable to get location
    url: urlstring, //use this url
    success: function(data) { //successfull
      var icon = '"' + data.weather[0].icon + '"'; //this is the built in icons on API
      var overView = data.weather[0].main; //overview from object
      var desc = data.weather[0].description; //decirption
      //needed to use 2 variables. One for rounded and one for working out far conversion. Kept getting NAN when trying to use currentTemp rounded with Far
      var currentTemp = data.main.temp;
      var currentTempRounded = Math.round(currentTemp) + String.fromCharCode(176) + "C";
      var far = currentTemp * (9 / 5) + 32;
      var farRounded = Math.round(far) + String.fromCharCode(176) + "F";
      var name = data.name;
      var country = data.sys.country;
      var windSpeed = data.wind.speed;
      var humidity = data.main.humidity;
      //Put data in span locations....
      $("#icon").append("<image src=" + icon + "</image>");
      $("#location").text(name + ", " + country);
      $("#wind").text(windSpeed + "mph");
      //call the function to change the temp on click
      changeTemps(currentTempRounded, farRounded);
//Function to adjust the temperatures onclick
function changeTemps(currentTempRounded, farRounded) {
$("#temp").click(function() {
  if ($("#temp").text() == currentTempRounded){


🕑 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 ..................