Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
iso
@iso1048
@jtan3 no worries
Tom
@moT01
@gothamknight ([erp]meti!)fi
iso
@iso1048
@moT01 i don't get it bro
oh its reversed of something I had...
@moT01 i changed item.hasOwnProperty(pre) to what you said (!item[pre]) and it worked.....why did it work?
just1witness
@just1witness
@gothamknight Your using .forEach(), look into .every() instead.
Tom
@moT01
cause the one test that was failing had that property
just1witness
@just1witness
hint, it's excruciatingly simple. @gothamknight
Tom
@moT01
the value was just NaN
so your test found the key there, and my test searched for the value
if that makes sense
and a NaN value isn't a value - like undefined or false
just1witness
@just1witness
@gothamknight just for reference, here's how you use .every()
function truthCheck(collection, pre) {
  return collection.every(function(a){
   return a[pre];
  });
}
iso
@iso1048
ok i get that NaN is not a value, since it makes no difference if I have it in that array i had. But I do not understand why !item[pre] was able to identify NaN... @moT01 @just1witness
@just1witness oh that is much better
Tom
@moT01
so it searches for item['single'] and gets the value that it holds which is NaN which is false
just1witness
@just1witness
:)
iso
@iso1048
@moT01 sorry i am being a bit of a dimwit - why does that specific test still pass regardless of whether or not there is ! in front of item['single']?
Tom
@moT01
cause in that specific test the other one is false
if(item[single]) == 'double' which is true
and sets your variable to false
if that makes sense
but the NaN one doesn't pass there
iso
@iso1048
because item['single'] evalutes to NaN, and NaN is null...(and null is in the array)?
Tom
@moT01
im not sure on that test of yours
i would have done maybe....
iso
@iso1048
@moT01 because NaN does not need to be in the array for me to pass the challenge
Tom
@moT01
if (!item.hasOwnProperty(pre) || item[pre] == (NaN || 0 || ...)){check = false;}
iso
@iso1048
@moT01 so if (!item.hasOwnProperty(pre) || item[pre] == (NaN || 0 || null || undefined || "")){check = false;} - that does not work.
Tom
@moT01
hmm, maybe you can't do a test like that - i thought you could
no, you can
i think there's something specific you have to do for a few of those
it's not recognizing it when you type NaN
you have to use isNaN()
and maybe the same for null or something
iso
@iso1048

yeah I had a look at that. I think it is fine for null though. I still do not get why

function truthCheck(collection, pre) {
  var check = true;
  collection.forEach(function(item){
    if (!item[pre] || [null, undefined, 0, ""].indexOf(item[pre]) > -1){check = false;}  
  });
  return check;
}

truthCheck([{"single": "double"}, {"single": NaN}], "single");
function truthCheck(collection, pre) {
  var check = true;
  collection.forEach(function(item){
    if (item[pre] || [null, undefined, 0, ""].indexOf(item[pre]) > -1){check = false;}  
  });
  return check;
}

truthCheck([{"single": "double"}, {"single": NaN}], "single");

both pass this specific test though

Tom
@moT01
all you need is !item[pre]
passes all
iso
@iso1048
oh true!
ok, then why does that test pass with both !item['single'] and item['single']? wouldn't the latter evaluate to false in the second object of collection?
Tom
@moT01
yes, but the first one wouldn't work
so the first one passes that test and sets it to false
iso
@iso1048
of course. I really am being an idiot. Thanks for all the help @moT01 (and sorry for wasting your time)
CamperBot
@camperbot
gothamknight sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 819 | @mot01 |http://www.freecodecamp.com/mot01
Tom
@moT01
im not doing much else
CamperBot
@camperbot
:cookie: 819 | @mot01 |http://www.freecodecamp.com/mot01
Markus Kiili
@Masd925
@gothamknight Method .every() would do the same as that flag variable and forEach. So it suits the problem well.
Mukesh Kumar Angrish
@MukeshAngrish
Hey guys, I need some help as my Tic Tac Toe app is not working properly. I have fairly good reasons to believe that is issue is with the minmax() function as I have tried running the app without using the minmax()function and it worked. Also I have some issue with the html/css maybe as the divs move from their location when I click on them.