Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
Eric Weiss
@eweiss17
i'v done mailing in php
Nate Mallison
@NJM8
I used a mailing service. no php on github pages
super easy, just send a post request to their website with your email address and it sends whatever was in the form to you
HerbiScript
@HerbiScript
'''
$(document).ready(function(){
var url = "https://fcc-weather-api.glitch.me/api/current?";
var api;
if (navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(pos){
api = url + "lat=" + pos.coords.latitude + "&" + "lon=" + pos.coords.longitude;
$.getJSON(api, (function(data){
$("#loc").html(data.name + ", " + data.sys.country);
$("#temp").html(data.main.temp + "<button id='C' class='btn btn-default'><b>C</b></button>");
$("img").attr("src", "http://openweathermap.org/img/w/" + setIcon(data.weather[0].id) + ".png");
function setIcon(num){
if (200 <= num && num <= 232){
return "11d";
} else if ((300 <= num && num <= 321) || (520 <= num && num <= 531)){
return "09d";
} else if (500 <= num && num <= 504){
return "10d";
} else if (num == 511 || 600 <= num && num <= 622){
return "13d";
} else if (num == 800){
return "01d";
} else if (num == 801){
return "02d";
} else if (num == 802){
return "03d";
} else if (num == 803 || num == 804){
return "04d";
} else {
return "01d";
}
}
}));
});
}
$(".btn").css("color", "orange");
});
'''
CamperBot
@camperbot
:bulb: to format code use backticks! ``` more info
HerbiScript
@HerbiScript
$(document).ready(function(){
  var url = "https://fcc-weather-api.glitch.me/api/current?";
  var api;
  if (navigator.geolocation){
    navigator.geolocation.getCurrentPosition(function(pos){
      api = url + "lat=" + pos.coords.latitude + "&" + "lon=" + pos.coords.longitude;
      $.getJSON(api, (function(data){
        $("#loc").html(data.name + ", " + data.sys.country);
        $("#temp").html(data.main.temp + "<button id='C' class='btn btn-default'><b>C</b></button>");
        $("img").attr("src", "http://openweathermap.org/img/w/" + setIcon(data.weather[0].id) + ".png");
        function setIcon(num){
          if (200 <= num && num <= 232){
            return "11d";
          } else if ((300 <= num && num <= 321) || (520 <= num && num <= 531)){
            return "09d";
          } else if (500 <= num && num <= 504){
            return "10d";
          } else if (num == 511 || 600 <= num && num <= 622){
            return "13d";
          } else if (num == 800){
            return "01d";
          } else if (num == 801){
            return "02d";
          } else if (num == 802){
            return "03d";
          } else if (num == 803 || num == 804){
            return "04d";
          } else {
            return "01d";
          }
        }
          }));
     });
   }
  $(".btn").css("color", "orange");
});
Why is my final jQuery statement not effecting the button after it is created in the initial function?
Nate Mallison
@NJM8
@HerbiScript backticks not single quotes, probably the tilde button, top left corner of keyboard
ah got it
HerbiScript
@HerbiScript
My bad, thanks! @NJM8
CamperBot
@camperbot
herbiscript sends brownie points to @njm8 :sparkles: :thumbsup: :sparkles:
:cookie: 316 | @njm8 |http://www.freecodecamp.org/njm8
Nate Mallison
@NJM8
getJson is asynchronous
so it sends the request, you get the response from weather api, THEN it creates the button. but that all happens inside the getjson call
The response can take some time.so what the browser sees is
var url
var api
getJson
make button orange
receive json
make button
HerbiScript
@HerbiScript
ahh I see
Nate Mallison
@NJM8
does that make sense?
HerbiScript
@HerbiScript
So youre saying I need to mess with the button inside of the getJSON call?
Eric Weiss
@eweiss17
well you need to 100% make sure it is created before you can mess with it
Nate Mallison
@NJM8
Nope, change it after the call!
HerbiScript
@HerbiScript
It is made, I have everything working fine. My last user story I need to add is the button that transfers it to Fahrenheit and vic versa
Nate Mallison
@NJM8
checkout .done() about halfway down the page
Eric Weiss
@eweiss17
make an event if the button is clicked?
Nate Mallison
@NJM8
so you'll do
$getJson(
  getMyInfo)
.done(
  gotMyInfo so I can use it);
more or less
that may not work if you copy it. :smile:
HerbiScript
@HerbiScript
hmm ok I think I see what you're getting at. I'll be back if I can't figure it out with all the new info. Thanks for the guidance @NJM8 and @eweiss17 : )
CamperBot
@camperbot
herbiscript sends brownie points to @njm8 and @eweiss17 :sparkles: :thumbsup: :sparkles:
api offline
:cookie: 613 | @eweiss17 |http://www.freecodecamp.org/eweiss17
Eric Weiss
@eweiss17
look here
that is what he was talking about with .done
Nate Mallison
@NJM8
man I got gipped on some points
lol
Eric Weiss
@eweiss17
how good you are as a dev is proportional to how many points you have
Nate Mallison
@NJM8
:worried: I have a ways to go
Eric Weiss
@eweiss17
there are people in the main fcc channel that have like 2k-3k points
Ravishasthri
@ravi6112

function getLength(str) {
"use strict";

// change code below this line
var leng = {length:str.length};
const {length:len} =leng ;
// change this
// change code above this line

return len; // you must assign length to len in line

}

console.log(getLength('FreeCodeCamp'));

what is the wrong in this code
its not working

function getLength(str) {
"use strict";

// change code below this line
var leng = {length:str.length};
const {length:len} =leng ;
// change this
// change code above this line

return len; // you must assign length to len in line

}

console.log(getLength('FreeCodeCamp'));

ES6: Use Destructuring Assignment to Assign Variables from Objects
Aditya
@ezioda004
@ravi6112 You dont need another variable, the expression on RHS is treated as an object, so you can just do const {length:len} = str; which will evaluate to const len = str.length
Dušan Todorović
@krckyboy
I need to find photos of specific car models. Any suggestions for source of free photos of those kind?