These are chat archives for FreeCodeCamp/Help

27th
Oct 2017
Victor Abeledo
@victorja
Oct 27 2017 00:02
:+1:
I have migraine now
korzo
@korzo
Oct 27 2017 00:03
@kbaig sorry, :point_up: October 27, 2017 1:58 AM was meant for @victorja
Kaz Baig
@kbaig
Oct 27 2017 00:05
o hehe
Jill Lee
@jill-lee
Oct 27 2017 01:07
@heroiczero thanks I'll try that :)
CamperBot
@camperbot
Oct 27 2017 01:07
phoenix-burn sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1954 | @heroiczero |http://www.freecodecamp.com/heroiczero
Jill Lee
@jill-lee
Oct 27 2017 01:07
@korzo @thekholm80 @daddycardona Thanks to the regulars :)
CamperBot
@camperbot
Oct 27 2017 01:07
phoenix-burn sends brownie points to @korzo and @thekholm80 and @daddycardona :sparkles: :thumbsup: :sparkles:
:star2: 1540 | @thekholm80 |http://www.freecodecamp.com/thekholm80
:cookie: 676 | @korzo |http://www.freecodecamp.com/korzo
:cookie: 423 | @daddycardona |http://www.freecodecamp.com/daddycardona
Kyle Holm
@thekholm80
Oct 27 2017 01:08
@phoenix-burn hey thank you too!
CamperBot
@camperbot
Oct 27 2017 01:08
thekholm80 sends brownie points to @phoenix-burn :sparkles: :thumbsup: :sparkles:
:cookie: 166 | @phoenix-burn |http://www.freecodecamp.com/phoenix-burn
Kaz Baig
@kbaig
Oct 27 2017 01:21
I have a silly question
Can I do import express from 'express'
Kyle Holm
@thekholm80
Oct 27 2017 01:28
nope
Kaz Baig
@kbaig
Oct 27 2017 01:28
por que
because it doesn't use export
Kyle Holm
@thekholm80
Oct 27 2017 01:28
@kbaig you'd have to configure babel to do that
Kaz Baig
@kbaig
Oct 27 2017 01:28
?
would it have to be using export default instead of module.exports?
Kyle Holm
@thekholm80
Oct 27 2017 01:28
import is part of ES6 (i think) that wasn't included in Node ES6 implementation
Kaz Baig
@kbaig
Oct 27 2017 01:29
aha
Kyle Holm
@thekholm80
Oct 27 2017 01:29
so
Kaz Baig
@kbaig
Oct 27 2017 01:29
thanks @thekholm80
CamperBot
@camperbot
Oct 27 2017 01:29
kbaig sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1541 | @thekholm80 |http://www.freecodecamp.com/thekholm80
Kyle Holm
@thekholm80
Oct 27 2017 01:29
:+1:
getting babel to work in node isn't too awfully hard, but it's much easier to just use require()
Kaz Baig
@kbaig
Oct 27 2017 01:33
@thekholm80 I'm doing a mern app initiated with create-react-app
Kyle Holm
@thekholm80
Oct 27 2017 01:33
oh cool
Kaz Baig
@kbaig
Oct 27 2017 01:33
so I'm importing in my src/ files
was wondering why I can't for my server.js file
Kyle Holm
@thekholm80
Oct 27 2017 01:34
yeah i don't know much about create-react-app
i've used it a few times, but i'm so used to doing things my way it was more annoying than anything
Kaz Baig
@kbaig
Oct 27 2017 01:39
Well I am a noob so can't try to pick up everything at the same time :/
Kyle Holm
@thekholm80
Oct 27 2017 01:39
I'm sure if i'd have started out using create-react-app i'd love it
and I do use it for electron apps
Long Nguyen
@longnt80
Oct 27 2017 01:41
@kbaig maybe the babel config of create-react-app only look into the src/ folder?
Kaz Baig
@kbaig
Oct 27 2017 01:41
@longnt80 I was actually just reading that
Kyle Holm
@thekholm80
Oct 27 2017 01:42
webpack runs babel when it does it's magic, but your backend doesn't run through webpack
Kaz Baig
@kbaig
Oct 27 2017 01:44
yeah I could just put it in src/ and it would be fine
no need though
korzo
@korzo
Oct 27 2017 01:52
@phoenix-burn Hi, thanks
CamperBot
@camperbot
Oct 27 2017 01:52
:cookie: 167 | @phoenix-burn |http://www.freecodecamp.com/phoenix-burn
korzo sends brownie points to @phoenix-burn :sparkles: :thumbsup: :sparkles:
Gilarath
@Gilarath
Oct 27 2017 02:05
Hey guys for my Random Quote Generator how do you get a tweet button to tweet the quote?
korzo
@korzo
Oct 27 2017 02:09
@Gilarath compose it as the link https://twitter.com/intent/tweet?text=' + encodeURIComponent('"' + quote + '" ' + author));
Manish Giri
@Manish-Giri
Oct 27 2017 03:31
@DarrenfJ @khaduch @daddycardona @alpox @thekholm80 @heroiczero @sjames1958gm @Marmiz ty! help on, code on :star:
CamperBot
@camperbot
Oct 27 2017 03:31
manish-giri sends brownie points to @darrenfj and @khaduch and @daddycardona and @alpox and @thekholm80 and @heroiczero and @sjames1958gm and @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 2189 | @darrenfj |http://www.freecodecamp.com/darrenfj
:star2: 1407 | @alpox |http://www.freecodecamp.com/alpox
:cookie: 424 | @daddycardona |http://www.freecodecamp.com/daddycardona
:star2: 1955 | @heroiczero |http://www.freecodecamp.com/heroiczero
:star2: 3414 | @khaduch |http://www.freecodecamp.com/khaduch
:star2: 8619 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 1065 | @marmiz |http://www.freecodecamp.com/marmiz
:star2: 1542 | @thekholm80 |http://www.freecodecamp.com/thekholm80
Manish Giri
@Manish-Giri
Oct 27 2017 03:31
@korzo ty too
CamperBot
@camperbot
Oct 27 2017 03:31
manish-giri sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 677 | @korzo |http://www.freecodecamp.com/korzo
heroiczero
@heroiczero
Oct 27 2017 03:59
@Manish-Giri @korzo @thekholm80 @longnt80 @daddycardona @khaduch @GitHub-Henry @DarrenfJ @sjames1958gm TY for Helping the FCC Help :)
CamperBot
@camperbot
Oct 27 2017 03:59
heroiczero sends brownie points to @manish-giri and @korzo and @thekholm80 and @longnt80 and @daddycardona and @khaduch and @github-henry and @darrenfj and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 617 | @longnt80 |http://www.freecodecamp.com/longnt80
:cookie: 678 | @korzo |http://www.freecodecamp.com/korzo
:star2: 1543 | @thekholm80 |http://www.freecodecamp.com/thekholm80
:star2: 6704 | @manish-giri |http://www.freecodecamp.com/manish-giri
:cookie: 425 | @daddycardona |http://www.freecodecamp.com/daddycardona
:cookie: 425 | @github-henry |http://www.freecodecamp.com/github-henry
:star2: 8620 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 2190 | @darrenfj |http://www.freecodecamp.com/darrenfj
:star2: 3415 | @khaduch |http://www.freecodecamp.com/khaduch
korzo
@korzo
Oct 27 2017 04:01
@Manish-Giri @heroiczero thanks too guys
CamperBot
@camperbot
Oct 27 2017 04:01
korzo sends brownie points to @manish-giri and @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1956 | @heroiczero |http://www.freecodecamp.com/heroiczero
:star2: 6705 | @manish-giri |http://www.freecodecamp.com/manish-giri
Henry
@GitHub-Henry
Oct 27 2017 04:02
@heroiczero hello and thank you
CamperBot
@camperbot
Oct 27 2017 04:02
github-henry sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1957 | @heroiczero |http://www.freecodecamp.com/heroiczero
Darren
@DarrenfJ
Oct 27 2017 05:04
evening fCC
and many thank yous :D
thanks @GitHub-Henry @Manish-Giri @korzo @heroiczero @longnt80 @daddycardona @khaduch @sjames1958gm @thekholm80
CamperBot
@camperbot
Oct 27 2017 05:05
darrenfj sends brownie points to @github-henry and @manish-giri and @korzo and @heroiczero and @longnt80 and @daddycardona and @khaduch and @sjames1958gm and @thekholm80 :sparkles: :thumbsup: :sparkles:
:cookie: 426 | @github-henry |http://www.freecodecamp.com/github-henry
:star2: 1959 | @heroiczero |http://www.freecodecamp.com/heroiczero
:cookie: 679 | @korzo |http://www.freecodecamp.com/korzo
:cookie: 426 | @daddycardona |http://www.freecodecamp.com/daddycardona
:star2: 6706 | @manish-giri |http://www.freecodecamp.com/manish-giri
:star2: 3416 | @khaduch |http://www.freecodecamp.com/khaduch
:star2: 1544 | @thekholm80 |http://www.freecodecamp.com/thekholm80
:cookie: 618 | @longnt80 |http://www.freecodecamp.com/longnt80
:star2: 8621 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Henry
@GitHub-Henry
Oct 27 2017 05:12
@DarrenfJ good evening, & thank you
CamperBot
@camperbot
Oct 27 2017 05:12
github-henry sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2191 | @darrenfj |http://www.freecodecamp.com/darrenfj
korzo
@korzo
Oct 27 2017 05:15
@DarrenfJ Morning and thanks
CamperBot
@camperbot
Oct 27 2017 05:15
korzo sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2192 | @darrenfj |http://www.freecodecamp.com/darrenfj
Gilarath
@Gilarath
Oct 27 2017 07:24
Hey guys how would you get a location for doing the weather app?
Fabien SHAN
@X140hu4
Oct 27 2017 07:25
@Gilarath use the navigator geolocation functionn
Gilarath
@Gilarath
Oct 27 2017 07:26
@X140hu4 Ok cool ty I will look into it
CamperBot
@camperbot
Oct 27 2017 07:26
gilarath sends brownie points to @x140hu4 :sparkles: :thumbsup: :sparkles:
:cookie: 307 | @x140hu4 |http://www.freecodecamp.com/x140hu4
Fabien SHAN
@X140hu4
Oct 27 2017 07:28
@Gilarath np :) I am currently doing this one too
Gilarath
@Gilarath
Oct 27 2017 07:28
Nice GL on it
Fabien SHAN
@X140hu4
Oct 27 2017 07:28
@Gilarath thanks ! you too ^^
CamperBot
@camperbot
Oct 27 2017 07:28
x140hu4 sends brownie points to @gilarath :sparkles: :thumbsup: :sparkles:
:cookie: 263 | @gilarath |http://www.freecodecamp.com/gilarath
Gilarath
@Gilarath
Oct 27 2017 07:28
I think i almost got it fully done just need to get this location thing
Eric Miller
@ericmiller777
Oct 27 2017 07:53
@Gilarath a couple challenges back you get a persons location.
@Gilarath json apis, and ajax, under get geo location data
Thanh Son Nguyen
@nguyen-thanhson
Oct 27 2017 10:26
guys any idea on how to fix the Uncaught TypeError: gamestate.indexOf is not a function?
Manish Giri
@Manish-Giri
Oct 27 2017 10:26
@nguyen-thanhson check what gameState is
Thanh Son Nguyen
@nguyen-thanhson
Oct 27 2017 10:27
it is an array
it should work
stackoverflow says that this is due to the depreciation of load() function and the likes in jquery
but I don't use them. I even use on("click"), not click()
Stephen James
@sjames1958gm
Oct 27 2017 10:30
if indexOf is not a function then gamestate is not an array. Use console.log or debugger to see value of gamestate
Thanh Son Nguyen
@nguyen-thanhson
Oct 27 2017 10:33
guys I'm pretty sure gamestate is an array
I log it on the console but I don't quite know how to read it lol so can you check
Screen Shot 2017-10-27 at 5.33.59 PM.png
Stephen James
@sjames1958gm
Oct 27 2017 10:39
You can use console.log(Array.isArray(gamestate)) to see what browser thinks.
Where is gamestate intialized
@nguyen-thanhson You can post link to your pen if you want
Thanh Son Nguyen
@nguyen-thanhson
Oct 27 2017 10:41
this is where it is initialized
Screen Shot 2017-10-27 at 5.33.59 PM.png
oops wrong image
Screen Shot 2017-10-27 at 5.41.00 PM.png
oh and I checked using your method. The browser didn't think it is an array. weird...
thanks @sjames1958gm I'm looking into that
CamperBot
@camperbot
Oct 27 2017 10:43
nguyen-thanhson sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8622 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Manish Giri
@Manish-Giri
Oct 27 2017 10:43
as I had said..
Thanh Son Nguyen
@nguyen-thanhson
Oct 27 2017 10:44
@Manish-Giri yeah I guess it went wrong somewhere. Thanks by the way
CamperBot
@camperbot
Oct 27 2017 10:44
nguyen-thanhson sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6707 | @manish-giri |http://www.freecodecamp.com/manish-giri
Arif Vdm
@arifcodecamper
Oct 27 2017 12:33
Hi
I need a help with codepen.io interface. a portion of my js is printed in the page. How come ?
If I run this project on my local machine , It is working as expected.
Please help.
I would appreciate your timely help.
Thanks in advance.
Stephen James
@sjames1958gm
Oct 27 2017 12:50
@arifcodecamper It appears that codepen does not like your <script> tag in the middle of the javascript (even inside the "")
Arif Vdm
@arifcodecamper
Oct 27 2017 13:04
@sjames1958gm Oh ! What do I do now ?
I have to inject my quotes into tweet button dynamically.
Is there any other way to do it ?
Thanks for the response @sjames1958gm !!!
CamperBot
@camperbot
Oct 27 2017 13:05
arifcodecamper sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8623 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Oct 27 2017 13:05
@arifcodecamper That is a good question.
Could you put an empty script tag in the HTML and then reference it in js ?
Arif Vdm
@arifcodecamper
Oct 27 2017 13:07
ok, I will give it a try.
@sjames1958gm
Stephen James
@sjames1958gm
Oct 27 2017 13:08
@arifcodecamper good luck
Arif Vdm
@arifcodecamper
Oct 27 2017 13:14
@sjames1958gm it works . Thanks a lot !!!
CamperBot
@camperbot
Oct 27 2017 13:14
arifcodecamper sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
api offline
Stephen James
@sjames1958gm
Oct 27 2017 13:19
@arifcodecamper :+1:
Arif Vdm
@arifcodecamper
Oct 27 2017 13:22
@sjames1958gm Now could check my pen and give me your comments there or here? I've completed that challenge with your help.
bilaal-s
@bilaal-s
Oct 27 2017 13:50
:wave:
Stephen James
@sjames1958gm
Oct 27 2017 13:50
@arifcodecamper Looks good, I might make the quote box and text larger, the button shouldn't be larger than the text ;)
@bilaal-s :coffee:
bilaal-s
@bilaal-s
Oct 27 2017 13:51
I asume 2 player is not a requirment for tic tac toe? should I build this now or later?
the challenge instructions dont mention it
Stephen James
@sjames1958gm
Oct 27 2017 13:51
@arifcodecamper You might also want to check if the text sent to twitter is too long and truncate?
@bilaal-s I did not do two player, so it isn't required.
bilaal-s
@bilaal-s
Oct 27 2017 13:51
@sjames1958gm thanks
CamperBot
@camperbot
Oct 27 2017 13:51
bilaal-s sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8624 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Arif Vdm
@arifcodecamper
Oct 27 2017 13:53
@sjames1958gm ok, I've noted your suggestions. Thanks !!!
CamperBot
@camperbot
Oct 27 2017 13:53
arifcodecamper sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
api offline
Marc
@MWBauer
Oct 27 2017 15:02
Morning everyone!
I am working on the weather app and I have a list of pics for the changing background. I put them in image: {and when I try to close it, it says unexpected end to input.
any thoughts on why?
@sjames1958gm :wave:
Marc
@MWBauer
Oct 27 2017 15:22
Anyone here?
Ken Haduch
@khaduch
Oct 27 2017 15:22
@MWBauer - try the dropdown in the upper right-hand corner of the JS tab - "Analyze JS" and see if you can fix things that it flags...
Marc
@MWBauer
Oct 27 2017 15:23
Oh wow....never knew. thanks
Ken Haduch
@khaduch
Oct 27 2017 15:24
@MWBauer - you're welcome... the "Tidy JS" is also handy for cleaning up/re-doing indentations of the code, which is also sometimes helpful ( although it doesn't work well for all cases)...
@MWBauer - one thing that was messy is your images section - needs commas after each image, and a var images = at the top... looks like this:
var images= {
    rain: "https://cdn.pixabay.com/photo/2017/08/18/13/04/trickle-2654887_960_720.jpg",
    clear: "https://cdn.pixabay.com/photo/2017/08/31/18/56/sunrise-2701879_960_720.jpg",
    fall: "https://cdn.pixabay.com/photo/2017/09/16/17/22/autumn-2756123_960_720.jpg",
    fog: "https://cdn.pixabay.com/photo/2017/08/10/05/12/sunrise-2618463_960_720.jpg",
    snow: "https://cdn.pixabay.com/photo/2016/12/12/16/47/snow-1902052_960_720.jpg"
};
Ken Haduch
@khaduch
Oct 27 2017 15:40
@MWBauer - you had a missing paren or curly brace at the end, and maybe when I put that in I moved your access for the images[json.weather... outside the scope of your $.getJSON( call to get the weather info, but you might also find that to be a problem. Your JSON data is only valid after the callback is invoked, so you have to have that access of the data within the callback function, or synchronized to the callback function being called.
Ken Haduch
@khaduch
Oct 27 2017 15:46
@MWBauer - and apparently "NO HOTLINKING" to pixabay images...
Marc
@MWBauer
Oct 27 2017 15:49
No....hotlinking?
Where did anyone else find the pics for their weather conditions?
Marc
@MWBauer
Oct 27 2017 15:57
And why do I keep getting and Unexpected token referencing my : ?
@khaduch thanks for sorting the commas out. I don't know why I wasn't thinking about that.
CamperBot
@camperbot
Oct 27 2017 16:00
mwbauer sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3418 | @khaduch |http://www.freecodecamp.com/khaduch
Marc
@MWBauer
Oct 27 2017 16:11
I've found new images to hotlink. Pixabay is removed.
I still have this unexpected token issue. If it's all setup the same way, why is it picking out this one entry, and why pick it out at all?
Kyle Holm
@thekholm80
Oct 27 2017 16:31
@DarrenfJ @heroiczero @Manish-Giri @daddycardona ty
CamperBot
@camperbot
Oct 27 2017 16:31
thekholm80 sends brownie points to @darrenfj and @heroiczero and @manish-giri and @daddycardona :sparkles: :thumbsup: :sparkles:
:cookie: 427 | @daddycardona |http://www.freecodecamp.com/daddycardona
:star2: 1960 | @heroiczero |http://www.freecodecamp.com/heroiczero
:star2: 2193 | @darrenfj |http://www.freecodecamp.com/darrenfj
:star2: 6708 | @manish-giri |http://www.freecodecamp.com/manish-giri
Albert Cardona II
@daddycardona
Oct 27 2017 16:35
@arifcodecamper your tweet code is awesome bro :)
Ken Haduch
@khaduch
Oct 27 2017 16:36
@MWBauer - sorry, I was away for a bit... just dropped back to check, and it looks like there are still problems with the setup for your images object - it should be declared as var images = { and then your list of properties and values, comma-separated... The "Analyze JS" also complains, after that, about semicolons in your functions and code above.
Albert Cardona II
@daddycardona
Oct 27 2017 16:45
Hey how are you @khaduch
Gilarath
@Gilarath
Oct 27 2017 16:55
Hey guys now since I've gotten my location how do you use that to get the weather?
Moisés Man
@moigithub
Oct 27 2017 17:03
find a weather API, which uses ur latitude/longitude location values @Gilarath
ie. wunderground, darksky, openweathermap.. etc..
CamperBot
@camperbot
Oct 27 2017 17:03
find a weather api which uses ur latitudelongitude location values @gilarath ie wunderground darksky openweathermap etc
nothing found
Kaz Baig
@kbaig
Oct 27 2017 17:34
Anyone have a resource recommendation for setting up a node server that I can write ES6/7 in?
Albert Cardona II
@daddycardona
Oct 27 2017 17:40
no brother sorry I am not even in your level yet @kbaig
Chris
@bestintown23
Oct 27 2017 17:51
why is my handshake picture not touching the left edge like the bullseye photo? https://codepen.io/bestintown23/pen/aVbzoj
Praveen Saraogi
@saraogipraveen
Oct 27 2017 18:09
can anyone help me with some good resume templates
i just have 6months of exp
i want to build good resume
to get noticed
Sorin Ruse
@sorinr
Oct 27 2017 18:24
@raviloop why not build a good one for yourself that will show your abilities in coding
Travis Boss
@travisboss
Oct 27 2017 18:28
@bestintown23 I do not see a handshake picture but I do see on your fc1 you just put the word “padding” and nothing else. also the a element cannot be a chile of UL so you would need an li in there.
@bestintown23 the image looks to be broken
Albert Cardona II
@daddycardona
Oct 27 2017 18:37
@raviloop First of all have you done all the FCC projects? If so keep adding to your GITHUB or pencode projects to show your coding skills. 2nd show your understanding of the language by doing some of the algorythim challenges on youtube videos ;)
@bestintown23 your site is coming along nicely
Albert Cardona II
@daddycardona
Oct 27 2017 18:57
    if (!x[1]) {
        var sumTwoAnd = addTogether(2);
    }
}

addTogether(2)(3);
so I know I need to return something here but I just don't know what? should I be returning
return function(b) {
var    sumTwoAnd = add Together(2)
// i don't get this part
}
Kaz Baig
@kbaig
Oct 27 2017 18:58
@daddycardona could you return your whole function as one snippet
Albert Cardona II
@daddycardona
Oct 27 2017 18:59
yes I am confused with this one I am trying to learn freaking closures which one person said is not even this complicated but for me in this situation it is this complicated
as a matter of fact he said and proved that this was a closure
Kaz Baig
@kbaig
Oct 27 2017 18:59
I'm asking for you to put all your code in one snippet for me to see
alpox
@alpox
Oct 27 2017 19:00
@daddycardona To understand closures, there is one thing you have to understand right.
A function, in javascript, is nothing else than data. A function is also just a variable which holds a function reference. Therefore, you can pass around a function like an integer in a variable - or a string, or whatever. Just look at a function like every other datastructure.
Albert Cardona II
@daddycardona
Oct 27 2017 19:01
var b = 3;
function addIt(a){
   return a+b;
}
addIt(2)
function addTogether() {
    var x = arguments;
    var sum;
    if (typeof x[0] !== 'number') {
        return undefined;
    }
    if (x[1]) {
        if (typeof x[1] === 'number') {
            sum = x[0] + x[1];
            console.log(sum);
            return sum;
        } else {
            return undefined;
        }
    }
    if (!x[1]) {
        var sumTwoAnd = addTogether(2);
    }
}

addTogether(2)(3);
Kaz Baig
@kbaig
Oct 27 2017 19:02
oh it's a currying function
okay so you want to return a function
alpox
@alpox
Oct 27 2017 19:02

@daddycardona Only the usage is a little different. If you have a function

function addIt(a, b) {
    return a+b;
}

Like you just showed, addIt is the variable in which the function is stored.
You can use addIt as any other variable.
But, if you want to use the function - to call it so to say, you just put () right after the reference to the function in the code.
The function can come out of an array, out of a list, out of another function.

Albert Cardona II
@daddycardona
Oct 27 2017 19:02
yes maybe I should
Kaz Baig
@kbaig
Oct 27 2017 19:03
the function that you return will take what you passed in to addTogether and add it to what it receives
alpox
@alpox
Oct 27 2017 19:03
@daddycardona
So you could also have:
function addIt(a, b) {
   return a+b;
}
var funcArr = [addIt];

console.log(funcArr[0](3,5)) // logs 8
As you see, the function is just stored i an array and when you get it out of the array you can also just add () with parameters or without to call your function.
Albert Cardona II
@daddycardona
Oct 27 2017 19:04
Holy crap I am confused
Kaz Baig
@kbaig
Oct 27 2017 19:05
function addTogether(a) {
  return function (b) {
    return a + b;
  };
}
alpox
@alpox
Oct 27 2017 19:06
@daddycardona About which part? :-) I try to show you what functions in javascript really are and how they can be treated - which is crucial for understanding what closures really do
Albert Cardona II
@daddycardona
Oct 27 2017 19:06
my problem is that this example you are showing me is simple but as you can see I have no parameters because the challenge wants us to not use the parameters in the first function addTogether()
Kaz Baig
@kbaig
Oct 27 2017 19:06
can you link
the function
the problem*
Albert Cardona II
@daddycardona
Oct 27 2017 19:07
I think I need to use if(!x[0]) as well
alpox
@alpox
Oct 27 2017 19:08
@daddycardona You have parameters in that function addTogether. In one case, you just only use one of them: addTogether(2) <-- here you use only the first argument of addTogether. You see in the description for how to call it: addTogether(2)(3) probably. That works, because addTogether(2) returns a function itself which takes 1 argument. Just like :point_up: 27. Oktober 2017 21:05
Albert Cardona II
@daddycardona
Oct 27 2017 19:08
yes but the function addTogether() does not why I am using arguments
Kaz Baig
@kbaig
Oct 27 2017 19:09
aha
alpox
@alpox
Oct 27 2017 19:10
@daddycardona But it knows if you gave it only 1 or if you gave it 2 arguments
Kaz Baig
@kbaig
Oct 27 2017 19:10
function addTogether() {
  if (typeof arguments[0] !== 'number' || (arguments[1] && typeof arguments[1] !== 'number')) {
    return undefined;
  } else {
    return arguments[0] && arguments[1] ?
      arguments[0] + arguments[1]
      :
      (n) => typeof n === 'number' ? arguments[0] + n : undefined;  
  }
}
that's what I did
alpox
@alpox
Oct 27 2017 19:10
Not sure if giving a solution helps :D
Kaz Baig
@kbaig
Oct 27 2017 19:10
tru
Albert Cardona II
@daddycardona
Oct 27 2017 19:10
why I used x=arguments :)
it doesn't his is to complicated anyways lmao
Kaz Baig
@kbaig
Oct 27 2017 19:11
mmm I kind of did it backwards
ima try to make it cleaner
alpox
@alpox
Oct 27 2017 19:11
Hmm mine is clean but i guess not very understandable for you
Albert Cardona II
@daddycardona
Oct 27 2017 19:12
yes I am just to simple and that is more advance arrow functions and ? stuff right now
alpox
@alpox
Oct 27 2017 19:12
@daddycardona You did right to check for x[1] if it exists or not. If it doesn't, you have to return a function.
@daddycardona the ? : stuff is called ternary operator (For later reference)
Albert Cardona II
@daddycardona
Oct 27 2017 19:14
so I should be doing this
  if (!x[1]) {
        return function addTwo(){
            return ;// something here 
        }
    }
alpox
@alpox
Oct 27 2017 19:14
@daddycardona It does not need a name, but yea kind of that
Albert Cardona II
@daddycardona
Oct 27 2017 19:14
or maybe have a with a parameter
function addTwo(b){
alpox
@alpox
Oct 27 2017 19:15
@daddycardona Way to go
Albert Cardona II
@daddycardona
Oct 27 2017 19:16
well I am just trying to go by the directions sometimes following the steps that they try to lay out for me helps, sometimes lol
this is the part that is confusing me right here now I have to create a variable that holds the function or something
@alpox these directions confuse the hell out of me I am freaking getting piss, like when you play a video games and you know you pressed a certain button two minutes ago but then since it is so laggy it moves it at the wrong time
alpox
@alpox
Oct 27 2017 19:18

@daddycardona With

function addTwo() {}

you already have the variable addTwo which holds the function.
But you don't have to "put it in a variable" here - it can be an anonymous function which you just return

@daddycardona What directions? :D
Albert Cardona II
@daddycardona
Oct 27 2017 19:19
alpox
@alpox
Oct 27 2017 19:19
Yea i know which challenge it is, but i was just not sure what you mean by directions
Albert Cardona II
@daddycardona
Oct 27 2017 19:20
Calling this returned function with a single argument will then return the sum:

var sumTwoAnd = addTogether(2);

sumTwoAnd(3) returns 5.
alpox
@alpox
Oct 27 2017 19:21
@daddycardona This is not what you have to do - this is what happens when you do addTogether(2)(3)
Its just split in 2 operations to make it clearer what happens
Albert Cardona II
@daddycardona
Oct 27 2017 19:21
so when I do var sumTwoAnd = addTogether(2); I get maximized stack flow sized exceede
alpox
@alpox
Oct 27 2017 19:22
@daddycardona Yea because you call addTogether inside of addTogether - and you have an endless recursion loop
Kaz Baig
@kbaig
Oct 27 2017 19:23
because you didn't establish a base case
ie
alpox
@alpox
Oct 27 2017 19:23
In each call you enter if(!x[1]) and call addTogether(2) again
Kaz Baig
@kbaig
Oct 27 2017 19:23
if something, return a value
otherwise, return addTogether(...)
Albert Cardona II
@daddycardona
Oct 27 2017 19:23
give me a minute
alpox
@alpox
Oct 27 2017 19:23
@daddycardona You do not have to call addTogether inside of addTogether again
Albert Cardona II
@daddycardona
Oct 27 2017 19:25
Okay so what does that mean
sorry on the phone
Albert Cardona II
@daddycardona
Oct 27 2017 19:31
I litterally just typed in what I asked the lady on the phone lol
alpox
@alpox
Oct 27 2017 19:34
:D can happen
Albert Cardona II
@daddycardona
Oct 27 2017 19:36
veteran issues brother LOL
so Okay you need to break it down barney style for me let's start over because the conversations I was having was deep with the vets. I should just have to getx[1] if there is nox[1] so I only really need to do is make a function that gets the 3 from the addTogether(2)(3)
Albert Cardona II
@daddycardona
Oct 27 2017 19:43
@alpox
alpox
@alpox
Oct 27 2017 19:43
@daddycardona not a function which just "gets" it. You have to make a function which does the calculation and returns the result.
Albert Cardona II
@daddycardona
Oct 27 2017 19:44
yes I got that part but I need to make a function that can get the (3) that is the part that is confusing me I guess not so much the addTogether(2) because I have that as the x[0]
alpox
@alpox
Oct 27 2017 19:45
Yes you do
You then only need the 3,right
Albert Cardona II
@daddycardona
Oct 27 2017 19:48
Okay so my first if statement should be if x0 is not a number then if x0=='number' && !x1
damn because having that if statement there I don't think I see the or can get the return of somethin
alpox
@alpox
Oct 27 2017 19:49
If x0 is not a number you return undefined
The if statement doesnt hurt you
Albert Cardona II
@daddycardona
Oct 27 2017 19:52
Yes but if I put if(!x[0]) like this
 if (x[1]) {
        if (typeof x[1] === 'number') {
            sum = x[0] + x[1];
            console.log(sum);
            return sum;
        } else if (!x[0]) {
            return function addTwo(b) {
                return x[0] + b; // something here 
            }
        } else {
            return undefined;
        }
    }
does this make a difference?
alpox
@alpox
Oct 27 2017 19:53
@daddycardona Thats a weird thing you test there - its the wrong case. The case you test now is:
addTogether(undefined, 2);
Surely not the place where you would return a function from
Kaz Baig
@kbaig
Oct 27 2017 19:54
I think it's implied in the problem that arguments[0] is always going to be there
@alpox can you send me your solution pls? just curious
Albert Cardona II
@daddycardona
Oct 27 2017 19:55
yes but should I be like testing if x1 as well before this additions?
alpox
@alpox
Oct 27 2017 19:56
@kbaig See PM :-)
Albert Cardona II
@daddycardona
Oct 27 2017 19:56
I litterally just confused myself lmao damn sleep deprived
alpox
@alpox
Oct 27 2017 19:56
@daddycardona Best test for the validity of x[0], then test if x[1] exist
Albert Cardona II
@daddycardona
Oct 27 2017 19:57
yes that is what I meant to do
I see what you guys are saying I had it correct originally lol
alpox
@alpox
Oct 27 2017 19:58
Yea that was not so bad :D
Albert Cardona II
@daddycardona
Oct 27 2017 19:59
   if (typeof x[0] !== 'number') {
        return undefined;
    }
    if (!x[1]) {
        return function addTwo(b) {
            return x[0] + b; // something here 
        }
    }
    if (x[1]) {// my other stuff
should If there isn't a value first? for argument[1] that was what I meant to ask but then my slow ass did that other stuff lol
gishy1
@gishy1
Oct 27 2017 20:02
guys how do you store an empty string ?
oh ya hello world !!!
Albert Cardona II
@daddycardona
Oct 27 2017 20:04
whats up
alpox
@alpox
Oct 27 2017 20:04
@daddycardona This looks alright what you have :-)
Albert Cardona II
@daddycardona
Oct 27 2017 20:04
var str ='';
gishy1
@gishy1
Oct 27 2017 20:04
image.png
Albert Cardona II
@daddycardona
Oct 27 2017 20:04
I finished it lol
gishy1
@gishy1
Oct 27 2017 20:04
@daddycardona have a look
alpox
@alpox
Oct 27 2017 20:05
@gishy1 An empty string is a string with nothing in it: ""
Albert Cardona II
@daddycardona
Oct 27 2017 20:05
yes you have a space @gishy1
delete the space
gishy1
@gishy1
Oct 27 2017 20:06
@alpox s9till giving me invalid count
Albert Cardona II
@daddycardona
Oct 27 2017 20:09
@gishy1 you need to put your first statement in the if statemen. if(num>0) because when you do it before it I believe it does it a negative times before you start doing it so your 1st statement is str = str.repeat(num) should be inside your if statement
gishy1
@gishy1
Oct 27 2017 20:09
range value invalid count value
@daddycardona that worked but why?
Albert Cardona II
@daddycardona
Oct 27 2017 20:11
because you telling the str to repeat a negative two times before you you figured out if the num was greater than zero
I done that before too :)
gishy1
@gishy1
Oct 27 2017 20:11
i thought it has access to the global variable?
Albert Cardona II
@daddycardona
Oct 27 2017 20:11
it did in the if statement
you could make it simpler too
if(num>0){
return str.repeat(num)
}else{
return "";
}
no need for the other variables :)
Koleen BP
@KBPsystem777
Oct 27 2017 20:15
Hi guys! I just finished my updates on my random quote machine. Can you please provide feedback on it? https://codepen.io/KBPsystem/pen/pWKqmo Thanks in advance :)
Kaz Baig
@kbaig
Oct 27 2017 20:18
@KBPsystem777 I like the overall aesthetic but I'd make the text for at least the quote and the quote gen button larger / more font-weight to draw attention
honestly didn't know where to look at first
also, those buttons could be narrower/taller
Albert Cardona II
@daddycardona
Oct 27 2017 20:22
Thanks @kbaig and @alpox :)
CamperBot
@camperbot
Oct 27 2017 20:22
daddycardona sends brownie points to @kbaig and @alpox :sparkles: :thumbsup: :sparkles:
:cookie: 389 | @kbaig |http://www.freecodecamp.com/kbaig
:star2: 1410 | @alpox |http://www.freecodecamp.com/alpox
alpox
@alpox
Oct 27 2017 20:24
@daddycardona np :-)
Albert Cardona II
@daddycardona
Oct 27 2017 20:24
@KBPsystem777 don't forget if the quote is more than 180 characters you need to shorten it somehow or esle you can't tweet it, it will say you are -11 or the number you are negative for every number you go over other than that looks awesome :)
i figured it out I just don't understand how it needed me to just make a quick function and it got the secong part of of the function the (3) and I didn't have to go crazy just return a function and it just grabbed @alpox
that was the problem that confused me the whole time some crazy stuff there but I get it just don't get it lol
dam phone number one looks hard I guess I will do it sunday :)
alpox
@alpox
Oct 27 2017 20:28
@daddycardona The thing is that the 3 comes in your variable b :)
Albert Cardona II
@daddycardona
Oct 27 2017 20:28
yes I saw that thanks to my addon to vs code but what I don't get is how it grabbed it i guess
because basically said yo son this is what it is grab it lol
gishy1
@gishy1
Oct 27 2017 20:30
@daddycardona bro im still trying to understand the reasoning behind it
Albert Cardona II
@daddycardona
Oct 27 2017 20:30
@gishy1 I feel you lol
gishy1
@gishy1
Oct 27 2017 20:31
@daddycardona i hate doing something not understanding it then having it bite me in the ass down the line
Albert Cardona II
@daddycardona
Oct 27 2017 20:32
I think it basically says the 1st functions arguments is captured so call a a new function and give it a parameter and then it will grab the second argument and since that is what I believe it to be true I will leave it like that lol
Well later people :)
alpox
@alpox
Oct 27 2017 20:33
@daddycardona You return the function - this means that addTogether(2) BECOMES the function you returned - so you can call THAT function with (3)

@daddycardona So when you do:

var addTwo = addTogether(2);

That addTwo is EXACTLY the function you returned at

return function addTwo(b) {
            return x[0] + b; // something here 
        }
So you can call addTwo(3) and b becomes 3
Albert Cardona II
@daddycardona
Oct 27 2017 20:34
just name it something differnt so it won't be recursive
alpox
@alpox
Oct 27 2017 20:34
With addTogether(2)(3) you just leave out the middlestep of saving that function to a variable
@daddycardona Wait no -
@daddycardona The var addTwo = addTogether(2); happens OUTSIDE of your function. Its how it gets USED
Its not part of your function
Albert Cardona II
@daddycardona
Oct 27 2017 20:35
this is my code and why it confuses me :)
function addTogether() {
    var x = arguments;
    if (typeof x[0] !== 'number') {
        return undefined;
    }
    if (!x[1]) {
        return function addTwo(b) {
            if (typeof b === 'number') {
                return x[0] + b;
            } else {
                return undefined;
            }
        }
    }
    if (x[1]) {
        if (typeof x[1] === 'number') {
            return x[0] + x[1];;
        } else {
            return undefined;
        }
    }
}

addTogether(2)(3);
alpox
@alpox
Oct 27 2017 20:36
@daddycardona You see, the addTogether(2)(3); is the usage - and outside of the function :-)
Albert Cardona II
@daddycardona
Oct 27 2017 20:36
so you saying if I did var addTwo = addTogether(2) outside the function it would work differently ?
I would have to recode it ?
Kaz Baig
@kbaig
Oct 27 2017 20:37
no
addTwo would be assigned a function
which is what you want
it would basically be the same as
var addTwo = function(n) { return n + 2 }
alpox
@alpox
Oct 27 2017 20:38
@daddycardona
var addTwo = addTogether(2);
addTwo(3);
// !!! Equals !!!
addTogether(2)(3);
Kaz Baig
@kbaig
Oct 27 2017 20:39
ye
Albert Cardona II
@daddycardona
Oct 27 2017 20:39
now I am very confused by what you guys are saying
whe I used var addTwo = addTogether (2); in the function it says something weird but if I used it outside the function it would of done seomthing different
why I use videos for this stuff
I will talk to you all later i have to go to boston its anhour drive later and thanks for all the help
Kaz Baig
@kbaig
Oct 27 2017 20:41
go to mike's pastry for me
I miss boston
alpox
@alpox
Oct 27 2017 20:41
@daddycardona If you call that inside of the function itself you have recursion. If you do it outside, you don't - there its just usage.
@daddycardona Have a good ride :D
gishy1
@gishy1
Oct 27 2017 21:20
my eyes are red atm
someone have a look
alpox
@alpox
Oct 27 2017 21:21
@gishy1 On your eyes? :D go to the eye-doctor! :D
gishy1
@gishy1
Oct 27 2017 21:22
image.png
trust me the doctor will need an eye doctor too
i satisfy one criteria the other fails
alpox
@alpox
Oct 27 2017 21:23
Hmm well no wonder you need an eye doctor with those variable names :D
gishy1
@gishy1
Oct 27 2017 21:24
@alpox if i had a cent for every variable i declared
there must be a better way suggestions\
alpox
@alpox
Oct 27 2017 21:26
@gishy1 :D
@gishy1 You have to have num characters for ALL characters - the ones from the string + the ones from the ...
You now put there num characters from the string + the dots
But it should be num-3characters + the dots
@gishy1 Well you can for now give your variables a fitting name. Variable names with only one character (except maybe in math calculations and x/y) are no good variable names and make it very hard to reason about a program (First CS class you'd get if you'd study CS) :D
You always need descriptive variable names
gishy1
@gishy1
Oct 27 2017 21:31
@alpox have you ever read something not fully understood it but just have a feeling what you need to do thats me right now
alpox
@alpox
Oct 27 2017 21:31
Also you don't have to calculate all these variables in every case
gishy1
@gishy1
Oct 27 2017 21:32
@alpox which is why I am not in a CS class loool
alpox
@alpox
Oct 27 2017 21:33

@gishy1 Well, the part of the challenge you missed is:

Note that inserting the three dots to the end will add to the string length.

gishy1
@gishy1
Oct 27 2017 21:33
@alpox i thats why i declared variable c
alpox
@alpox
Oct 27 2017 21:34
@gishy1 c? You don't make use of it - and its the total beginning of the string - only the first 3 characters of the string to be precise
That doesn't look like that case
gishy1
@gishy1
Oct 27 2017 21:35
@alpox i need to let this stew for a while then come back because I am actually having a brain freeze
alpox
@alpox
Oct 27 2017 21:36
Can happen :-) chill off your brain and give it another try later
Darren
@DarrenfJ
Oct 27 2017 23:20
evening fCC
how goes thee ole code
korzo
@korzo
Oct 27 2017 23:29
@DarrenfJ Hi