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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


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.


                <div class="container-fluid">
  <h1 class = "text-center">Free Code Camp Local Weather App</h1>
  <div class = "text-center" id = "temperature"></div>
  <div class = "row">
    <div class = "col-md-offset-3 col-md-2">
      <div class = "weatherSection" id = "location">

    <div class = "col-md-2">
      <div class = "weatherSection" id = "summary">
    <div class = "col-md-2">
      <div class = "weatherSection" id = "wind">

  <div class = "row">
    <div class = "col-md-4 col-md-offset-4 text-center">
      <button class = "btn btn-lg btn-primary" id = "change">Toggle Celsius / Fahrenheit</button>



                body {
  background-image: url('');
  background-repeat: no-repeat;
  background-size: cover;

.summer {
    background-image: url('');
    background-repeat: no-repeat;
    background-size: cover;

h1, h2 {
  margin-top: 50px;
  margin-bottom: 50px;
  color: #ffff00;
  text-shadow: 3px 2px gray;

.weatherSection {
  display: none;

p {
  font-size: 20px;
  color: orange;

.visible {
  display: block;

.row {
  margin-bottom: 50px;

#currentTemperature {
  margin-top: 10px;



                $(document).ready(function() {
  // declare variables
  var latitude = null;
  var longitude = null;
  var weatherAPI = "";
  var celsius = false;
  var wd;
  // function for displaying temperature in F or C
  function displayTemp(fTemp, c) {
    if (c) {
      return Math.round((fTemp-32)*(5/9)) + " C";
    return Math.round(fTemp) + " F";
  // html render
  function render(apiData, celsius) {
        var location =;
        var description =[0].description;
        var summary = description.charAt(0).toUpperCase() + description.slice(1);
        var temperature = displayTemp(apiData.main.temp, celsius);
        var country =;
        var wind = apiData.wind.speed;
        var icon =[0].icon;
        var iconSrc = '' + icon + '.png';
        var temperatureHTML = `<img src = "${iconSrc}"><h2 id = "currentTemperature">Current temperature: ${temperature}.</h2>`;
        var locationHTML = `<p>${location}, ${country}</p>`;
        var summaryHTML = `<p>${summary}</p>`
        var windHTML = `<p>Wind speed: ${wind}</p>`
        if (temperature > 70) {
  // use geolocation to get the current position
  function getLocation() {
    var geolocation = navigator.geolocation;
  function showLocation(position) {
    latitude = position.coords.latitude;
    longitude = position.coords.longitude;
    weatherAPI = `${latitude}&lon=${longitude}&appid=7813026cea5d27742c4e9a868c318243`;

      $.getJSON(weatherAPI, function(apiData) {
        wd = apiData;
        render(apiData, celsius);
        $('#change').click(function() {
          celsius = !celsius;
          render(wd, celsius);
      }) // end getJSON
 }  // end showLocation  

}) // end ready