These are chat archives for FreeCodeCamp/HelpJavaScript

2nd
Mar 2018
jusgoose
@gusd773
Mar 02 2018 00:35
anybody wanna point me in the right direction of where to start w the local weather app?

my amazing progress thus far, I am thinking of manipulating the geo loc next

https://codepen.io/gusd773/pen/qxgjxP

Greg Duncan
@GregatGit
Mar 02 2018 00:38
@gusd773 openweather and watch out when you http instead of https
jusgoose
@gusd773
Mar 02 2018 00:42
@GregatGit first of all, dope name, secondly I am not sure how to use an API after a page is loaded tbh. The last challenge for random quotes made sense gives you had to click something but this one is nonsense
Jason Luboff
@JLuboff
Mar 02 2018 00:45

If you're using jQuery, you just have the function run on page load

$(document).ready(function(){
$.getJSON(....)
})

for example

Or slightly different approach..
$(document).ready(function(){
function getWeather(){
$.getJSON(....) }

getWeather();
})
Greg Duncan
@GregatGit
Mar 02 2018 01:18
@gusd773 http://openweathermap.org just sign up for a free open weather account and try get a city's weather data (doesnt matter which one) that would be a good starting point
jusgoose
@gusd773
Mar 02 2018 01:19
@JLuboff thanks man
CamperBot
@camperbot
Mar 02 2018 01:19
gusd773 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2350 | @jluboff |http://www.freecodecamp.org/jluboff
jusgoose
@gusd773
Mar 02 2018 01:20
@GregatGit I get the api documentation and what url to use (at least I think) but they require I ask for a specific place to use the API
Greg Duncan
@GregatGit
Mar 02 2018 01:23
jusgoose
@gusd773
Mar 02 2018 01:27
@GregatGit what if they use an alternate IP address?
Greg Duncan
@GregatGit
Mar 02 2018 01:29
@gusd773 it will pick up where there computer is in the world -
but I wouldn't worry about that
jusgoose
@gusd773
Mar 02 2018 01:31
@GregatGit ok so should I setup my JS to ask for Geo loc first?
@GregatGit sorry for all the baby questions but this is super overwhelming as I know the steps sort of but don't know where/how to start
Greg Duncan
@GregatGit
Mar 02 2018 01:33
I would just use static data first - so just get the weather data
jusgoose
@gusd773
Mar 02 2018 02:07
@GregatGit what do you mean by static data?
Greg Duncan
@GregatGit
Mar 02 2018 02:07
you put the lat and long in the api
jusgoose
@gusd773
Mar 02 2018 02:11
@GregatGit lost me
jusgoose
@gusd773
Mar 02 2018 02:31
@GregatGit would this get me the city ?

$(document).ready(function(){
$.getJSON("https://ip-api.com/json/?callback=yourfunction", function(loc){
    $(".location").html(loc[0].city);
}
)
})
abraham anak agung
@padunk
Mar 02 2018 02:39
@gusd773 you could also use navigator.geolocation to get user location.
Stephen James
@sjames1958gm
Mar 02 2018 02:44
@gusd773 I don't think that site supports https
@gusd773 https://ipapi.co/json this one does
Ming Zhang
@mingsky1987
Mar 02 2018 02:56
var newArray = oldArray.map(fuction(val){
return val+3;
});
it's about map method
who help me?
abraham anak agung
@padunk
Mar 02 2018 02:57
@mingsky1987 what's your problem? map is like for loop, but return new array
Ming Zhang
@mingsky1987
Mar 02 2018 02:58
Iterate over Arrays with map
it's this lesson which i can't pass
abraham anak agung
@padunk
Mar 02 2018 02:59
@mingsky1987 what is the requirement?
Ming Zhang
@mingsky1987
Mar 02 2018 03:00
oldArray plus 3,return to newArray
Nate Mallison
@NJM8
Mar 02 2018 03:00
@mingsky1987 Check your spelling
Ming Zhang
@mingsky1987
Mar 02 2018 03:01
oh,my god!
function
Nate Mallison
@NJM8
Mar 02 2018 03:01
Did you get the error (expected ) instead saw {
?
Ming Zhang
@mingsky1987
Mar 02 2018 03:02
it works,thank you.
Nate Mallison
@NJM8
Mar 02 2018 03:02
no problem. :smile:
dinesh
@1532j0004kg
Mar 02 2018 09:59
use of preventdefault() in timers ?
Johnny
@JohnnyBizzel
Mar 02 2018 10:24
dinesh
@1532j0004kg
Mar 02 2018 10:32
for pomodora clock is it necesaary to use settimeout()
Johnny
@JohnnyBizzel
Mar 02 2018 10:32
@1532j0004kg Yes but why do you need preventDefault() ?
dinesh
@1532j0004kg
Mar 02 2018 10:32
is it okay with setinterval();
no i dont need that
Johnny
@JohnnyBizzel
Mar 02 2018 10:32
@1532j0004kg What have you tried?
dinesh
@1532j0004kg
Mar 02 2018 10:33
i want to pause my timer once i paused , then again it must be play with the last counted seconds once i clicked the play button
here its not preventing the last counted seconds.
here its starts from the first given seconds.
Marianissimus
@Marianissimus
Mar 02 2018 10:41
You need some () and {} for your if/else: if (condition){do stuff} else{do something else}
dinesh
@1532j0004kg
Mar 02 2018 10:41
i knew that but how to prevent the seconds when on click
pause button.
Johnny
@JohnnyBizzel
Mar 02 2018 10:45
@1532j0004kg On the stop button press, set a flag (boolean) which detects whether the timer runs or not.
Marianissimus
@Marianissimus
Mar 02 2018 10:45
you can use a callback. but I struggle with your logic so far, if(seconds > 0) { seconds--} only changes the seconds var in js, not in display; this will be overwritten by html
dinesh
@1532j0004kg
Mar 02 2018 10:47
@JohnnyBizzel try my pen , the clear interval and setinterval is working.
Johnny
@JohnnyBizzel
Mar 02 2018 10:48
@1532j0004kg The clock goes to 0:0:0.
dinesh
@1532j0004kg
Mar 02 2018 10:48
enter the seconds in first input field
and click start button
and then try stop button
Johnny
@JohnnyBizzel
Mar 02 2018 10:49
@1532j0004kg Confusing interface if you ask me.
@1532j0004kg And if you stop, it starts again at the initial time
dinesh
@1532j0004kg
Mar 02 2018 10:50
thats my problem :smile:
i want to continue the timer from last seconds
Johnny
@JohnnyBizzel
Mar 02 2018 10:52
@1532j0004kg Well on the pause you need to store the current value.
@1532j0004kg maybe lock the input box until the user resets? You don't have a reset button yet though.
dinesh
@1532j0004kg
Mar 02 2018 10:54
how to store the current value
am i want to store the current value every seconds
?
@JohnnyBizzel
Johnny
@JohnnyBizzel
Mar 02 2018 10:55
@1532j0004kg use a global variable??
dinesh
@1532j0004kg
Mar 02 2018 10:55
inside the setinterval function ?
Johnny
@JohnnyBizzel
Mar 02 2018 10:56
@1532j0004kg What do you know about variables? Do you know about scope?
dinesh
@1532j0004kg
Mar 02 2018 10:56
ya
i will try , thanks :smile: @JohnnyBizzel
CamperBot
@camperbot
Mar 02 2018 10:56
1532j0004kg sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1803 | @johnnybizzel |http://www.freecodecamp.org/johnnybizzel
Johnny
@JohnnyBizzel
Mar 02 2018 10:57
@1532j0004kg :+1:
hal0o0o0
@hal0o0o0
Mar 02 2018 11:15

// Declarations
var StUdLyCapVaR;
var properCamelCase;
var TitleCaseOver;

// Assignments
STUDLYCAPVAR = 10;
PRoperCAmelCAse = "A String";
tITLEcASEoVER = 9000;

hey guys, could you tell me how to Write variable names in Javascript in camelCase?
abraham anak agung
@padunk
Mar 02 2018 11:16
@hal0o0o0 var properCamelCase
hal0o0o0
@hal0o0o0
Mar 02 2018 11:18
the mission is to Modify the existing declarations and assignments so their names use camelCase.
Johnny
@JohnnyBizzel
Mar 02 2018 11:20
@hal0o0o0 theMissionIsToModifyTheExistingDeclarationsAndAssignmentsSoTheirNamesUse ... camelCase
abraham anak agung
@padunk
Mar 02 2018 11:21
@hal0o0o0 this is camelCase instead of using underscore camel_Case
Stephen James
@sjames1958gm
Mar 02 2018 11:22
@hal0o0o0 If you have some doubts, the answers show the correct values
hal0o0o0
@hal0o0o0
Mar 02 2018 11:23
there is a difference between Chinese and English instructions about this mission, so i'm confused.
dinesh
@1532j0004kg
Mar 02 2018 11:24
@sjames1958gm how to save the last second during the pause
Stephen James
@sjames1958gm
Mar 02 2018 11:25
@1532j0004kg Just like @JohnnyBizzel said, keep the seconds value outside of any function so you can reference it later.
dinesh
@1532j0004kg
Mar 02 2018 11:26
i did that ,but i cant able to get the value from the input field
it means that the field is empty
Johnny
@JohnnyBizzel
Mar 02 2018 11:27
@hal0o0o0 the rules for camelCase. 1st letter of 1st word lower case. Any words after should have Upper case 1st letter and lower case remaining letters.
Stephen James
@sjames1958gm
Mar 02 2018 11:29
@hal0o0o0 Oh, didn't know that.
@1532j0004kg Just move the variable outside, not the setting of the variable.
var seconds;
then inside the function
seconds = $("#sessip").val();
But you need to decide between start - reset seconds and resume use existing seconds value
dinesh
@1532j0004kg
Mar 02 2018 11:32
i did like that only
var set,seconds,breakTime;

var setTimer = function(){
  seconds = $("#sessip").val();
  breakTime = $("#breakip").val();
  $('#btnstart').prop('disabled',true);
  $('#btnstop').prop('disabled',false);

set = setInterval(function(){
   hr = Math.floor(seconds/3600);
   min = Math.floor(seconds%3600/60);
   sec = Math.floor(seconds%60);
Stephen James
@sjames1958gm
Mar 02 2018 11:34
@1532j0004kg - everytime you click start it is going to reset the timer back to the full value
dinesh
@1532j0004kg
Mar 02 2018 11:35
yes but i need to resume
Stephen James
@sjames1958gm
Mar 02 2018 11:36
Then you need different logic, maybe something that tells you the timer is already running and not reset it,
hal0o0o0
@hal0o0o0
Mar 02 2018 11:38
var studlyCapVar = STUDLYCAPVAR;
var studlyCapVar = 10;
var properCamelCase = "A String";
var titleCaseOver = TitleCaseOver;
var titleCaseOver = 9000;
dinesh
@1532j0004kg
Mar 02 2018 11:38
thats my question
hal0o0o0
@hal0o0o0
Mar 02 2018 11:40
the page says i can go to next challenge, so i do it correctly?
abraham anak agung
@padunk
Mar 02 2018 11:41
@hal0o0o0 yes, but i think this will do
var studlyCapVar = 10;
var properCamelCase = "A String";
var titleCaseOver = 9000;
hal0o0o0
@hal0o0o0
Mar 02 2018 11:42
studlyCapVar should use camelCase in both declaration and assignment sections.
titleCaseOver should use camelCase in both declaration and assignment sections.
here are 2 problems above.
Stephen James
@sjames1958gm
Mar 02 2018 11:43
@1532j0004kg Well you could have a variable running, initially false, then set to true when they first click start
If true don't reset seconds from the input
hal0o0o0
@hal0o0o0
Mar 02 2018 11:43
so i have to write 5 rows
abraham anak agung
@padunk
Mar 02 2018 11:43
@hal0o0o0
//Declararions
var properCamelCase;

//Assignment
properCamelCase = 10;
Stephen James
@sjames1958gm
Mar 02 2018 11:44
@hal0o0o0 Well the english one had six lines and you should just edit those six lines, not create new ones
dinesh
@1532j0004kg
Mar 02 2018 11:45
@sjames1958gm :confused:
abraham anak agung
@padunk
Mar 02 2018 11:45
when you use = that means you assign the variable to something @hal0o0o0
hal0o0o0
@hal0o0o0
Mar 02 2018 11:47
oh god, i think it harder...i just should correct them directly...
Stephen James
@sjames1958gm
Mar 02 2018 11:48

@1532j0004kg

/// global
var running = false;
// In your click function
if (!running)  {
   seconds = $("#sessip").val();
   running = true;
}

This is basically what you want

@hal0o0o0 Exactly!
dinesh
@1532j0004kg
Mar 02 2018 11:48
@sjames1958gm thanks
CamperBot
@camperbot
Mar 02 2018 11:48
1532j0004kg sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9051 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
dinesh
@1532j0004kg
Mar 02 2018 11:48
i will try with these points
hal0o0o0
@hal0o0o0
Mar 02 2018 11:49
thank you all, i'll go to net challenge.
Stephen James
@sjames1958gm
Mar 02 2018 11:49
@hal0o0o0 :+1:
hal0o0o0
@hal0o0o0
Mar 02 2018 11:49
u r so nice
Stephen James
@sjames1958gm
Mar 02 2018 11:50
@1532j0004kg running would be called a state variable it indicates what the state of the clock is, running or not.
As you program you will encounter state very often.
@hal0o0o0 :heart_eyes_cat:
dinesh
@1532j0004kg
Mar 02 2018 11:51
ya
on click only i want to initialize the starting value
othertimes i want to run with the last seconds
rubber2018
@rubber2018
Mar 02 2018 12:47
under.jpg
Hey guys! What am i doing wrong?
I put it under 9
Johnny
@JohnnyBizzel
Mar 02 2018 12:50
@rubber2018 keep trying
Marianissimus
@Marianissimus
Mar 02 2018 12:51
your second condition is more or equal; you're close
rubber2018
@rubber2018
Mar 02 2018 12:52
I am keepting tryng...still dont get it
i dont see something wrong
Stephen James
@sjames1958gm
Mar 02 2018 12:53
@rubber2018 In your mind put val = 9 and run through the code step by step
rubber2018
@rubber2018
Mar 02 2018 12:53
if i put 10 its 10 or over
Marianissimus
@Marianissimus
Mar 02 2018 12:53
your second condition says: if val is more or EQUAL to 9...
Stephen James
@sjames1958gm
Mar 02 2018 12:53
@rubber2018 The failing one says val is 9
rubber2018
@rubber2018
Mar 02 2018 12:54
AAA
Doooh
i am stupid
it's suppose tot be 10
pff
Tnx guys
Stephen James
@sjames1958gm
Mar 02 2018 12:54
@rubber2018 Computers, only your spouse can make you feel stupider
Marianissimus
@Marianissimus
Mar 02 2018 12:54
you're not stupid, just learning;
rubber2018
@rubber2018
Mar 02 2018 12:54
@sjames1958gm :smile:
Markus Kiili
@Masd925
Mar 02 2018 13:10
@sjames1958gm My kid asked for a new dad for Xmas. I asked my spouse, if i can go. She said that I can go after the mortgage is paid.
Stephen James
@sjames1958gm
Mar 02 2018 13:11
@Masd925 She didn't say go, but still pay the mortgage?
Markus Kiili
@Masd925
Mar 02 2018 13:12
@sjames1958gm I cannot be trusted that much, I suppose.
@sjames1958gm I got a new job today. A bit fed up on the old job, so feels good.
Stephen James
@sjames1958gm
Mar 02 2018 13:20
@Masd925 Cool, I started a new job on Monday (last)
Good luck
function isMAC48Address(inputString) {
    inputString = inputString.split("-");
    if(inputString.length !== 6 || !inputString.every((ele)=>ele.length == 2 )) return false;
    return inputString.every((ele)=>!isNaN(parseInt(ele,16)));
}
any idea what im missing?
I guess maybe regex is a good idea
CamperBot
@camperbot
Mar 02 2018 14:43
:bulb: to format code use backticks! ``` more info
Stephen James
@sjames1958gm
Mar 02 2018 14:43
@tiagocorreiaalmeida Which tests fail?
Tiago Correia
@tiagocorreiaalmeida
Mar 02 2018 15:29
@sjames1958gm ended up doing it with regex since it was quite simple with it but thanks
CamperBot
@camperbot
Mar 02 2018 15:29
tiagocorreiaalmeida sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9052 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Mar 02 2018 15:30
@tiagocorreiaalmeida :+1:
jusgoose
@gusd773
Mar 02 2018 16:06
can somebody help with my local weather app? I am stuck with the first step
I know how to ask for the geolocation of the user but I am not sure how to store that
ehutchllew
@ehutchllew
Mar 02 2018 16:09
@gusd773 show your codepen
Nate Mallison
@NJM8
Mar 02 2018 16:17
@gusd773 You can store the coordinates in variables then pass those to a function to the FCC weather api to get conditions for that location.
Nazar
@IsaakNazar
Mar 02 2018 16:18
hey guys, how to return given string on every possible version of itself by shuffling the string, example:
abc -> acb, bac, bca, cab , cba . I can use random method, to shuffle and compare with previous result, are there another ways?
need a hint
jusgoose
@gusd773
Mar 02 2018 16:19

@NJM8 thanks all within the ```

<script> </script>```
tags?

CamperBot
@camperbot
Mar 02 2018 16:19
gusd773 sends brownie points to @njm8 :sparkles: :thumbsup: :sparkles:
:cookie: 313 | @njm8 |http://www.freecodecamp.org/njm8
Quantomistro3178
@Quantomistro3178
Mar 02 2018 16:19
https://codepen.io/Quantomistro3178/pen/xYqJYw
How do I make the quote fadeOut when the getQuote function is invoked, and the fadeOut once the new quote is ready?
Sorry, fadeIn* once the new quote is ready
Nate Mallison
@NJM8
Mar 02 2018 16:20
Yes, getCurrentPosition also is a little funny in that it expects a successFunction and an errorFunction, if it can get the coordinates it will run successFunction, if not error function.
Like so:
    if ('geolocation' in navigator) {
        displayMessage('Finding your local weather');
        let successHandler = function(position){
            const latLng = [position.coords.latitude, position.coords.longitude];
            getLocation(latLng);
            getWeather(latLng);
        }
        const errorHandler = function(){
            displayMessage("We couldn't get your location automatically, please search above!");
        }
        navigator.geolocation.getCurrentPosition(successHandler, errorHandler);
    } else {
        displayMessage("We couldn't get your location automatically, please search above!");
    }
note displayMessage, getLocation, and getWeather are my own functions
but if getWeather was:
function getWeather(latLng){
call to FCC weather api with latLng[0] + latLng[1];
}
something like that, then it would work
Nate Mallison
@NJM8
Mar 02 2018 16:28
@Quantomistro3178 Almost the same way you do for your spinning button
Think about how that works, you hover over it, which defines the buttons state (hover) and then the animation you have made runs
Quantomistro3178
@Quantomistro3178
Mar 02 2018 16:30
@NJM8 But I used CSS for that...
wait, let me think about it
Nate Mallison
@NJM8
Mar 02 2018 16:30
ok
if you need more direction let us know
Quantomistro3178
@Quantomistro3178
Mar 02 2018 16:32
@NJM8 At first I thought I could add another var to hold the previous quote's value, and then something like
if (quote !== previousQuote) { $(quote).fadeIn(); }
something like that?
Jason Luboff
@JLuboff
Mar 02 2018 16:37

@Quantomistro3178 I would think something like

$('#idOfQuoteContainer').fadeOut().html(quote).fadeIn();

It's been a while since I've worked with fade in/out but I think that may work but don't quote me on it :D

You can also use .text instead of .html if you're only changing the text and not having any html
Nate Mallison
@NJM8
Mar 02 2018 16:41
@Quantomistro3178 I didn't realize there was a jQuery function for that, of course there is lol. I was thinking more along the lines of define your own animation in CSS with a custom class name, then add that class to the elements class list upon button click to run the animation
There is also the AOS library with some cool animations
here.
the fade animations work, but I want it to fadeOut as the previous quote, and then fadeIn as the new quote...
Nevermind, I got it.
I added fadeOut() at the top of the function, and chained the fadeIn() function after changing the html of the element.
Nate Mallison
@NJM8
Mar 02 2018 16:50
yeah you just need to swap the order of calls around
Quantomistro3178
@Quantomistro3178
Mar 02 2018 16:50
thanks @NJM8 @JLuboff
CamperBot
@camperbot
Mar 02 2018 16:50
quantomistro3178 sends brownie points to @njm8 and @jluboff :sparkles: :thumbsup: :sparkles:
:cookie: 314 | @njm8 |http://www.freecodecamp.org/njm8
:star2: 2351 | @jluboff |http://www.freecodecamp.org/jluboff
Nate Mallison
@NJM8
Mar 02 2018 16:50
Nice!
Just a suggestion since you are using an api to get the quotes (good idea btw), I would think about how things look when the api call is slow
Quantomistro3178
@Quantomistro3178
Mar 02 2018 16:53
@NJM8 I know, the box kind of gets weird when the button is clicked....any suggestions on how to avoid that?
Nate Mallison
@NJM8
Mar 02 2018 16:55
So right now it's jumping around because of the removing and adding of the text, so maybe you'll want some placeholder text? Or fade in and out on the whole box? Or, the best thing would be since, you have an async call to get your data, do the fade out when you know you have the data, then add in the new data and the fade in. But that still may look weird. Maybe a simple solution would be just to maintain the size of the empty box with css so it doesn't collapse.
jusgoose
@gusd773
Mar 02 2018 16:56
@NJM8 does this work?
var lat = "";
var lng = "";
if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
   lat= position.coords.latitude;          lng= position.coords.longitude;
  });
}
anybody else welcome to take a hack at making sense of my nonsense
Nate Mallison
@NJM8
Mar 02 2018 16:57
should, just start with var lat = 0; or var lat; since it is a number
Quantomistro3178
@Quantomistro3178
Mar 02 2018 16:57
@NJM8 Good ideas. I think i'll try storing the data first and then adding the animations
jusgoose
@gusd773
Mar 02 2018 16:59
lolll @NJM8 true i'm sorry my brain's been acting up
Nate Mallison
@NJM8
Mar 02 2018 17:00
Don't apologize to me. :smile:
No worries, that's why we are here right? the crazy ones, lol
rubber2018
@rubber2018
Mar 02 2018 17:03
under.jpg
what am i doing wrong...cuz u put
testLessOrEqual should return "25 or More
i already put it..'
Jason Luboff
@JLuboff
Mar 02 2018 17:07
@rubber2018 You have val >= 9
thus if its 9, its going to return 10 or Over
rubber2018
@rubber2018
Mar 02 2018 17:09
Oh yes
thnx
@JLuboff :+1:
under.jpg
and here? what am i doing worng?
wrong*?
Jason Luboff
@JLuboff
Mar 02 2018 17:12
@rubber2018 Again you're using the wrong operand
val <= 25
If its 25, its going to return Smaller than or..
rubber2018
@rubber2018
Mar 02 2018 17:13
well i put <=25
Jason Luboff
@JLuboff
Mar 02 2018 17:13
Which means less than or equal to 25
rubber2018
@rubber2018
Mar 02 2018 17:13
yes
24 i get it
=))
that was the problme
tnx
@JLuboff :+1:
Jason Luboff
@JLuboff
Mar 02 2018 17:14
:smile: :+1:
rubber2018
@rubber2018
Mar 02 2018 17:40
under.jpg
I don't get...i declare less then 5....what am i doing wrong herE?
Pieter Stokkink
@forkerino
Mar 02 2018 17:46
@rubber2018 you have two identical comparisons
also order matters
Jason Luboff
@JLuboff
Mar 02 2018 17:46
@forkerino :wave:
Pieter Stokkink
@forkerino
Mar 02 2018 17:46
@JLuboff :metal:
Jason Luboff
@JLuboff
Mar 02 2018 17:47
How's the weekend so far?
rubber2018
@rubber2018
Mar 02 2018 17:47
Hard=))
Pieter Stokkink
@forkerino
Mar 02 2018 17:48
Doing some python katas over at codewars. Not too comfortable with the language yet, so want to level up a bit. Just reached 6kyu this afternoon.
@JLuboff
rubber2018
@rubber2018
Mar 02 2018 17:48
I delete the secound one and still says the same thing
Jason Luboff
@JLuboff
Mar 02 2018 17:48
@forkerino Nice
rubber2018
@rubber2018
Mar 02 2018 17:48
orderMyLogic(4) should return "Less than 5"
Jason Luboff
@JLuboff
Mar 02 2018 17:48
Well do you have a test to see if the number is less than 5?
Pieter Stokkink
@forkerino
Mar 02 2018 17:49
@rubber2018 if / else if /else is the way to go, but you have to use the correct values to compare to and do it in the correct order
@JLuboff Any plans for the weekend?
Jason Luboff
@JLuboff
Mar 02 2018 17:50
@forkerino Ya....moving.. ugh.. lol
rubber2018
@rubber2018
Mar 02 2018 17:51
I am sorry..this one i don't get it...
function orderMyLogic(val) {
if (val < 10) {
return "Less than 10";
} else
return "Less than 5";
} else {
return "Greater than or equal to 10";
}
}
this is the order i made
Jason Luboff
@JLuboff
Mar 02 2018 17:51
You can't have two else statements, you need if/ else if/ else
Pieter Stokkink
@forkerino
Mar 02 2018 17:52
@JLuboff ok, moving to a nice place?
@rubber2018 what would happen if val is 1 when it enters your if?
Jason Luboff
@JLuboff
Mar 02 2018 17:52
and order matters, meaning if I have the number 4, well thats less than 5 but in your logic, your testing first if the number is less than 10, which is true which means if never gets to the statement saying less than 5
rubber2018
@rubber2018
Mar 02 2018 17:53
@forkerino U are not helpping...
=))
Jason Luboff
@JLuboff
Mar 02 2018 17:54
@forkerino Ya, same apartment complex but into a 2 bedroom unit. Will have all new carpet/flooring/paint, etc. And we'll have a single car garage. So thats all good but still a pain to move but luckily its ~.2 miles away so we're just renting a box truck and should hopefully be a quick move
rubber2018
@rubber2018
Mar 02 2018 17:55
=))
I will stuck with code...
forever
=))
i absolutely don;t get it
Pieter Stokkink
@forkerino
Mar 02 2018 17:57
@rubber2018 If you both have to test if a number is below 10 or if it is below 5. What do you need to test first?
remember return exits the function immediately
@JLuboff Cool, fresh house sounds good, man. Also a good moment to get rid of stuff you don't need anymore. Clean start.
Jason Luboff
@JLuboff
Mar 02 2018 18:01
@forkerino Ya, my wife has been purging. I need to purge some things as well
jusgoose
@gusd773
Mar 02 2018 18:21

question:

should my getJSON request be inside of my function ? I've yet to see it but I don't see my variables being utilized otherwise b/c of scope

var lat = 0;
var lng = 0;
if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
   lat= position.coords.latitude;          
    lng= position.coords.longitude;
  });
}
$(document).ready(function(){
$.getJSON();
}
)
})
I need the request to call the weather api using the coordinates
Jason Luboff
@JLuboff
Mar 02 2018 18:24
would recomend having your $.getJSON inside your geolocation function or make $.getJSON a function that is then called within the geolocation functon. Geolocation is an async process, meaning how you're currently setup, your $.getJSON would run before geolocation has completed
Pieter Stokkink
@forkerino
Mar 02 2018 18:24
@gusd773 I would put everything inside the document.ready function. the getJSON should be called from a position in the code where lat and lng are defined.
Gulsvi
@gulsvi
Mar 02 2018 18:43
I don't think document.ready is needed for that code. Nothing depends on the DOM being ready.
captain hindisght, 20 minutes after the post lol
Pieter Stokkink
@forkerino
Mar 02 2018 18:46
@gulsvi not yet, but the project will involve adding stuff to the DOM and changing things there.
Jason Luboff
@JLuboff
Mar 02 2018 18:48
I can't remember, but isn't it generally recomend when using jQuery to include document ready?
Christopher McCormack
@cmccormack
Mar 02 2018 19:18
:wave:
Nate Mallison
@NJM8
Mar 02 2018 19:18
Hey what's the simplest way to send an email from a contact form these days? This is just for my portfolio page contact me
Christopher McCormack
@cmccormack
Mar 02 2018 19:20
php is pretty easy
mainly because there are a bajillion templates out there and php is on most servers by default @NJM8
Jason Luboff
@JLuboff
Mar 02 2018 19:21
@cmccormack Good almost afternoon
Markus Kiili
@Masd925
Mar 02 2018 19:22
:wave:
Jason Luboff
@JLuboff
Mar 02 2018 19:22
Ya, if you're hosting your page, then PHP would be easiest but nodejs can do it if your host provides nodejs as an option. nodemailer is the package I use. Keep in mind both solutions require an SMTP server @NJM8
@Masd925 Good evening there?
Markus Kiili
@Masd925
Mar 02 2018 19:23
@JLuboff Yes, bedtime for old farts.
Jason Luboff
@JLuboff
Mar 02 2018 19:24
@Masd925 Indeed. Go check out @cmccormack link there, you'll love it!
Markus Kiili
@Masd925
Mar 02 2018 19:26
@JLuboff Document ready is needed for things that need dom to be ready.
Christopher McCormack
@cmccormack
Mar 02 2018 19:26
like anything that requires an element to already be mounted
Jason Luboff
@JLuboff
Mar 02 2018 19:27
I understand that
I guess I've always just included it lol
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 19:27
@cmccormack php bud
Christopher McCormack
@cmccormack
Mar 02 2018 19:27
I remember the countless questions we used to get in here about why their jquery failed and it was almost always that reason :D
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 19:28
@JLuboff nerd!
Jason Luboff
@JLuboff
Mar 02 2018 19:28
@RoniqueRicketts It happens
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 19:28
When ya'll having a skype call so we can make some apps using some of the free open apis. :)
Christopher McCormack
@cmccormack
Mar 02 2018 19:28
PHP is fine if you are lazy and want to copy existing scripts :D
Markus Kiili
@Masd925
Mar 02 2018 19:29
@JLuboff Do you really mean that link to some three letter language gist :imp:
Jason Luboff
@JLuboff
Mar 02 2018 19:29
Skype sucks
@Masd925 ;) :P
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 19:30
@cmccormack I learnt a little React Native over the past 2 days. I just felt curious. I think I wanna try something.
Markus Kiili
@Masd925
Mar 02 2018 19:30
@JLuboff New job got confirmed today.
Christopher McCormack
@cmccormack
Mar 02 2018 19:30
@RoniqueRicketts make something beautiful
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 19:30
hmm. any adult movie apis available?
Nate Mallison
@NJM8
Mar 02 2018 19:30
Thanks @cmccormack . However I am using github pages which has no server support so I'll end up using an email service of somesort
CamperBot
@camperbot
Mar 02 2018 19:30
njm8 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1357 | @cmccormack |http://www.freecodecamp.org/cmccormack
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 19:30
@cmccormack I'll try.
Jason Luboff
@JLuboff
Mar 02 2018 19:31
@Masd925 Thats awesome, Congrats!
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 19:31
I really need to learn authentication with backend
Markus Kiili
@Masd925
Mar 02 2018 19:31
@JLuboff I think that the firm mostly uses Java+React+SQL stack.
I'm somewhat familiar with the two, but not React.
They also like functional programming there.
Jason Luboff
@JLuboff
Mar 02 2018 19:33
@RoniqueRicketts Passport.js makes it easy but you can manage it yourself as well using express-sessions to maintain user state and bcrypt to hash passwords ,etc
@Masd925 No javascript?
Gulsvi
@gulsvi
Mar 02 2018 19:33
document.ready is technically obsolete in jQuery 3. Only code that needs to be ready after the DOM is loaded would need to go there. navigator.geolocation doesn't depend on the DOM.
Kelechi Chinaka
@ke1echi
Mar 02 2018 19:34
congrats on your confirmation @Masd925
Markus Kiili
@Masd925
Mar 02 2018 19:34
@JLuboff Normal browser techniques of course.
Kelechi Chinaka
@ke1echi
Mar 02 2018 19:34
:wave: guys
Gulsvi
@gulsvi
Mar 02 2018 19:35
jQuery offers several ways to attach a function that will run when the DOM is ready. All of the following syntaxes are equivalent:
  • $( handler )
  • $( document ).ready( handler )
  • $( "document" ).ready( handler )
  • $( "img" ).ready( handler )
  • $().ready( handler )
    As of jQuery 3.0, only the first syntax is recommended; the other syntaxes still work but are deprecated.
Markus Kiili
@Masd925
Mar 02 2018 19:35
@JLuboff @kelechy Thanks.
CamperBot
@camperbot
Mar 02 2018 19:35
masd925 sends brownie points to @jluboff and @kelechy :sparkles: :thumbsup: :sparkles:
:cookie: 327 | @kelechy |http://www.freecodecamp.org/kelechy
:star2: 2353 | @jluboff |http://www.freecodecamp.org/jluboff
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 19:35
@JLuboff I still have issues with it I need to practice with it.
Jason Luboff
@JLuboff
Mar 02 2018 19:36
@gulsvi Thanks
CamperBot
@camperbot
Mar 02 2018 19:36
jluboff sends brownie points to @gulsvi :sparkles: :thumbsup: :sparkles:
:star2: 2634 | @gulsvi |http://www.freecodecamp.org/gulsvi
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 19:36
I need to do better
Markus Kiili
@Masd925
Mar 02 2018 19:37
@JLuboff And the most important factors: 4 kinds of coffee there waiting to be drunk all the time and no PHP anywhere :sparkles:
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 19:40
I need a run down of all of it.
Christopher McCormack
@cmccormack
Mar 02 2018 19:40
@kelechy heya
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 19:40
I think I like mySQL with Node.
Jason Luboff
@JLuboff
Mar 02 2018 19:41
@Masd925 Beautiful!
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 19:41
@cmccormack I wanted something with express. bcrypt and passport.js
Jason Luboff
@JLuboff
Mar 02 2018 19:42
@RoniqueRicketts I've been building my latest app using MS SQL and node....I still found mongo to be a much much better choice but I need to use SQL for this so it is what it is
Christopher McCormack
@cmccormack
Mar 02 2018 19:42
@RoniqueRicketts so find it, this is a good start though :)
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 19:42
@JLuboff I will learn mongodb soon.
john94
@lpy1994
Mar 02 2018 19:42
hey guys, i got a question here.
Christopher McCormack
@cmccormack
Mar 02 2018 19:42
bcrypt is very simple to add on
john94
@lpy1994
Mar 02 2018 19:42
<script type="text/paperscript" canvas="myCanvas">
    // Create a Paper.js Path to draw a line into it:
    var path = new Path();
    // Give the stroke a color
    path.strokeColor = 'black';
    var start = new Point(100, 100);
    // Move to start and draw a line from there
    path.moveTo(start);
    // Note the plus operator on Point objects.
    // PaperScript does that for us, and much more!
    path.lineTo(start + [ 100, -50 ]);
</script>
Christopher McCormack
@cmccormack
Mar 02 2018 19:43
@RoniqueRicketts https://github.com/cmccormack/voting-app i've got all that in my app along with React if you want to walk through the code. It's not done from a usability standpoint but all the stuff you're looking for is implemented
john94
@lpy1994
Mar 02 2018 19:43
why is javascript in script doesnt work? they appear to be comments instead of javascript
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 19:43
@cmccormack Ya i learnt node and express just not the passport.js and bcrypt.
@cmccormack im o look
Gulsvi
@gulsvi
Mar 02 2018 19:47

@lpy1994

<canvas id="myCanvas" resize></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/paper.js/0.11.5/paper-full.min.js"></script>
<script type="text/paperscript" canvas="myCanvas">
    // Create a Paper.js Path to draw a line into it:
    var path = new Path();
    // Give the stroke a color
    path.strokeColor = 'black';
    var start = new Point(100, 100);
    // Move to start and draw a line from there
    path.moveTo(start);
    // Note the plus operator on Point objects.
    // PaperScript does that for us, and much more!
    path.lineTo(start + [ 100, -50 ]);
</script>

^ That works for me

Jason Luboff
@JLuboff
Mar 02 2018 19:48
I didn't look close enough, I meant to include the import of the actual paper.js library
So what @gulsvi has
john94
@lpy1994
Mar 02 2018 19:48
let me try loading paper-full-min instead.
Christopher McCormack
@cmccormack
Mar 02 2018 19:49
bbiab
john94
@lpy1994
Mar 02 2018 19:50
are you using vs code ? @gulsvi
Gulsvi
@gulsvi
Mar 02 2018 19:51
@lpy1994 I have it installed, but I tested the code above in codepen
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 19:52
@cmccormack thanks bruv. May your codes be bug free. I know that's the highest blessing in the land of coding.
CamperBot
@camperbot
Mar 02 2018 19:52
roniquericketts sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1358 | @cmccormack |http://www.freecodecamp.org/cmccormack
Christopher McCormack
@cmccormack
Mar 02 2018 19:53
@RoniqueRicketts haha thanks - probably not bug free but it works ok so far
CamperBot
@camperbot
Mar 02 2018 19:53
cmccormack sends brownie points to @roniquericketts :sparkles: :thumbsup: :sparkles:
:cookie: 416 | @roniquericketts |http://www.freecodecamp.org/roniquericketts
john94
@lpy1994
Mar 02 2018 19:54
can you try on your vs code instead?
also notice that if i change paperscript to javascript everything would go normal.
jusgoose
@gusd773
Mar 02 2018 19:55
how would I get to fit my new variables lat & lon to work into my url for the api call for weather?
   $(document).ready(function(){

var lat = 0;
var lng = 0;
if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
   lat= position.coords.latitude;          
    lng= position.coords.longitude;


$.getJSON("https://api.openweathermap.org/data/2.5/weather?lat=35&lon=139")  ;
}
)

}

});
Gulsvi
@gulsvi
Mar 02 2018 19:55
@lpy1994 Why don't you talk to the authors of the script and see if they can help? https://github.com/paperjs/paper.js/issues
They have a discussion forum here: http://groups.google.com/group/paperjs
Jason Luboff
@JLuboff
Mar 02 2018 19:56
@gusd773 You need to use either string concatenation or template strings to include them in the url
jusgoose
@gusd773
Mar 02 2018 19:57
@JLuboff tru
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 19:59
@cmccormack yaaa hehehe
Gulsvi
@gulsvi
Mar 02 2018 20:00
@gusd773 Also, use the information they provide here: https://fcc-weather-api.glitch.me/
You'll need an API key if you want to use the URL you're trying to use
john94
@lpy1994
Mar 02 2018 20:00
got it
Adel
@AdelMahjoub
Mar 02 2018 20:15
Anyone have a webpack-typescript setup to share where public and interface keywords works please ?
I have this webpack.config.js, but it is working as if it was es6 with typings
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');

const dev = process.env.WEBPACK_BUILD_MODE  === 'development' ? true : false;

const config = { 
    entry: { 
        bundle:  path.resolve('src/main.ts'),
        phaser: ['pixi', 'p2', 'phaser']
    }, 
    output: { 
        path: path.resolve('dist'), 
        filename: dev ? '[name].js' : '[name].[chunkhash:8].js',
        publicPath: '/' 
    },
    resolve: { 
        extensions: ['.ts', '.js'],
        alias: {
            pixi: path.resolve('node_modules/phaser/build/custom/pixi.js'),
            phaser: path.resolve('node_modules/phaser/build/custom/phaser-split.js'),
            p2: path.resolve('node_modules/phaser/build/custom/p2.js')
        } 
    },
    context: __dirname, 
    module: {
        rules: [
            {
                test: '/\.ts$/',
                exclude: '/node_modules/',
                use: [
                    { 
                        loader: 'cache-loader' 
                    },
                    {
                        loader: 'thread-loader',
                        options: { workers: require('os').cpus().length - 1 }
                    },
                    { 
                        loader: 'ts-loader', 
                        options: { happyPackMode: true }
                    }
                ]
            },
            { test: /pixi\.js$/, use: 'expose-loader?PIXI' },
            { test: /phaser-split\.js$/, use: 'expose-loader?Phaser' },
            { test: /p2\.js$/, use: 'expose-loader?p2' },
        ]
    },
    plugins: [
        new webpack.DefinePlugin({ IN_DEVELOPMENT: JSON.stringify(dev) }),
        new webpack.optimize.CommonsChunkPlugin({
            name: 'phaser',
            filename: 'phaser.js'
        }),
        new HtmlWebpackPlugin({ 
            template: path.resolve('src/index.html'),
            inject: 'body',
            chunks: ['phaser', 'bundle'],
            chunkSortMode: 'manual',
            minify: !dev 
        }),
        new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true  }),
        new CleanWebpackPlugin(['dist']),
        new CopyWebpackPlugin([{from: path.resolve('assets'), to: path.resolve('dist/assets')}])
    ],
    watch: dev,
    devtool: dev ? 'cheap-module-eval-source-map' : false,
    devServer: {
        hot: true,
        compress: true,
        overlay: true,
        proxy: {
            '/api': {
                target: 'http://localhost:8080'
            }
        }
    }
};

if(!dev) {
    config.plugins.push(new webpack.optimize.UglifyJsPlugin());
} else {
    config.plugins.push(new webpack.WatchIgnorePlugin([/\.js$/, /\.d\.ts$/]))
}
Adel
@AdelMahjoub
Mar 02 2018 20:21
I get this error when using this
Module parse failed: The keyword 'interface' is reserved (7:0)
You may need an appropriate loader to handle this file type.
interface IGameConfig {
    width: number;
    height: number;
    renderer: number;
}
same if I use the public keyword for public properties
same error when using awesome-typescript-loader
and same error when using babel-loader after any ts loader
Adel
@AdelMahjoub
Mar 02 2018 20:29
this is magic
Christopher McCormack
@cmccormack
Mar 02 2018 20:29
@AdelMahjoub have you tried using test: '/\.tsx?$/', instead of test: '/\.ts$/',?
Adel
@AdelMahjoub
Mar 02 2018 20:30
@cmccormack it works, after a lot of ctr+c and npm start
Christopher McCormack
@cmccormack
Mar 02 2018 20:30
@AdelMahjoub :D
webpack is just the worst when troubleshooting stuff like that
Adel
@AdelMahjoub
Mar 02 2018 20:30
@cmccormack no clue why, it seems you only need to post a question here to make things works
Christopher McCormack
@cmccormack
Mar 02 2018 20:31
@AdelMahjoub I think the idea is part of your brain doesn't want someone to solve it before you do so it goes into overdrive
Adel
@AdelMahjoub
Mar 02 2018 20:32
@cmccormack :laughing: maybe
@cmccormack thanks for the help :+1:
CamperBot
@camperbot
Mar 02 2018 20:34
:star2: 1359 | @cmccormack |http://www.freecodecamp.org/cmccormack
adelmahjoub sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
Christopher McCormack
@cmccormack
Mar 02 2018 20:37
@AdelMahjoub I know most people probably aren't using TS but you mind sharing what the actual issue is, so maybe somewhere down the line if we run into it we'll remember your issue?
Adel
@AdelMahjoub
Mar 02 2018 20:41
@cmccormack public, interface and private keywords were not working
@cmccormack it was es6 with typings not typescript
@cmccormack but I need to reproduce the issue now
Christopher McCormack
@cmccormack
Mar 02 2018 20:42
@AdelMahjoub :thumbsup: thanks and good luck
CamperBot
@camperbot
Mar 02 2018 20:42
cmccormack sends brownie points to @adelmahjoub :sparkles: :thumbsup: :sparkles:
:cookie: 661 | @adelmahjoub |http://www.freecodecamp.org/adelmahjoub
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 20:47
@AdelMahjoub soon you will have 666 points :)soon you will have 666 points :)
@cmccormack i fig
Christopher McCormack
@cmccormack
Mar 02 2018 20:47
:whistles:
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 20:47
that devil boi
boss aint here today so I may take a nap at my desk. Was up all night reading through react native
now sleep is killing me
Adel
@AdelMahjoub
Mar 02 2018 20:50
:imp: what about those who have more than 666 cookies :laughing:
@bot substract cookies from now !
Christopher McCormack
@cmccormack
Mar 02 2018 20:50
@RoniqueRicketts tape some googly eyes to your eyelids and prop your head up, noone will know you aren't working
@AdelMahjoub they're all devils
Ronique Ricketts
@RoniqueRicketts
Mar 02 2018 20:51
@cmccormack lol, i wish I had a pillow at my desk yow.
Christopher McCormack
@cmccormack
Mar 02 2018 20:52
get one of those airplane pillows and lean back
Jason Luboff
@JLuboff
Mar 02 2018 21:05
@cmccormack The U shaped ones? They're awful...at least the ones I've used lol
Christopher McCormack
@cmccormack
Mar 02 2018 21:06
Seems half the people in the airport have them now, and they're all memory foam now too
Christopher McCormack
@cmccormack
Mar 02 2018 21:13
Pretty great article from last month - Lots of stuff I wish I had known or thought of when first starting: https://medium.com/@samerbuna/the-mistakes-i-made-as-a-beginner-programmer-ac8b3e54c312
Jason Luboff
@JLuboff
Mar 02 2018 21:33
@cmccormack I like #6
jusgoose
@gusd773
Mar 02 2018 21:36
wanted to change my TEMP text to black but it won't let me

<div class= "text-center temps">
  <h2> TEMP </h2></div>




}
.temps{
  color:black;
}
Matej Bošnjak
@mbosnjak01
Mar 02 2018 21:46
<style>
.temps {
color:black;
}
</style>
<div class="text-center temps">
     <h2> TEMP </h2>
</div>
@gusd773 try this
jusgoose
@gusd773
Mar 02 2018 21:47
@mbosnjak01 i'm doing it with codepen so the style sheet is seperate but it still won't work
Matej Bošnjak
@mbosnjak01
Mar 02 2018 21:47
link codepen
Jason Luboff
@JLuboff
Mar 02 2018 21:49
@gusd773 It's becuase you're setting h2 to white
jusgoose
@gusd773
Mar 02 2018 21:50
@JLuboff tru I changed it to h3 tag i'll resize in css thank you
CamperBot
@camperbot
Mar 02 2018 21:50
gusd773 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2354 | @jluboff |http://www.freecodecamp.org/jluboff
Jason Luboff
@JLuboff
Mar 02 2018 21:50
Do .temps h2 {
jusgoose
@gusd773
Mar 02 2018 21:51
@JLuboff genius

now question, anybody know what to make of these temps?

https://openweathermap.org/current#geo

they say 300 degrees i doubt thats in cesiius or farenheit lol

Jason Luboff
@JLuboff
Mar 02 2018 21:52
Its in kelvin

You should read the entirity of the documentation, it states under unit

Temperature is available in Fahrenheit, Celsius and Kelvin units.

    For temperature in Fahrenheit use units=imperial
    For temperature in Celsius use units=metric
    Temperature in Kelvin is used by default, no need to use units parameter in API cal

https://openweathermap.org/current#data

Matej Bošnjak
@mbosnjak01
Mar 02 2018 21:54
@gusd773 you can call C or F temperature if it's inside api, but if just one is there, you can do a conversion by a formula on click or hover, or show both at the same time (using conversion formula)
jusgoose
@gusd773
Mar 02 2018 21:54
@JLuboff will do, does this look like it'll change something?

   $(document).ready(function(){

var lat = 0;
var lng = 0;
if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
   lat= position.coords.latitude;          
    lng= position.coords.longitude;


$.getJSON("https://api.openweathermap.org/data/2.5/weather?"+"lat="+lat+"&lon="+lng, function(data){
      $(".location").html(data[0].name + ", " + data[3].sys);
$(".temps").html(data[0].name + ", " + data[3].sys);
});
})

}

});
@mbosnjak01 thank you
CamperBot
@camperbot
Mar 02 2018 21:54
gusd773 sends brownie points to @mbosnjak01 :sparkles: :thumbsup: :sparkles:
:cookie: 238 | @mbosnjak01 |http://www.freecodecamp.org/mbosnjak01
Matej Bošnjak
@mbosnjak01
Mar 02 2018 21:58
god ... looks like I didn't save my weather app nowhere and it's gone ... guess I'll have to recreate that :s
jusgoose
@gusd773
Mar 02 2018 21:59
@mbosnjak01 it's not that bad if you get api's
Matej Bošnjak
@mbosnjak01
Mar 02 2018 21:59
oh, found it
Jason Luboff
@JLuboff
Mar 02 2018 22:00
@gusd773 Two things, one you don't have jQuery loaded in codepen, so no nothing there is going to work. And second, as someone else mentioned already, you need an API key for openweathermap.
jusgoose
@gusd773
Mar 02 2018 22:00
@JLuboff I'm on it
Matej Bošnjak
@mbosnjak01
Mar 02 2018 22:01
@gusd773 if weatherapi is giving you trouble, use https://fcc-weather-api.glitch.me/api/current?lat="+lat+"&lon="+lon to finish your challenge
@JLuboff Would you be that kind and check out my JS code on the bottom of this? https://codepen.io/fcccder/pen/qpVwyY -> specificaly the part for night and day background on the bottom, as it's not working and I don't know why ... I just get night background all the time :O
Jason Luboff
@JLuboff
Mar 02 2018 22:07
@mbosnjak01 Shouldn't the numbers here: d.getTime() > 1515220092 && d.getTime() < 1515252072 be different every day?
getTime() is returning the UTC time since Jan 1 1970 in milliseconds
Matej Bošnjak
@mbosnjak01
Mar 02 2018 22:07
damn
I don't know what I was thinking :laughing: thanks @JLuboff
CamperBot
@camperbot
Mar 02 2018 22:08
mbosnjak01 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2355 | @jluboff |http://www.freecodecamp.org/jluboff
Jason Luboff
@JLuboff
Mar 02 2018 22:08
I always use momentjs when dealing with time
One I'm lazy, and two, it makes things easy lol
Documentation is really good too. Lots you can do
Matej Bošnjak
@mbosnjak01
Mar 02 2018 22:09
I don't deal much with time, but I'll bookmark it :)
Jason Luboff
@JLuboff
Mar 02 2018 22:10
It's a great library, I highly recomend it :D
Matej Bošnjak
@mbosnjak01
Mar 02 2018 22:14
alright, i kind of fixed it, i'll see if something changes in the morning xD
Jason Luboff
@JLuboff
Mar 02 2018 22:16
:P
jusgoose
@gusd773
Mar 02 2018 22:18
@JLuboff https://codepen.io/gusd773/pen/qxgjxP I have my appid in the url now but it won't change any html, it does ask for my location now tho
Jason Luboff
@JLuboff
Mar 02 2018 22:19
console.log() is your friend. Try doing console.log(data); in your json call and see what oyu get
Matej Bošnjak
@mbosnjak01
Mar 02 2018 22:20
@gusd773 I remember having issues with openweatherapi as well, i don't remember how i resolved them, but I did ... although I didn't stick with it
jusgoose
@gusd773
Mar 02 2018 22:20
@mbosnjak01 i don't give up
Matej Bošnjak
@mbosnjak01
Mar 02 2018 22:20
I should switch back to that so I could expand my app
and I should make my share button functional as well, totaly forgot about that :|
jusgoose
@gusd773
Mar 02 2018 22:22
@JLuboff i did that but nothing pops up
Jason Luboff
@JLuboff
Mar 02 2018 22:22
Exactly
So there's an issue with your url. Try copying your url into a console.log() and then paste that url into your browser and see what it returns
Matej Bošnjak
@mbosnjak01
Mar 02 2018 22:23
{"cod":401, "message": "Invalid API key. Please see http://openweathermap.org/faq#error401 for more info."}
this is what you get
in console
jusgoose
@gusd773
Mar 02 2018 22:24
how do you guys get those errors, codepen doesn't let me see those
Christopher McCormack
@cmccormack
Mar 02 2018 22:24
@gusd773 use your developer console, not codepen's
Matej Bošnjak
@mbosnjak01
Mar 02 2018 22:24
yep ^
Christopher McCormack
@cmccormack
Mar 02 2018 22:24
Usually you can see it by hitting F12, or look in the options
Jason Luboff
@JLuboff
Mar 02 2018 22:25
Or you can do what I said to, and you'll most likely see that same eror
alpox
@alpox
Mar 02 2018 22:25
Or if that doesn't work: Ctrl-Shift-I or when you are on mac: Cmd-Alt-I
Christopher McCormack
@cmccormack
Mar 02 2018 22:25
codepen's console is really only good for viewing console.log statements
Matej Bošnjak
@mbosnjak01
Mar 02 2018 22:26
for a moment my app broke, was showing I was in japan XD
Jason Luboff
@JLuboff
Mar 02 2018 22:26
Ugh... I hate data entry.
Creating my person's table..
Matej Bošnjak
@mbosnjak01
Mar 02 2018 22:27
inserting users one by one?
or... :|
Jason Luboff
@JLuboff
Mar 02 2018 22:28
All in one insert, but ya essentially. I guess I could try and use powershell to export them but its only ~22 individuals
Eh..actually a few more than that but meh
Matej Bošnjak
@mbosnjak01
Mar 02 2018 22:29
@gusd773 You need to use HTTPS protocol, not HTTP inside your api link
jusgoose
@gusd773
Mar 02 2018 22:29
@mbosnjak01 I fixed that and am using my give api key but idk why it won't work
Jason Luboff
@JLuboff
Mar 02 2018 22:31
@cmccormack Got plans tomorrow? Wanna take a quick drive over to help me move? I'll provide you with a couple of beers, and a mediocore lunch?
Christopher McCormack
@cmccormack
Mar 02 2018 22:35
Data entry??? only if we can find a way to automate
quick 8 hour drive haha
Jason Luboff
@JLuboff
Mar 02 2018 22:36
You could make it in 6!
Christopher McCormack
@cmccormack
Mar 02 2018 22:36
haha
Jason Luboff
@JLuboff
Mar 02 2018 22:37
Come on, you could enjoy the beach! (ok thats a lie, its kind of cloudy/rainy/cold)
Christopher McCormack
@cmccormack
Mar 02 2018 22:37
I would but I'd much prefer the manual labor I have to do tomorrow :D
Jason Luboff
@JLuboff
Mar 02 2018 22:38
....but moving is manual labor... :joy:
Christopher McCormack
@cmccormack
Mar 02 2018 22:38
ohhh I conflated your data entry with going over there haha
Jason Luboff
@JLuboff
Mar 02 2018 22:38
Oh nahh. The data entry is almost done
I'm talking actual physical moving
Christopher McCormack
@cmccormack
Mar 02 2018 22:39
Could you wait a few weeks? I was supposed to go to cali in April to visit my bro
Although he's up in Modesto which I don't believe is very close
Jason Luboff
@JLuboff
Mar 02 2018 22:39
Nope. Already got the uhaul and everything ready to go for tomorrow.
Oh ya modesto is way out of the way
Christopher McCormack
@cmccormack
Mar 02 2018 22:39
Put that baby to work
Jason Luboff
@JLuboff
Mar 02 2018 22:40
like... 5-6 hours away? Modesto is near sacremento
Christopher McCormack
@cmccormack
Mar 02 2018 22:40
Jeeze your state is too large
Jason Luboff
@JLuboff
Mar 02 2018 22:40
Haha I'm going to ! Otherwise I have some other people to help, really just need help on the move in I think since we're going into a second floor unit
Thats why people want to split California into three seperate states :joy: Crazy if you as kme
Matej Bošnjak
@mbosnjak01
Mar 02 2018 22:41
@gusd773 i found your issue
sec
Christopher McCormack
@cmccormack
Mar 02 2018 22:41
@JLuboff They just need to get that hyperloop thing setup :)
Jason Luboff
@JLuboff
Mar 02 2018 22:42
That thing does sound cool.. unlike the stupid bullet train
Christopher McCormack
@cmccormack
Mar 02 2018 22:43
I just wish there were easier ways to get between major cities in the US
Matej Bošnjak
@mbosnjak01
Mar 02 2018 22:43
@gusd773 Do this -> https://i.imgur.com/Xcs09hU.png
Jason Luboff
@JLuboff
Mar 02 2018 22:43
I agree. Its easy in Europe. Here, not so much
Christopher McCormack
@cmccormack
Mar 02 2018 22:43
Who wants to drive themselves when they could be playing their switch or whatever
Matej Bošnjak
@mbosnjak01
Mar 02 2018 22:44
@gusd773 you had issue both in url and data calls
Jason Luboff
@JLuboff
Mar 02 2018 22:46
@cmccormack One time I took an amtrak from here to napa valley. It was nice that I didn't have to drive, but took just as long as if I did partly becuase it required me to take two different buses and a train but I was able to read and just relax which was nice
Matej Bošnjak
@mbosnjak01
Mar 02 2018 22:46
@gusd773 data.sys.country instead of data.sys there
Christopher McCormack
@cmccormack
Mar 02 2018 22:47
@JLuboff I went to Europe a few years ago staying in Vienna, I could take a train from a few blocks away to almost any city center, went to Graz and Budapest and just sat drinking in the restaurant car, was amazing.
jusgoose
@gusd773
Mar 02 2018 22:48
@mbosnjak01 when do I have to use bracket notation then?
Matej Bošnjak
@mbosnjak01
Mar 02 2018 22:50
@gusd773 I used them when I have multiple objects inside an object ... for example
var object = { "objectOne": [ {"property1: "p1", "property2": "p2" }, { "property1":"s1", "property2":"k4 } ] }
because [] is for calling stuff from an array (mostly :P )
Christopher McCormack
@cmccormack
Mar 02 2018 22:50
@gusd773 examples:
> var object = { 'a': 'apple', 'b': 'banana' }
> object
{ a: 'apple', b: 'banana' }
> object.a
'apple'
> object['a']
'apple'
> object[a]
undefined
> var test = 'a'
> object[test]
'apple'
> object.test
undefined
Matej Bošnjak
@mbosnjak01
Mar 02 2018 22:51
and what @cmccormack said :D
Christopher McCormack
@cmccormack
Mar 02 2018 22:51

You can only use dot notation when you know the property name AND it fits a specific formatting:

alphanumerical characters, also including the underscore ("_") and dollar sign ("$"), that cannot start with a number. For example, object.$1 is valid, while object.1 is not.

Gulsvi
@gulsvi
Mar 02 2018 22:52
and when the property name has spaces in it
or special characters? I'd have to check
alpox
@alpox
Mar 02 2018 22:52
@gusd773 You use bracket notation to get properties of an object when:
  • The key you want to look up is stored in a variable
  • The key starts with a number
  • The key has spaces or other special characters in it which don't count as word characters
Gulsvi
@gulsvi
Mar 02 2018 22:52
Thank you @alpox saved me that check
CamperBot
@camperbot
Mar 02 2018 22:52
gulsvi sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1565 | @alpox |http://www.freecodecamp.org/alpox
alpox
@alpox
Mar 02 2018 22:53
Just to summarize all that :D
Matej Bošnjak
@mbosnjak01
Mar 02 2018 22:53
I am always prefering to use dot notation instead of brackets
Christopher McCormack
@cmccormack
Mar 02 2018 22:54
Occassionally you don't have a choice, but using dot notation on known properties is usually the standard
alpox
@alpox
Mar 02 2018 22:54
@cmccormack I second that. Whenever you can, use dot notation. When you cannot, use bracket notation.
Gulsvi
@gulsvi
Mar 02 2018 22:55
I prefer using eval() on the object :trollface:
alpox
@alpox
Mar 02 2018 22:56
@gulsvi ---> There's the door :clap:
:D
Gulsvi
@gulsvi
Mar 02 2018 22:56
Security first, right?! :)
alpox
@alpox
Mar 02 2018 22:56
Always
Christopher McCormack
@cmccormack
Mar 02 2018 22:58
@alpox only problem I have is python is only bracket notation so going back and forth stinks :)
alpox
@alpox
Mar 02 2018 22:59
@cmccormack Hmm well that are not really objects there, that are dicts
When you use classes you occasionally have dot syntax :D
Christopher McCormack
@cmccormack
Mar 02 2018 22:59
they're all maps
alpox
@alpox
Mar 02 2018 22:59
Well whatever you wanna call it :D
But they say dicts to them usually
Christopher McCormack
@cmccormack
Mar 02 2018 23:00
But those are for class atributes
a dict and an object are just maps
alpox
@alpox
Mar 02 2018 23:00
Yea they are
Hashmaps in theory
Christopher McCormack
@cmccormack
Mar 02 2018 23:01
Or associative array
honestly I think it's all the same thing haha
alpox
@alpox
Mar 02 2018 23:01
One of my profs made me cringe each time he talked about the dicts in python (or map).
He called them hashes
Christopher McCormack
@cmccormack
Mar 02 2018 23:02
well that's how they're referenced so not incorrect I guess :)
but a hash would just be the output, not the data structure
alpox
@alpox
Mar 02 2018 23:03
Hmm it is incorrect because a hash is the hash value of a key which is used for the mapping. The datastructure itself can therefore not be called hash
Christopher McCormack
@cmccormack
Mar 02 2018 23:03
Maybe he was referring to each key/property? haha I don't kow
alpox
@alpox
Mar 02 2018 23:04
No, really to the datastructure
my_dict = dict()
He would say that my_dict is a hash
But that one teached computerlinguistics and didn't understand much of the underlying theory as it seemed :D
Jason Luboff
@JLuboff
Mar 02 2018 23:05
I don't care to hear about your_dict
Christopher McCormack
@cmccormack
Mar 02 2018 23:05
I guess, sucks to have them confuse students for no good reason
haha @JLuboff
Jason Luboff
@JLuboff
Mar 02 2018 23:05
I've been working on my dad jokes
alpox
@alpox
Mar 02 2018 23:05
@JLuboff Well, i didn't tell you to imagine other characters :P
Jason Luboff
@JLuboff
Mar 02 2018 23:05
Gotta start embrassing them young you know?
@alpox ;)
Christopher McCormack
@cmccormack
Mar 02 2018 23:09
Everyone's a comedian today :)
Well I'm out for a while - good luck on your move tomorrow @JLuboff!
Jason Luboff
@JLuboff
Mar 02 2018 23:10
@cmccormack Thanks, catch next week
CamperBot
@camperbot
Mar 02 2018 23:10
jluboff sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1360 | @cmccormack |http://www.freecodecamp.org/cmccormack
jusgoose
@gusd773
Mar 02 2018 23:56
@mbosnjak01 still giving me api problems