Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:33
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • May 10 09:13
    @bjorno43 banned @zhaokunhaoa
  • Apr 25 17:12
    @mstellaluna banned @cmal
  • Apr 01 18:11
    thecodingaviator labeled #31179
  • Apr 01 18:11
    thecodingaviator labeled #31179
  • Apr 01 18:09
    thecodingaviator commented #31179
  • Apr 01 18:09
    thecodingaviator labeled #31182
  • Apr 01 18:09
    thecodingaviator labeled #31182
  • Apr 01 18:07
    thecodingaviator commented #31182
  • Apr 01 18:07
    thecodingaviator labeled #31190
  • Apr 01 18:07
    thecodingaviator labeled #31190
  • Apr 01 18:07
    thecodingaviator commented #31190
  • Apr 01 18:05
    thecodingaviator commented #31157
  • Apr 01 18:04

    thecodingaviator on master

    remove A (#31157) (compare)

  • Apr 01 18:04
    thecodingaviator closed #31157
  • Apr 01 18:04
    thecodingaviator closed #33788
  • Apr 01 18:04
    thecodingaviator commented #33788
  • Apr 01 18:02
    thecodingaviator closed #31059
  • Apr 01 18:02
    thecodingaviator commented #31059
Ahmad Abdolsaheb
@ahmadabdolsaheb

hey everyone, I am trying to use filter, however, i want it to some times not filter anything. this is currently what i have

cards.filter(card=> card.type == "awards")

i have a variety of cards and sometimes i want filter to include all of the cards. how can I do that?

Ken Haduch
@khaduch

@ahmadabdolsaheb - without knowing all that you're doing, how about not calling the .filter when you don't want to actually filter, or if you make a "control" variable like this:

let doAll = true;
cards = cards.filter(card=> card.type == "awards" || doAll );

So that you can set doAll to the value you want (based on some condition) and then it would always pass the test? That's at least one take at it... You have to catch the return from the .filter, so I just threw that in there...

Ahmad Abdolsaheb
@ahmadabdolsaheb
@khaduch so cards.filter(card=> card.type == true ); does not seem to return all items.
i tried it in js fiddle
array = [1,2,3,5]; console.log(array.filter(num => num == true)); only returns one
Markus Kiili
@Masd925
@ahmadabdolsaheb What are you trying to do? Why use abstract equality == (which nobody remember how it works really).
Ahmad Abdolsaheb
@ahmadabdolsaheb
@Masd925 i have cards with different types. i wanna show a specific card type when a relevant button is pressed. but, sometime, i wanna show all cards.
i am trying to use filter not to filter :)
cards.filter(card=> card.type == "awards")
what should I use instead of "awards and includes everything
or
cards.filter(card=> card.type === "awards")
Markus Kiili
@Masd925
@ahmadabdolsaheb There is no value that would be equal to all strings. cards.filter(card => true) would keep all elements.
cards.filter(card => card.type) would also keep all cards provided that types are non-empty strings.
@ahmadabdolsaheb I think that changing the logic as @khaduch said is best.
Ahmad Abdolsaheb
@ahmadabdolsaheb
@Masd925 @khaduch i think i will change logic since making a control variable didn't work. thanks
CamperBot
@camperbot
ahmadabdolsaheb sends brownie points to @masd925 and @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3677 | @khaduch |http://www.freecodecamp.org/khaduch
:star2: 4653 | @masd925 |http://www.freecodecamp.org/masd925
Ken Haduch
@khaduch
:point_up: January 15, 2018 9:20 AM @ahmadabdolsaheb - you need to do something like what I posted in my comment above yours - cards = cards.filter(card=> card.type == "awards" || doAll ); - the variable doAll would be set to true or false (or something that evaluated to true or false) and if it did not match the first conditional test, then if doAll evaluated to true, it would add the card to the output array. It is the || "or" condition that makes it work. It is a common way to affect conditional tests. So it will work, but it might not always be the best way to do things, for example, if you have a 1000 element array that you don't need to filter, then maybe it is not too efficient to do this (just thinking of performance).
Jason Luboff
@JLuboff
:wave:
Gersho
@Gersho
:wave:
Jason Luboff
@JLuboff
What up
Markus Kiili
@Masd925
Yo
Jason Luboff
@JLuboff
@Masd925 Yo'
Kaz Baig
@kbaig
:wave:
Jason Luboff
@JLuboff
Whats good?
Kaz Baig
@kbaig
TFW you were sick last week so you didn't get much done at work, but now you're even more sick and need to start working harder to catch up :(
Jason Luboff
@JLuboff
Flu?
Markus Kiili
@Masd925
@JLuboff I finally did a portfolio page.
Jason Luboff
@JLuboff
@Masd925 Impressive!
Kaz Baig
@kbaig
@JLuboff sinus infection into bronchitis about 4 weeks ago that almost ended but now I'm coughing hard again and throat is swollen :(
Jason Luboff
@JLuboff
@kbaig Shitty. Did you get antibiotics for it?
Kaz Baig
@kbaig
@JLuboff Doc gave me some in case it's bacterial pneumonia, which they were seeing some cases of. But no, nothing to directly treat it as they thought it was probably viral
Markus Kiili
@Masd925
@JLuboff I have to do a better one at some point but at least I can put some projects there http://www.cleanprogramming.com Lacks my picture too at the moment.
Kaz Baig
@kbaig
@Masd925 what did you use for the particles?
Markus Kiili
@Masd925
@kbaig JS
Kaz Baig
@kbaig
No library?
Markus Kiili
@Masd925
I made a physics engine earlier for making some JS games and that uses it.
Jason Luboff
@JLuboff
@kbaig Lame. Hope you get well soon
Kaz Baig
@kbaig
@Masd925 oh cool. Maybe you'd enjoy looking at the source code for ParticleJS?
thanks bud
@JLuboff
Jason Luboff
@JLuboff
@Masd925 Master's degree in Theoretical and Mathematical Physics with a focus on particle physics eh?
Markus Kiili
@Masd925
@JLuboff That was 20 years ago. Don't remember any of that ;)
Kaz Baig
@kbaig
unlucky
Jason Luboff
@JLuboff
@Masd925 And then another degree just a few years ago. Mean while, I'm over here with just an Associates degree haha
Kaz Baig
@kbaig
Can someone pay for the 2 masters I'd like to do but can't imagine paying for? thx
Markus Kiili
@Masd925
@kbaig Yes, some library would do it too (and better) but maybe doing it by hand has some value too.
Kaz Baig
@kbaig
@Masd925 For sure. I just mean that you have the background to maybe more easily comprehend what's going on in ParticleJS's source
For learning purposes
Markus Kiili
@Masd925
@kbaig Yeah. Must be something similar going on there too.