These are chat archives for FreeCodeCamp/HelpFrontEnd

11th
Oct 2017
Mauricio Scioville
@invasorMou
Oct 11 2017 01:18
hi
Tom
@moT01
Oct 11 2017 01:37
any regex masters around?
Pagnito
@Pagnito
Oct 11 2017 02:12
who did the dungeon crawler alrdy?
Tom
@moT01
Oct 11 2017 02:21
sup
@Pagnito
Pagnito
@Pagnito
Oct 11 2017 02:22
@moT01 did you randomize all the rooms?
with an alg?
Tom
@moT01
Oct 11 2017 02:22
yes
Pagnito
@Pagnito
Oct 11 2017 02:22
so ur maps are always random?
Tom
@moT01
Oct 11 2017 02:23
yes
Pagnito
@Pagnito
Oct 11 2017 02:23
did u use canvas?
Tom
@moT01
Oct 11 2017 02:24
no
hit 'm' after it loads to see the map
after you start
i made a 2d array, and used a table
probly not the best way to go
my buddy just wrote an article about how he did this one that i used
Pagnito
@Pagnito
Oct 11 2017 02:26
sweet thanks, did u use phaser?
Tom
@moT01
Oct 11 2017 02:27
no, what's phaser
Pagnito
@Pagnito
Oct 11 2017 02:28
a js library to make html games
what did u use to make the graphics and the characters?
Tom
@moT01
Oct 11 2017 02:28
basically the algorithm takes a 2d array and, and just randomly walks around it and turns everything it walks on to 1's or whatever
i took that 2d array, mapped it to a <table> and gave the elements classes
so if the array had a 0, it was a wall or something, and if it had a 1 it was a hallway
room whatever
like i said, that's probly not the best way to go
but, i dunno, it was what i was familiar with at the time
Pagnito
@Pagnito
Oct 11 2017 02:31
i feel u
thats what i did for game of life
the blocks are those also pngs?
Tom
@moT01
Oct 11 2017 02:33
yea, i think all the images are pngs
i had to do so gimp work with some of them
and i must have put another element in the <td> of the table for the items and stuff
Pagnito
@Pagnito
Oct 11 2017 02:34
gimp?
Tom
@moT01
Oct 11 2017 02:34
cheap man's version of photoshot
photoshop
free
Pagnito
@Pagnito
Oct 11 2017 02:34
oooh
Ben Hart
@Benjmhart
Oct 11 2017 02:45
I seem to have broken codepen...
what did I do?
welp, fixed it enough for codepen to let me debug at least
Tom
@moT01
Oct 11 2017 02:48
twitchsrt
you didn't ask much of a question for me to be able to help, but the twitchSort function wasn't closed
Ben Hart
@Benjmhart
Oct 11 2017 02:50
yeah i figured that out
now on to my real question -- are there any good resources for figuring out promises on foreach loops? the more i read about promises and deferred objects the more confused i am
Tom
@moT01
Oct 11 2017 02:54
I dont have anything specific
i dont think promises are necessary for this project
nesting them in a forEach loop, im not sure about that
Ben Hart
@Benjmhart
Oct 11 2017 02:56
oh, maybe someone sent me on a wild goose chase, how would you approach it?
Tom
@moT01
Oct 11 2017 02:56
the forEach loop should be enough by itself
Ben Hart
@Benjmhart
Oct 11 2017 02:57
hmm, ok, well I was able to get back a bunch of objects, the problem is that the data seems to be scrambled when I put it through the operation make it HTML
specifically twitchers[i] seems to survive long enough to be passed into the ajax call, but turns into a single letter when i try to reference it in the success function - is there something weird going on with scope?)
Tom
@moT01
Oct 11 2017 03:03
im not seeing what you're seeing
but I think that twitchers variable next to the data in the success shouldn't be there
  $.each(twitchers, function(i){ 
    console.log(twitchers[i]);
  $.ajax({
        type: "GET",
        dataType: "jsonp",
        url: 'https://wind-bow.gomix.me/twitch-api/streams/'+twitchers[i],
        success: function(data){
          console.log(data);
Ben Hart
@Benjmhart
Oct 11 2017 03:06
it was a scope issue, apparently I don't need to pass the twitchers variable into the anon function in the success. thanks
thanks @moT01
CamperBot
@camperbot
Oct 11 2017 03:09
benjmhart sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 873 | @mot01 |http://www.freecodecamp.com/mot01
Ben Hart
@Benjmhart
Oct 11 2017 03:10
any idea why I'm only getting the online users returned now?
it's like failure to qualify for the IF is cancelling the rest of the operations
Tom
@moT01
Oct 11 2017 03:14
that is strange
not quite sure yet
Ben Hart
@Benjmhart
Oct 11 2017 03:18
or is the object just getting overwritten by the next response
Tom
@moT01
Oct 11 2017 03:21
not sure what's happening
but if you change your if
to if(data.stream)
it works
you can't have a single = in an if statement like that
needs to be to two or three
Ben Hart
@Benjmhart
Oct 11 2017 03:28
awesome, thanks so much!
Stephen
@stephepush
Oct 11 2017 03:57
Hey, I’m trying to integrate gulp functionality in my portfolio project, and I’m wondering if it’s okay to concat and minify font awesome css and bootstrap css together?
linkin-park
@linkin-park
Oct 11 2017 06:13
hi @Pagnito
Pagnito
@Pagnito
Oct 11 2017 06:14
Hi @linkin-park
linkin-park
@linkin-park
Oct 11 2017 06:18
your projects are really interesting
Markus Kiili
@Masd925
Oct 11 2017 06:19
@stephepush I don't think that licences forbid that. Maybe you should name the file so it is clear that it combines those two files.
Stephen
@stephepush
Oct 11 2017 06:20
indeed
linkin-park
@linkin-park
Oct 11 2017 06:20
a little buggy in the logic @Pagnito
Pagnito
@Pagnito
Oct 11 2017 06:22
@linkin-park ya they are old besides the react ones...im too lazy tonupdate them. And react is new to me so ya haha im sure it is buggy.
linkin-park
@linkin-park
Oct 11 2017 06:24
no the old ones like calculator and other FCC thingy
TJ Hardin
@AndroidNinjaX
Oct 11 2017 06:26
Hey everyone. Did they get rid of some rooms? Noticed some disappeared from my rooms.
Pagnito
@Pagnito
Oct 11 2017 06:26
Ya thats the ones i was talking about too. I might redo them. Tho i didnt know my calc was buggy
linkin-park
@linkin-park
Oct 11 2017 06:26
i can learn alot from your work html css but the logic matter the most as a programmer not even GUI :) hope you update it soon :) good luck
Pagnito
@Pagnito
Oct 11 2017 06:27
Whats buggy about the calculator
linkin-park
@linkin-park
Oct 11 2017 06:28
example :P 5/0 never infinity in math world , they will kill you.
8//1 not even valid but it comments rest out and give me 8 :) lolz
and many things :)
Markus Kiili
@Masd925
Oct 11 2017 06:31
@linkin-park You can add infinities to the group of real numbers in math too. Affinely extended real number system
Pagnito
@Pagnito
Oct 11 2017 06:31
Ooh ok..ya i didnt even consider such cases
Markus Kiili
@Masd925
Oct 11 2017 06:31
@linkin-park But usually they would kill, yes.
Pagnito
@Pagnito
Oct 11 2017 06:32
Did u check out my simon game tho?
linkin-park
@linkin-park
Oct 11 2017 06:33
no :)
Pagnito
@Pagnito
Oct 11 2017 06:34
Check it out and get it wrong on purpose
linkin-park
@linkin-park
Oct 11 2017 06:34
k later
do you know stack @Pagnito ?
might have used that for calculator :)
Pagnito
@Pagnito
Oct 11 2017 06:36
Stack?
linkin-park
@linkin-park
Oct 11 2017 06:36
one of the old data structure :)
Pagnito
@Pagnito
Oct 11 2017 06:37
First time hearing about it
linkin-park
@linkin-park
Oct 11 2017 06:53
hi @Masd925
watz up
Markus Kiili
@Masd925
Oct 11 2017 06:53
@linkin-park Work :(
linkin-park
@linkin-park
Oct 11 2017 06:55
:(
so react is a library where they consider widgets are components , with properties are props and states value passed to components - right?
props aka properties used to customize these components
am i right?
@Masd925 @Pagnito
linkin-park
@linkin-park
Oct 11 2017 07:04
please let me know on the above anyone :)
Long Nguyen
@longnt80
Oct 11 2017 07:04
@linkin-park maybe something like that, I'm not sure about those terms
linkin-park
@linkin-park
Oct 11 2017 07:04
so its not like that ?
Long Nguyen
@longnt80
Oct 11 2017 07:04
props and states are to store data
linkin-park
@linkin-park
Oct 11 2017 07:05
i thought props are for configuration of components
Long Nguyen
@longnt80
Oct 11 2017 07:05
you can use those data to customize the component
linkin-park
@linkin-park
Oct 11 2017 07:05
okay ofcourse :)
Long Nguyen
@longnt80
Oct 11 2017 07:05
but basically, props and states are just data
linkin-park
@linkin-park
Oct 11 2017 07:06
yes
just want to know what is reactjs before i go into it :) thanks mate
Long Nguyen
@longnt80
Oct 11 2017 07:07
@linkin-park have you taken a look at the official docs?
you should have the general idea from there
linkin-park
@linkin-park
Oct 11 2017 07:08
okay
Long Nguyen
@longnt80
Oct 11 2017 07:08
and I would suggest doing a few react exercises from codecademy
it helps to understand some of the basics
linkin-park
@linkin-park
Oct 11 2017 07:09
i see :+1:
TJ Hardin
@AndroidNinjaX
Oct 11 2017 07:17
hey can anyone help with a rounding issue really quick
linkin-park
@linkin-park
Oct 11 2017 07:21
in android or ios ? @AndroidNinjaX
TJ Hardin
@AndroidNinjaX
Oct 11 2017 07:22
oh javascript actually. One of the front end algorithm challanges
i feel dumb. just adding numbers together but it wants to give me a longer decimal then i gave it
Fabien SHAN
@X140hu4
Oct 11 2017 07:24
Is it the "exact change" one?
TJ Hardin
@AndroidNinjaX
Oct 11 2017 07:25
haha yup
Fabien SHAN
@X140hu4
Oct 11 2017 07:25
yeah i got stuck on that too...
What did you come up with so far?
linkin-park
@linkin-park
Oct 11 2017 07:26
link please @AndroidNinjaX
to challenge
TJ Hardin
@AndroidNinjaX
Oct 11 2017 07:26
function checkCashRegister(price, cash, cid) {
  var totalInReg = 0;

  for (var i = 0; i < cid.length; i++){
    totalInReg += cid[i][1];
  }

  console.log(totalInReg);
}

checkCashRegister(3.26, 100.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
I have more code, and bassically done except for the rounding issue. If you run this, instread of totalInReg = 335.41 you get 335.40999999999997
I just dont understand why its adding all the 999999999's
Fabien SHAN
@X140hu4
Oct 11 2017 07:27
I personally used toFixed but it did not seem to be very reliable
It is because computers cannot represent floats exactly
So they approximate and that's what happens
You can multiply the value by 100, round it and then divide by 100. It is in the hint and more reliable than toFixed from what I experienced
TJ Hardin
@AndroidNinjaX
Oct 11 2017 07:30

would you explain that further?

Im still lost at why 1.01 + 2.05 does not = 3.06 rather 3.05999999999996......... Its not like I gave the computer a longer number

and actually if I put that in just like i did it does = 3.06, but If i put it as part of the for loop then it ha the 9's
ya I saw that I could do the rounding and multiplying, but just really...
Markus Kiili
@Masd925
Oct 11 2017 07:35
@AndroidNinjaX JS has only one Number type and all numbers are 64bit floats. Only small enough integers are guaranteed to be exact. Most numbers are a bit off.
@AndroidNinjaX Only robust way is to use penny amounts that are safe integers.
Some rounding scheme or margin of error on comparisons can work too, but it is harder to prove that it works on all situations.
TJ Hardin
@AndroidNinjaX
Oct 11 2017 07:36
@Masd925 ahhh well that makes more sense. So just honestly a javascript thing, and you have to find ways to work around it.
Markus Kiili
@Masd925
Oct 11 2017 07:37
@AndroidNinjaX All languages have floats, but they usually also have types that are better at handling such problems.
TJ Hardin
@AndroidNinjaX
Oct 11 2017 07:39
@Masd925 that explanation helps so much. I thought I was going crazy with some calculus stuff where 1 does not = 1 lol.
Markus Kiili
@Masd925
Oct 11 2017 07:40
@AndroidNinjaX JS having only one number type is widely considered a design error. There are of course libraries that help here.
TJ Hardin
@AndroidNinjaX
Oct 11 2017 07:42
@Masd925 ya that sounds like it. Why would they do that?
amatayamada
@amatayamada
Oct 11 2017 07:44
hello, I could use some help understanding a vue boilerplate
Markus Kiili
@Masd925
Oct 11 2017 07:44
@AndroidNinjaX The language was originally a scripting language for Netscape browser, and was written in 10 days. Therefore the core features were not so well thought out.
amatayamada
@amatayamada
Oct 11 2017 07:44
I have no idea where the argument is passed to the downloadRows function
linkin-park
@linkin-park
Oct 11 2017 07:45
/notify-all hi
TJ Hardin
@AndroidNinjaX
Oct 11 2017 07:45
@Masd925 that's logical. And not the language is HUGE haha. Well good to get some history on it.
@Masd925 thanks for that
CamperBot
@camperbot
Oct 11 2017 07:45
androidninjax sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4531 | @masd925 |http://www.freecodecamp.com/masd925
TJ Hardin
@AndroidNinjaX
Oct 11 2017 07:45
@X140hu4 and thanks for the tip. Still working on it.
CamperBot
@camperbot
Oct 11 2017 07:45
androidninjax sends brownie points to @x140hu4 :sparkles: :thumbsup: :sparkles:
:cookie: 292 | @x140hu4 |http://www.freecodecamp.com/x140hu4
amatayamada
@amatayamada
Oct 11 2017 07:45
Is the { commit } passed implicitly somehow?
what is happening here?
Fabien SHAN
@X140hu4
Oct 11 2017 07:46
@AndroidNinjaX No prob, good luck :)
amatayamada
@amatayamada
Oct 11 2017 07:46
clearly the passed commit argument is used to update the current state of the app with downloaded data
TJ Hardin
@AndroidNinjaX
Oct 11 2017 07:46
@X140hu4 hopefully will figure out how to deal with this float
amatayamada
@amatayamada
Oct 11 2017 07:46
but I have no idea how is it passed
TJ Hardin
@AndroidNinjaX
Oct 11 2017 07:46
@X140hu4 literally the last thing and ill have this problem solved.
amatayamada
@amatayamada
Oct 11 2017 07:46
since the call has no arguments
amatayamada
@amatayamada
Oct 11 2017 07:57
so far my ideas are that maybe the this. part in the call implicitly passes something...? can that happen?
Kris Baillargeon
@krisb1220
Oct 11 2017 07:58
Hey guys - how would I rerotate this text?
Dhowlath Basha
@Dhowlathbasha
Oct 11 2017 07:59
guys! anyone can help me my gitter app is not working in windows so i am using it by website help pls
Kris Baillargeon
@krisb1220
Oct 11 2017 08:00
lmao
that doesnt sound like something we can fix :P
whats going on?
Dhowlath Basha
@Dhowlathbasha
Oct 11 2017 08:00
when i click the icon its not opening
Kris Baillargeon
@krisb1220
Oct 11 2017 08:02
redownload it lol
Dhowlath Basha
@Dhowlathbasha
Oct 11 2017 08:02
i already done that but no use
Kris Baillargeon
@krisb1220
Oct 11 2017 08:04
hey is anyone who has a dev job online?
ADIL KARMOUZI
@mradil16
Oct 11 2017 08:31
Web design & Web development Hot Updates - Oct 11, 2017 : http://alldevtop.blogspot.com
Kris Baillargeon
@krisb1220
Oct 11 2017 08:36
/commands
CamperBot
@camperbot
Oct 11 2017 08:36

commands:

  • isCommand
  • cbot
  • botversion
  • botstatus
  • botenv
  • archive
  • init
  • tooNoisy
  • rooms
  • find
  • commands
  • music
  • announce
  • eightball
  • wiki
  • thanks
  • about
  • showInfoCallback
  • explain
  • bot
  • hi
  • index
  • thank
  • log
  • archives
Kevin Madill
@kmadill
Oct 11 2017 09:37
Anyone with redux experience out there that could answer a question?
alpox
@alpox
Oct 11 2017 09:38
@kmadill depends on the question :D
Kevin Madill
@kmadill
Oct 11 2017 09:38
Fair enough, I’ll give it a shot!
OK, so I have a component with a form in it. This form retrieves (and then save) data from the database. I had the idea not to save the state of each individual form element (text field) into the redux form, but instead use the local state for these text fields, and then save to the DB and redux store once the user actually hits save on the form.
Maybe I’ll start with this question - is this the right design pattern?
alpox
@alpox
Oct 11 2017 09:43
@kmadill lets say its a widely used pattern and one i would recommend (as long as you dont want to opt for redux-form). There is a huge code overhead - boilerplate for saving everything to the redux store on the fly. That would end quite ugly
Kevin Madill
@kmadill
Oct 11 2017 09:46
@alpox Thanks, glad my intuition was right on that one. OK, followup question - in which lifecycle method should I be accessing the props that come down from redux (the values coming from the database). Initially I thought the constructor, but the props are still null at that point.
CamperBot
@camperbot
Oct 11 2017 09:46
kmadill sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1346 | @alpox |http://www.freecodecamp.com/alpox
Kevin Madill
@kmadill
Oct 11 2017 09:49
componentWillReceiveProps seems like the only place they arrive, but it is not called again if I leave this component and then come back to it later...
alpox
@alpox
Oct 11 2017 09:51
@kmadill how will you use the data which comes from redux?
Kevin Madill
@kmadill
Oct 11 2017 09:51
@alpox For the initial values in the form
alpox
@alpox
Oct 11 2017 09:52
@kmadill depends on what you want to do with the data. Id just access them in the props of the render method
Kevin Madill
@kmadill
Oct 11 2017 09:53
@alpox Since they are the initial values, they can then be edited. Which leads back to my initial question / solution - not wanting to hold this state in the redux store but keeping it local.
alpox
@alpox
Oct 11 2017 09:54
@kmadill Ah what you want is to map the initial values to the state, right? You would have to use componentWillReceiveProps for the mapping - that was the right idea. You can just access your state from then on
Kevin Madill
@kmadill
Oct 11 2017 10:02
@alpox OK, so that works initially… except if I leave the component and then come back, the fields are blank because in my constructor I set the values to empty strings, and componentWillReceipveProps is only loaded on the first load of the component.
Should I be setting these default values in some other way?
alpox
@alpox
Oct 11 2017 10:13
@kmadill Hmm I would have to test what would work best. I thought that it should be called again when its created again, how else would redux inject the props again else?
@kmadill Actually, it could be that the props come in through the constructor the second time. You'd have to check :D
Kevin Madill
@kmadill
Oct 11 2017 10:37
@alpox Thanks for the help - I’ll keep digging.
CamperBot
@camperbot
Oct 11 2017 10:37
kmadill sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
api offline
ADIL KARMOUZI
@mradil16
Oct 11 2017 10:39
Guys , I want to get a part time job as a web developer , what should I do :
  • Build portfolio (5 to 10 website using HTML / CSS / Bootstrap / responsive design )
  • Or waiting until I learn PHP / MySQL / javascript then build portfolio
Shiran
@shiranag
Oct 11 2017 10:49
hi i need help with js code
myStr should have encoded text with the proper escape sequences and no spacing.
myStr should have one newline character \n
myStr should have one carriage return character \r
myStr should have two correctly escaped backslash characters \
how to made str?
heroiczero
@heroiczero
Oct 11 2017 10:50
@shiranag they should give you a text on how it should look like and you have to use one \n and one \r and \ for escaping the \.
linkin-park
@linkin-park
Oct 11 2017 10:51
so happy to see you back @heroiczero
heroiczero
@heroiczero
Oct 11 2017 10:51
:wave:
Shiran
@shiranag
Oct 11 2017 10:52
like this?
var myStr ="FirstLine\n\SecondLine\r\ThirdLine\";// Change this line
heroiczero
@heroiczero
Oct 11 2017 10:52
you are missing \ for you\
Shiran
@shiranag
Oct 11 2017 10:52
you can show me how to do it
heroiczero
@heroiczero
Oct 11 2017 10:53
like \\escaped the backslash
\r\ThirdLine\ that would make it look like
\ThirdLine\
Shiran
@shiranag
Oct 11 2017 10:54
not working
var myStr ="FirstLine\n\SecondLine\r\ThirdLine";
heroiczero
@heroiczero
Oct 11 2017 10:56
@shiranag
you have are missing an extra you need two \\ so you can escape \ so like
\\Second\\
Shiran
@shiranag
Oct 11 2017 10:57
ok now only the first is not working
var myStr ="FirstLine\n\SecondLine\r\ThirdLine";
myStr should have encoded text with the proper escape sequences and no spacing.
heroiczero
@heroiczero
Oct 11 2017 10:58

@shiranag if i remember correctly it should look like

FirstLine
\SecondLine\
ThirdLine

Currently you have

FirstLine
\SecondLine
\ThirdLine
Shiran
@shiranag
Oct 11 2017 10:59
so what to do?
Kevin Madill
@kmadill
Oct 11 2017 10:59
@alpox Alright… so you are right that they come in on the constructor on subsequest reloads of that component. Should I just use an if statement to check if they are there in the constructor, and set them accordingly?
heroiczero
@heroiczero
Oct 11 2017 11:00
@shiranag
var myStr ="FirstLine\n\\SecondLine\\\rThirdLine"; so do this
Shiran
@shiranag
Oct 11 2017 11:01
thanks
heroiczero
@heroiczero
Oct 11 2017 11:01
@shiranag you see how i escaped the\ with another \
Kevin Madill
@kmadill
Oct 11 2017 11:01
@mradil16 It’s just my personal opinion, but I think if you want a job as a web developer you will need something more than HTML/CSS/Bootstrap. To be a developer, you need to know some sort of development language, like javascript. You might be able to get a different job with that portfolio, but likely not developer. That’s my two cents at least...
alpox
@alpox
Oct 11 2017 11:01
@kmadill Nice :-) I guess thats maybe the best way
Kevin Madill
@kmadill
Oct 11 2017 11:02
@alpox I was using Update in mongoose instead of FindOneAndUpdate… turns out those return very different things (although both perfrom the actual operation)
so the updated state my reducer was returning was not what I had thought...
I’m still a little suprised that componentWillReceiveProps doesn’t call again… but this works
As an aside, would you always use redux-form? I thought since I only had three field in the form it would be more overhead than needed.
Shiran
@shiranag
Oct 11 2017 11:17
thanks now i realize how to do it
Fabien SHAN
@X140hu4
Oct 11 2017 13:36
hugh I have a filter that does not seem to work properly...
alexg1990
@alexg1990
Oct 11 2017 14:33

hey I am just working my way through object oriented programming and have a question regarding best practices regarding prototypes and constructors:
When adding a property to a constructor, should it be ideally added inside the constructor or outside of its scope so it won't be initiated every time a new Instance is created?

function Bird() {this.prototype.Legs = 4;} or function Bird () {} Bird.prototype.Legs = 4;

linkin-park
@linkin-park
Oct 11 2017 14:56
both look same to me :) @alexg1990
Kaz Baig
@kbaig
Oct 11 2017 14:58
@alexg1990 I've only seen it be done outside the object
Ben Hart
@Benjmhart
Oct 11 2017 15:02
hey folks, would anyone be able to let me know what I'm doing wrong in my for loop on line 55-62 - for some reason it can't seem to access the 'twitchers' array properly?
alteducation
@alteducation
Oct 11 2017 15:09
hi I tried changing the for loops inside this code to forEach arrow fucntions but it didnt work. Could someone help

    <!-- Dropdown Filter -->


    function filterCards() {

      var card = document.getElementsByClassName('card-parent');
      var cardState = Array.from(document.getElementsByClassName("card-state"));
      var cardApproach = Array.from(document.getElementsByClassName("card-approach"));


      if(states.value == "All States" && approach.value == "All Learning Methods"){
        $('.card-parent').show();
        return;
      }
      else if (states.value == "All States" && approach.value !== "All Learning Methods"){
        for (i = 0; i < card.length; i++) {
          cardApproach[i].textContent.includes(approach.value) ? card[i].style.display = "inline-block" : card[i].style.display = "none";
          }

        return;
      }
      else if (approach.value == "All Learning Methods" && states.value !== "All States"){
        for (i = 0; i < card.length; i++) {
          cardState[i].textContent.includes(states.value) ? card[i].style.display = "inline-block" : card[i].style.display = "none";
          }

        return;
      }
      else{
        for (i = 0; i < card.length; i++) {
          cardState[i].textContent.includes(states.value)  && cardApproach[i].textContent.includes(approach.value) ? card[i].style.display = "inline-block" : card[i].style.display = "none";
          }

        return;
      }
    }

  var states = document.getElementById('state');
  var approach = document.getElementById('approach');

  [states,approach].forEach(function(item){
    item.addEventListener('change', filterCards);
  });
korzo
@korzo
Oct 11 2017 15:09
@Benjmhart you pass twitchers as callback argument, but it's event, not your array
@Benjmhart
$('#search').change(function(twitchers){
this line
because jQuery will pass event object as argument
Ben Hart
@Benjmhart
Oct 11 2017 15:10
right, so the event happens to search and it's looking for an event object instead of the variable I'm calling?
how do I get jquery to grab the variable properly?
korzo
@korzo
Oct 11 2017 15:11
@Benjmhart
$('#search').change(function(){
Ben Hart
@Benjmhart
Oct 11 2017 15:26
oh just don't pass it and it will grab the global?
Kaz Baig
@kbaig
Oct 11 2017 15:26
@Benjmhart yes
Ben Hart
@Benjmhart
Oct 11 2017 15:27
cool, thanks @korzo
CamperBot
@camperbot
Oct 11 2017 15:27
benjmhart sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 612 | @korzo |http://www.freecodecamp.com/korzo
linkin-park
@linkin-park
Oct 11 2017 15:31
being a devops sucks :(
Kaz Baig
@kbaig
Oct 11 2017 16:47
Anyone know how to make my force directed graph stay within my svg's dimensions? https://codepen.io/kbaig/pen/OxEvdj?editors=0010
Kaz Baig
@kbaig
Oct 11 2017 16:50
@moT01 That is implementing a border, so if the node wants to be outside the svg, it will be on the border. I just want to scale the distances down.
Tom
@moT01
Oct 11 2017 16:51
you could play around with the forces so it's more tightly bound
and maybe make the svg a little bigger
but that still wont force it to be within the svg
Kaz Baig
@kbaig
Oct 11 2017 16:52
I've tried making the SVG 1000 x 1000 and that wasn't enough
Tom
@moT01
Oct 11 2017 16:52
it might be drawn within it, but when you let the user drag things around they could be thrown out
Kaz Baig
@kbaig
Oct 11 2017 16:52
The centering force should bring them back after the user releases the drag
Tom
@moT01
Oct 11 2017 16:54
play around with the forces
.force('charge', d3.forceManyBody().strength(-0.5))
you can check out mine as well if you want https://s.codepen.io/moT01/pen/EWmYPq
piteto
@piteto
Oct 11 2017 16:55
I was going to say, this seems to work:
.force('charge', d3.forceManyBody().distanceMax(w/5))
Kaz Baig
@kbaig
Oct 11 2017 16:55
@moT01 I've been playing around with the link force this whole time, just realized the charge force could be it, thanks!
CamperBot
@camperbot
Oct 11 2017 16:55
kbaig sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 874 | @mot01 |http://www.freecodecamp.com/mot01
piteto
@piteto
Oct 11 2017 16:58
or, more accurately: .force('charge', d3.forceManyBody().distanceMax((h / 4) - (padding / 2)))
Tom
@moT01
Oct 11 2017 17:01
d3 is cool, i should really go learn it better
Spyrantis Theodoros
@thodorisanta
Oct 11 2017 17:21

can someone help me fix the bugs in my tic tac toe project pleasee! im in this project for a while and cant just finish it. Im good with the player vs player part. my player vs computer has some bugs though.1) for instance when the game starts if its computers turn and the player rushes to click a box. the player basically loses a turn and the computer plays 2 times. 2) if its players turn and the player clicks a couple times same thing happens, player loses a turn and the computer plays a couple times(accordingly to the clicks). 3) for some reason when the computer wins(3 X's or O's in a turn) the player has to click one more time(play for 1 more turn bassically) and then the message that "computer wins" appear.And in that 1 more turn, the player can actually win the game. those are the ones i found atleast. PLEASE HELP :(
I have 2 functions for the computer turn in js and the computer plays randomly

https://codepen.io/oshikurou/pen/RVRqLM?editors=1010

alpox
@alpox
Oct 11 2017 17:49
@thodorisanta You're everywhere :D
Tom
@moT01
Oct 11 2017 17:58
@thodorisanta the first problem, make a boolean variable
var computerIsPlaying = false;
set it to true when you call the computers turn and false at the end of the turn, and anytime a player clicks something, check if(computerIsPlaying) before you let anything else happen
Nick
@rhozeta
Oct 11 2017 18:01

Hey all, can anyone give me a hand? I am trying to make a game where you select the correct color square from the RGB provided. and can't seem to get .textContent to update my span to display if the user was correct or incorrect. I get no display at all.
Much thanks

Here is my HTML:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>RGB Guesser</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <h1>The Great <span class="colorDisplay">RGB</span> Color Game</h1>
    <div>
        <span class="status"></span>
    </div>
    <div id="container">
        <div class="square"></div>
        <div class="square"></div>
        <div class="square"></div>
        <div class="square"></div>
        <div class="square"></div>
        <div class="square"></div>
    </div>
    <script src="script.js"></script>
</body>

</html>

and my JS:

var colors = [
  "rgb(255, 0, 0)",
  "rgb(255, 255, 0)",
  "rgb(0, 255, 0)",
  "rgb(0, 255, 255)",
  "rgb(0, 0, 255)",
  "rgb(255, 0, 255)"
];

//Select and display winning color.
var pickedColor = colors[3];
var squares = document.querySelectorAll(".square");
var colorDisplay = document.querySelector(".colorDisplay");
var status = document.getElementsByClassName("status");
colorDisplay.textContent = pickedColor;

//Loop through squares
for (i = 0; i < squares.length; i++) {
  //add initial colors
  squares[i].style.backgroundColor = colors[i];
  //add click listeners and grab, compare selected to winning.
  squares[i].addEventListener("click", function() {
    var selected = this.style.backgroundColor;
    if (selected === pickedColor) {
      status.textContent = "You Win!";
    } else {
      this.style.background = "#232323";
      status.textContent = "Try Again!";
    }
  });
}

_

piteto
@piteto
Oct 11 2017 18:11
@rhozeta status is a reserved word in JavaScript. Change your variable name to something like statusMessage
Also, getElementsByClassName returns a collection - make it an ID in your HTML and use document.getElementById
Nick
@rhozeta
Oct 11 2017 18:12
Ah! Thank you! Didn't even think to check reserved keywords.
piteto
@piteto
Oct 11 2017 18:13
Sometimes they're the perfect variable name, but unfortunately...someone else thought of it before
:)
Koleen BP
@KBPsystem777
Oct 11 2017 18:22
Hi guys! would like you seek your feedback on my random quote machine: https://kbpsystem777.github.io/random-quote-machine/index.html
Thanks in advance :)
Kaz Baig
@kbaig
Oct 11 2017 18:25
@KBPsystem777 Suggestions:
  • You could make the challenge link text a hyperlink
  • The quote box could prob do with a border and/or shadow
  • It would also be cool if the buttons didn't move every time I clicked generate quote
piteto
@piteto
Oct 11 2017 18:32
@KBPsystem777 Nice work - you should probably remove console.log statements from the final app. Perhaps consider running newQuote() on window load so we get a quote when first opening the page, and although not 100% necessary for your current quotes, tweets should to be encoded with encodeURIComponent()
This is a real nitpick, but none of your code was "compiled" *** Compiled and Coded by Koleen BP *** (at least by the CS definition)
Kaz Baig
@kbaig
Oct 11 2017 18:40
Still struggling to find a way to make the nodes image sprites on codepen in svg. Any hints would be appreciated https://codepen.io/kbaig/pen/OxEvdj?editors=1010
Koleen BP
@KBPsystem777
Oct 11 2017 19:20
thanks @kbaig and @piteto I will surely address your feedback :)
CamperBot
@camperbot
Oct 11 2017 19:20
kbpsystem777 sends brownie points to @kbaig and @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 235 | @piteto |http://www.freecodecamp.com/piteto
:cookie: 353 | @kbaig |http://www.freecodecamp.com/kbaig
Ve Vanderpool
@VanAmoVe
Oct 11 2017 19:55
I know this isn't a question in FCC but can anyone help?

function hasGlasses(eyesight){

if(eyesight>=20){console.log("Nice Glasses");
}
else{console.log("You should maybe look into getting some glasses...");}
}
hasGlasses(30);

Create a function called hasGlasses that takes in a boolean argument. Then, add an evaluation to your argument to check whether the argument is true or false.

If the argument is true, return the string "Nice glasses."
If the argument is false, return the string "You should maybe look into getting some glasses..."

its working but I don't think it likes my answer
alpox
@alpox
Oct 11 2017 19:59
@VanAmoVe you log the answer to the console but the question asks you to return the string from the function
Ve Vanderpool
@VanAmoVe
Oct 11 2017 20:01
ah!
lemme try that
thanks!
alpox
@alpox
Oct 11 2017 20:03
@VanAmoVe np
Ve Vanderpool
@VanAmoVe
Oct 11 2017 20:15
ok I can't understand how to make a return statement without defining the parameters in the function, but how can I define the parameters if its a function?
alpox
@alpox
Oct 11 2017 20:17
@VanAmoVe what parameters are you talking about? With a return, you can return any value or variable
intcreate
@intcreate
Oct 11 2017 20:28

The slider is working but when the first background slides in you can see the white background from behind and I dont know why that is happening. The last background should slide out to the left and then first background should slide in so there will be no white background.

You can inspect the codepen and see it changing classes.

The previous class makes the background go to the left of the screen.

The item class makes the background go to the right of the screen.

The active class is the background that you currently see.

https://codepen.io/anon/pen/qPKwOb

https://imgur.com/a/v8rlz

piteto
@piteto
Oct 11 2017 20:30
@VanAmoVe 30 isn't a boolean argument, maybe that's part of the reason this isn't working?
To return those values, use return instead of console.log
function hasGlasses(eyesight) {
  if (eyesight >= 20) {
    return "Nice Glasses";
  } else {
    return "You should maybe look into getting some glasses...";
  }
}
hasGlasses(30);
Renan Teixeira Ferraz
@RTFerraz
Oct 11 2017 20:44
Hi there
I'm stuck in the arguments optional
Renan Teixeira Ferraz
@RTFerraz
Oct 11 2017 20:50
``
function addTogether() {
  var num = 0;
  var test = [];
  for (var i in arguments){
    if(typeof arguments[i] === 'number' && test.length <= 2){
      test.push(true);
      num += arguments[i];
    } else if (typeof arguments[i] !== 'number'){
      num = undefined;
    }
  }
  if(test.length != 2){
    return num == typeof arguments[i] !== 'number'? undefined : addTogether();
  }
  return num;
}

addTogether(2, 3);
Renan Teixeira Ferraz
@RTFerraz
Oct 11 2017 21:01
I don't know how to use addTogether() recursively
korzo
@korzo
Oct 11 2017 21:02
@RTFerraz If there is only one argument, you have to return function taking one argument and sum it with argument from addTogether
If only one argument is provided, then return a function that expects one argument and returns the sum.
@RTFerraz It's not recursion, but closure
Renan Teixeira Ferraz
@RTFerraz
Oct 11 2017 21:03
hmm
korzo
@korzo
Oct 11 2017 21:03
@RTFerraz you shouldn't be calling addTogether, but return new function
@RTFerraz
  return function(second) {
    return typeof second === "number" ? storedArgument + second : undefined;
  };
Renan Teixeira Ferraz
@RTFerraz
Oct 11 2017 21:04
so with addTogether(2)(3), it would keep the 2 and later add with three?
korzo
@korzo
Oct 11 2017 21:04
@RTFerraz exactly
Renan Teixeira Ferraz
@RTFerraz
Oct 11 2017 21:04
hmm
korzo
@korzo
Oct 11 2017 21:05
If there are 2 arguments, you return result
If only one, you assign argument to variable and return function @RTFerraz
Renan Teixeira Ferraz
@RTFerraz
Oct 11 2017 21:05
I should create a function that stores the argument of the first run and then adds to the argument of the previous run?
next run
korzo
@korzo
Oct 11 2017 21:06
@RTFerraz No, it will be stored in scope
Ve Vanderpool
@VanAmoVe
Oct 11 2017 21:07
how do you set it up to return a string?
Renan Teixeira Ferraz
@RTFerraz
Oct 11 2017 21:07
Ah
It'll be stored in the outer function scope
korzo
@korzo
Oct 11 2017 21:07
function sum(a) {
   return function (b) {
     return a + b;
  }
}

var  a = sum(5);
console.log(a(5));
@RTFerraz
Renan Teixeira Ferraz
@RTFerraz
Oct 11 2017 21:07
?
hmm
korzo
@korzo
Oct 11 2017 21:08
@RTFerraz yes
Renan Teixeira Ferraz
@RTFerraz
Oct 11 2017 21:08
I saw something similar in the article
thanks @korzo, I'll see here if I understood
CamperBot
@camperbot
Oct 11 2017 21:09
rtferraz sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 613 | @korzo |http://www.freecodecamp.com/korzo
korzo
@korzo
Oct 11 2017 21:09
function sum(a) {
   var c = a + 2;
   return function (b) {
     return c + b;
  }
}

var  a = sum(5);
console.log(a(5));
@RTFerraz
Ve Vanderpool
@VanAmoVe
Oct 11 2017 21:09
@piteto I did try that...
its very particular...
I wonder if I am not sitting top a boolean properly in the function?
piteto
@piteto
Oct 11 2017 21:12
@VanAmoVe A boolean is either true/false. Where is this challenge from? I think you're the third person I've seen in the past few days with that hasGlasses function
Seems to be popular :p
Ve Vanderpool
@VanAmoVe
Oct 11 2017 21:12
devmountian precourse
right, so it asks to

Create a function called hasGlasses that takes in a boolean argument. Then, add an evaluation to your argument to check whether the argument is true or false.

If the argument is true, return the string "Nice glasses."
If the argument is false, return the string "You should maybe look into getting some glasses..."

when it says takes in a boolean argument. that confuses me
korzo
@korzo
Oct 11 2017 21:14
@VanAmoVe
Boolean can be only true or false
piteto
@piteto
Oct 11 2017 21:14
function myFunc(bool) {
  if (bool) {
    return "This is true";
  } else {
    return "This is false";
  }
}
Ve Vanderpool
@VanAmoVe
Oct 11 2017 21:14
I know but I don't know how to set up a boolean in a function
ok, let me try somthing
korzo
@korzo
Oct 11 2017 21:15
@VanAmoVe You don't have to setup. It will be passed as argument
But @piteto already spilled the beans
piteto
@piteto
Oct 11 2017 21:16
spilled the bools* ;)
korzo
@korzo
Oct 11 2017 21:17
:joy_cat:
piteto
@piteto
Oct 11 2017 21:17
Thanks for the courtesy laugh lol
Ve Vanderpool
@VanAmoVe
Oct 11 2017 21:17
lol
Kaz Baig
@kbaig
Oct 11 2017 21:17
@RTFerraz
// jshint esversion:6
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;  
  }

}
Ve Vanderpool
@VanAmoVe
Oct 11 2017 21:18
this has me feeling so stupid
piteto
@piteto
Oct 11 2017 21:21
They use a lot of the same challenges that we have here at Free Code Camp: https://precourse.devmountain.com/map
Ve Vanderpool
@VanAmoVe
Oct 11 2017 21:21
they do
this part is repl.it
then I do FCC problems after, I did FCC first before deciding on bootcamp
G-4-R-Y
@G-4-R-Y
Oct 11 2017 21:22
hey guys, i can't figure out what's wrong here (diff two arrays)
function diffArray(arr1, arr2) {
  var newArr = [];
  var newArr1 = [];
  var newArr2 = [];

  for (var i = 0; i < arr1.length; i++) {
    var check1 = arr2.indexOf(arr1[i]);
    if (check1 == -1) {
      newArr1.push(arr1[i]);
    }} 

  for (var o = 0; o < arr2.length; o++) {
    var check2 = arr1.indexOf(arr2[i]);
    if (check2 == -1) {
      newArr2.push(arr2[i]);
    }}

  newArr = arr1.concat(arr2);
  return newArr;
}
korzo
@korzo
Oct 11 2017 21:23
@G-4-R-Y Why to push to 3 different arrays?
You can use just newArr
G-4-R-Y
@G-4-R-Y
Oct 11 2017 21:24
i was doing that, i was just trying different things lol
Ve Vanderpool
@VanAmoVe
Oct 11 2017 21:24
ahhh. I was missing a period on "Nice glasses." a period!
thanks @piteto
CamperBot
@camperbot
Oct 11 2017 21:25
vanamove sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 236 | @piteto |http://www.freecodecamp.com/piteto
korzo
@korzo
Oct 11 2017 21:25
@G-4-R-Y you return newArr = arr1.concat(arr2);
piteto
@piteto
Oct 11 2017 21:25
oh no! Glad you got it figured out @VanAmoVe :)
korzo
@korzo
Oct 11 2017 21:25
@G-4-R-Y instead of newArr1.concat(newArr2);
Ron Laniado
@ronlaniado
Oct 11 2017 21:28
document.addEventListener("keyup", function(event) {
  if (event.keyCode == 13) {
    event.preventDefault(); //Disables the form from being submitted
    $("#userInput").animate({ //animates the search box
      marginTop: "1.5%",
      height: "35px",
      fontSize: "18px",
    }, 1000);
    searchWiki();
    $("#userInput").val('');
    console.log($("#userInput"));
    document.querySelector(".card").style.display = "block"; //makes the card not hidden
    $(".card").animateCss("fadeInLeft"); //makes the card fade in left
    setTimeout(function() {
      document.querySelector("#card2").style.display = "block";
      $("#card2").animateCss("fadeInLeft");
    }, 200);
G-4-R-Y
@G-4-R-Y
Oct 11 2017 21:28
@korzo lol, didn't see that
but still not working :(
Ron Laniado
@ronlaniado
Oct 11 2017 21:28
So I am trying to empty out #userInput after searchWiki () is called, but it doesnt seem to work
userInput is a search box I am using, and this piece of code seems to clear what you see in the search, if I try and search again, it will actually add the previous value to the search
A live demo can be found here ronlaniado.github.io/Wikipedia-Viewer/
G-4-R-Y
@G-4-R-Y
Oct 11 2017 21:30
@korzo found another mistake here, lemme see if it works now
Ron Laniado
@ronlaniado
Oct 11 2017 21:30
Try to search twice w/o reloading the page, and there will be problems
G-4-R-Y
@G-4-R-Y
Oct 11 2017 21:30
thanks anyway!
Ron Laniado
@ronlaniado
Oct 11 2017 21:30
Any help would be appreciated
korzo
@korzo
Oct 11 2017 21:32
@G-4-R-Y was it o ?
G-4-R-Y
@G-4-R-Y
Oct 11 2017 21:34
@korzo yes haha, thanks!
CamperBot
@camperbot
Oct 11 2017 21:34
g-4-r-y sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 614 | @korzo |http://www.freecodecamp.com/korzo
G-4-R-Y
@G-4-R-Y
Oct 11 2017 21:34
@korzo i forgot to change the "i"s to "o"s
korzo
@korzo
Oct 11 2017 21:36
@G-4-R-Y I missed it at first too . found out after tests were still failing
Jose Diaz
@jsd540
Oct 11 2017 22:41
Hey everyone... I was reforming the html for the twitch project and forgot to disable the api calls, I now get and error 429, and rightfully so as I was reloading a lot when reformatting the css. Anyway there is no message as to when this will be re-set. Has anyone else done this and if so how long till I can request from the api?
Jose Diaz
@jsd540
Oct 11 2017 22:51
@ronlaniado i used $( "your_div" ).remove(); immediately after the success: function
Moisés Man
@moigithub
Oct 11 2017 22:52
i think fcc provides their own api endpoint for twitchtv which uses some sort of caching
korzo
@korzo
Oct 11 2017 22:54
@jsd540 As far as I remember, there is limit 1 request/second.
Try to check your account for some hints.
@jsd540 check response headers https://dev.twitch.tv/docs/api#rate-limit
aRtoo
@artoodeeto
Oct 11 2017 23:02
hey guys for the calculator challenge are we allowed to use eval()
Jose Diaz
@jsd540
Oct 11 2017 23:04
@korzo thanks for the link, I waited a few seconds and it came back, I was worried I was banned since I was working on this since yesterday and tend to refresh too much..
CamperBot
@camperbot
Oct 11 2017 23:04
jsd540 sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 615 | @korzo |http://www.freecodecamp.com/korzo
Ve Vanderpool
@VanAmoVe
Oct 11 2017 23:14
help!
function hasGlasses(boo1,boo2){
if(boo1){return "Nice glasses.";}
else if(boo2){return "Congrats on being one of the few people who look good without glasses!";}
else{return "You should maybe look into getting glasses...";}
}

Create a function called hasGlasses that takes in two boolean arguments, the first for if a person has glasses, and the second for if they look good anyway. Then, add a nested evaluation to your argument to check which of the following sentences should be returned:

If the first argument is true, return the string "Nice glasses."
If the first argument is false, and the second argument is false, return the string "You should maybe look into getting some glasses..."
If the first argument is false, and the second argument is true, return the string "Congrats on being one of the few people who look good without glasses!"

it wants me to nest an evaluation but I can't figure out how and make it work
korzo
@korzo
Oct 11 2017 23:19
@VanAmoVe You don't have to use else/else if in case you are returning from if

@VanAmoVe

function hasGlasses(boo1, boo2) {
  if (boo1) {
    return 'Nice glasses.';
  }
  if (boo2) {
    return 'Congrats on being one of the few people who look good without glasses!';
  }
  return 'You should maybe look into getting glasses...';
}

Otherwise it should work unless you have some typo in strings

@VanAmoVe missing some in You should maybe look into getting glasses...
Ve Vanderpool
@VanAmoVe
Oct 11 2017 23:24
oh.my.god
very time
every single time
thank you
my freaking typos will be the end of me
@korzo lifesaver
@korzo thank you
CamperBot
@camperbot
Oct 11 2017 23:26
vanamove sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 616 | @korzo |http://www.freecodecamp.com/korzo
korzo
@korzo
Oct 11 2017 23:27
@VanAmoVe That's why I always copy/paste all texts :)
Glad to help