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
Mark Lawrence
@ninja-ml
hi guys... I understand the scope of variables (I think) but I cant seem to get the latiitude and longitude to go into my api string... any suggestions? thanks
$(document).ready(function() {
    var latitude = "";
    var longitude = "";
    getLocation();
    var forecastAPI = "https://api.forecast.io/forecast/c1302682e0b647408be17c8d4316e468/";
    // var latitude = "39.2833";
    // var longitude = "-76.6167";
    var darkSky = forecastAPI + latitude + "," + longitude;
    var openCageAPI = "https://api.opencagedata.com/geocode/v1/json?q=";
    var openCage = openCageAPI + latitude + "+" + longitude + "&key=c9807bef51c405ef59c91a4c7124088e";

    function getLocation(){
          if (navigator.geolocation){
            navigator.geolocation.getCurrentPosition(bindPosition);
          }
          else {
            // x.innerHTML = "Geolocation is not supported by this browser.";
          }
    }
    function bindPosition(position) {
        latitude = position.coords.latitude;
        longitude = position.coords.longitude;
          console.log(latitude);
        }
});
Robert Uivarosi
@URobert
@ninja-ml it might be because you are loading the page before you get your reply from the api
Andrew Charlebois
@andrewchar
@URobert yeah i will come back to that later. got frustrated with in. i need to remake my array to do it aswell.
Robert Uivarosi
@URobert
@andrewchar just wanted to point it out. Other than that you might want to add some quotation marks to your quotes... and overall it looks very nice
Mark Lawrence
@ninja-ml
@URobert i modify my code to this before document.ready but it still doesn't populate the strings
var latitude = "";
var longitude = "";

    if (navigator.geolocation) {
       navigator.geolocation.getCurrentPosition(function(position) {
       latitude = position.coords.latitude;
       longitude = position.coords.longitude;
       console.log(latitude);
       console.log(longitude);
      });
    }

    var forecastAPI = "https://api.forecast.io/forecast/c1302682e0b647408be17c8d4316e468/";
    // var latitude = "39.2833";
    // var longitude = "-76.6167";
    var darkSky = forecastAPI + latitude + "," + longitude;
    var openCageAPI = "https://api.opencagedata.com/geocode/v1/json?q=";
    var openCage = openCageAPI + latitude + "+" + longitude + "&key=c9807bef51c405ef59c91a4c7124088e";
Andrew Charlebois
@andrewchar
@URobert i was debaiting including the quotations
@URobert people know its a quote, do ireally need to include the quotations
Robert Uivarosi
@URobert
@andrewchar it's a matter of taste I guess.
Andrew Charlebois
@andrewchar
@URobert i had them to begin with but took them out
@URobert and included a blockquote
Robert Uivarosi
@URobert
@ninja-ml what I did was create a function that gets the geolocation and at the end of its execution calls the function that makes the API call with long/lat values
@andrewchar again, it depends whenever you like them or not. I do , so I added them
Mark Lawrence
@ninja-ml
@URobert thanks... I don't actually have the API calls in a function I dont think... I'll try that
CamperBot
@camperbot
ninja-ml sends brownie points to @urobert :sparkles: :thumbsup: :sparkles:
:star: 567 | @urobert | http://www.freecodecamp.com/urobert
Joseph Morse
@jnmorse
@ninja-ml part of the issues is the geolocation is a async operation, so latitude and longitude don't equal anything till bindPosition is run, which is sometime after your url is being created.
Robert Uivarosi
@URobert
@ninja-ml yw, and you will need a the id at the end to get the response. Did you test your api call with a console log? does get you what you need ?
@ninja-ml here is an example of how the URL have to look like:
  weatherApiUrl = 'http://api.openweathermap.org/data/2.5/weather?lat=' + currentLat + '&lon=' +    currentLong  + "&units=" + units + "&APPID=" + appId;
Mark Lawrence
@ninja-ml
@jnmorse @URobert the API calls get me what I need and everything else worked before actually asking for the latitude, longitude... i originally hardcoded my location to get started
Robert Uivarosi
@URobert
@ninja-ml ok, so it is not the api call
@ninja-ml try what I mentioned above, that's all I did and it worked for me
Joseph Morse
@jnmorse
@ninja-ml yeah, hard coding would work cause then they values are not "" which is what you set them to at the start of your script, but the actuall call for the location is happening at some point in the future
Joseph Morse
@jnmorse
This message was deleted
Mark Lawrence
@ninja-ml
@URobert @jnmorse thanks guys... it's populating the location now but this is my first time working with JSON and now my functions aren't working... I'm not calling them somewhere, but I'm not sure where I should call them... if you get a chance could someone look at my code? http://codepen.io/ninja-ml/pen/PZyYwL/
CamperBot
@camperbot
ninja-ml sends brownie points to @urobert and @jnmorse :sparkles: :thumbsup: :sparkles:
:warning: ninja-ml already gave urobert points
:star: 381 | @jnmorse | http://www.freecodecamp.com/jnmorse
R. E. Daniels
@RDaniels34
@sreeves89 Great calculator! If you put .btn:focus { /* Removes any outlining from button containers */ outline: 0 !important; } It will remove the blue outlining from around your buttons. Thumbs up!
Joseph Morse
@jnmorse
@ninja-ml well you $.getJSON calls are outside of your callAPI function, so they are erroring silently now
Mark Lawrence
@ninja-ml
@jnmorse thanks... i just realized that and got it working! thanks for reviewing and helping!
CamperBot
@camperbot
ninja-ml sends brownie points to @jnmorse :sparkles: :thumbsup: :sparkles:
CompGeekGirl
@LisaRamos
I am not able to total the numbers, convert percentages into decimals, or add decimals to numbers in my calculator. I've been trying to figure out everything for too long and I need help here. http://codepen.io/lisaramos/pen/MKBmgm
Can anyone please help me figure this out?
CamperBot
@camperbot
api offline
Alexander Køpke
@alexanderkopke
@LisaRamos just a quick question.. the input variable. I see you have var input outside and inside the function. is this intentional?
@LisaRamos I do believe it will create some scope problems but I didn't look closely at your code. It just caught my eye
Robert Uivarosi
@URobert
@LisaRamos have you tried parseFloat();
CompGeekGirl
@LisaRamos
@URobert How do I do that?
Robert Uivarosi
@URobert
@LisaRamos See this: v
CompGeekGirl
@LisaRamos
@URobert I don't know what I'm trying to do with parseFloat() as far as this calculator goes. I'm trying to come up with a formula and I'm going mad here. Can you show me an example as to what I could do?
Robert Uivarosi
@URobert
@LisaRamos take a break if you feel like you are overwhelmed
@LisaRamos I just took a brief look and you have quite a few things to adjust
@LisaRamos i personally haven't used eval but build my own algorithm
Robert Uivarosi
@URobert
@LisaRamos see below a small sample of my code
                  // DOING THE MATH

          result = parseFloat(nr[0]);
          for (k=0; k < nr.length; k++){
          //SUM 
          if (operators[op] === "+" && k !== nr.length -1){
          result = result +parseFloat(nr[k+1]);
          }
CompGeekGirl
@LisaRamos
@alexanderkopke I think the var input thing is intentional.
Salman Shahid
@salman-shahid
This message was deleted
This message was deleted
Jonathan Coleman
@jondcoleman
@LisaRamos do you want to pair program - I could help walk you through some of it - I've got about 30 minutes free right now