Where communities thrive


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

    thecodingaviator on master

    remove A (#31157) (compare)

  • Apr 01 2019 18:04
    thecodingaviator closed #31157
  • Apr 01 2019 18:04
    thecodingaviator closed #33788
  • Apr 01 2019 18:04
    thecodingaviator commented #33788
Moisés Man
@moigithub
function greaterThan3( value ) {
     if( value > 3) {return true;}
     else {return false;}
}
[1,2,3,4,5,6].filter ( greaterThan3 )
result : [4,5,6]
pablovvb
@pablovvb
thanks for the tip, @kumquatfelafel . I'll look into it :)
CamperBot
@camperbot
pablovvb sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 377 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
Johnny O'Sullivan
@johnnyosullivan

@pablovvb on the same problem. finding it trickier than I thought.

function destroyer(arr) { 
 var args = arr.slice.call(arguments);
 for (var i = 1; i < args.length; i++)
 var seek = args[i];
 var destroyed = args[0].filter(function(val){
   return val !== seek;
 });
 return destroyed;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);

Any advice would be helpful.

kumquatfelafel
@kumquatfelafel
@pablovvb Also note, as @moigithub points out, you can pass values into a function. Or rather, more importantly, you can provide that function with a parameter which enables you to reference a certain value...
pablovvb
@pablovvb
oooh!! that gets me way closer!
@johnnyosullivan in my humble review, I don't get that args[0]. What does destroyed return?
Moisés Man
@moigithub
@johnnyosullivan what value will destroyed have after run this code...
destroyed = 1;
destroyed = 2;
destroyed = 3;
@pablovvb args is a copy of arguments... which is this [[1, 2, 3, 1, 2, 3] , 2 , 3]
soo args[0] is the first element [1, 2, 3, 1, 2, 3]
which is the same as arr
Johnny O'Sullivan
@johnnyosullivan
@moigithub @pablovvb
[1,2,1,2] is what it's returning right now.
Moisés Man
@moigithub
@johnnyosullivan u not answering the question :)
:point_up: 27 de junio de 2017 20:13 1, 2 or 3
Johnny O'Sullivan
@johnnyosullivan
Am I not? Sorry. Let me revisit.
kumquatfelafel
@kumquatfelafel

@johnnyosullivan what value will destroyed have after run this code...

destroyed = 1;
destroyed = 2;
destroyed = 3;

^this bit. Will destroyed be 1?

pablovvb
@pablovvb
@moigithub @johnnyosullivan man, that's cleaner than mine :P I like it!! (and @johnnyosullivan , I'm exactly in the same place)
Johnny O'Sullivan
@johnnyosullivan
@kumquatfelafel @moigithub oh man, I'm having one of those moments...I don't understand the question.
georgebatton
@georgebatton
jnbjk
kumquatfelafel
@kumquatfelafel

@johnnyosullivan If one were to say

var destroyed = 1;
destroyed = 2;
destroyed = 3;
console.log(destroyed);

What would show up in console?

georgebatton
@georgebatton
Why can't I use for Stand in Line: arr.push(item);
var remove=arr.shift(item);
pablovvb
@pablovvb
@johnnyosullivan I think moi is into something with mine as well. I may be replacing once and again the value I want to get
Saif Ur Rahman
@saifsmailbox98
@georgebatton vvv return remove.
kumquatfelafel
@kumquatfelafel
@georgebatton ^^^ Shift doesn't require an argument.
georgebatton
@georgebatton
why does push require one but shift doesn't?
Saif Ur Rahman
@saifsmailbox98
@georgebatton push adds that to the array, shift is used to remove element.
kumquatfelafel
@kumquatfelafel
@georgebatton Shift just removes first element from array. Doesn't really care what we lowly humans and/or rodents have to say. :p
There's no need for any kind of special input in order to remove an element.
Johnny O'Sullivan
@johnnyosullivan
Wouldn't destroyed just be equal to the number you assign it in those cases?
Moisés Man
@moigithub
@johnnyosullivan code runs from top to bottom
@johnnyosullivan but it WONT have all 3 values
it can be 1 OR 2 OR 3... soo what value will be after the code is executed ?
Johnny O'Sullivan
@johnnyosullivan
3
?
Moisés Man
@moigithub
yep only last value prevails
kumquatfelafel
@kumquatfelafel
aye
Kent Saeteurn
@sansae

Hi all,
I am working on the "Arguments Optional" challenge. I have tested all 5 cases. The returned results are exactly what FreeCodeCamp wants, however, when click submit, only the top two cases are marked as correct. The last 3, which expects "undefined" to be returned, are marked incorrect. When testing for all 3 undefined cases in FCC's editor window, the returned result is "undefined" (It shows on the left hand column).

Does anyone know why FCC won't recognize the returned values of "undefined"?

kumquatfelafel
@kumquatfelafel

@sansae post code

(if you're doing something like return "undefined"; lose the "")

Johnny O'Sullivan
@johnnyosullivan
ok. so my problem is with the variable seek.
it's only taking the last item in the args array.
Kent Saeteurn
@sansae
@kumquatfelafel https://repl.it/JEqA/67
Moisés Man
@moigithub

@johnnyosullivan soo another concept
a loop repeat code

for (var x=1; x<= 3; x++){
    doSomething(x);
}

will do
doSomething(1)
doSomething(2)
doSomething(3)

kumquatfelafel
@kumquatfelafel
@sansae :point_up_2: see my reply. "undefined" != undefined.
"undefined" is a string that happens to be the word "undefined". undefined, on the other hand, is... well... undefined.
Johnny O'Sullivan
@johnnyosullivan
Thanks @moigithub and @kumquatfelafel . I have to retire for the evening, but you've set me straight.
CamperBot
@camperbot
johnnyosullivan sends brownie points to @moigithub and @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 378 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
:star2: 3440 | @moigithub |http://www.freecodecamp.com/moigithub
Johnny O'Sullivan
@johnnyosullivan
Or on the right path at least.
Kent Saeteurn
@sansae
@kumquatfelafel yikes. i just returned a string didn't I? lol Oops
@kumquatfelafel i fixed it
Moisés Man
@moigithub

@johnnyosullivan soo on ur code.. on each iteration u replacing destroyed values reassigning it
only last filter result prevail

var destroyed = [1, 2, 3, 1, 2, 3].filter() // when seek is 2
var destroyed = [1, 2, 3, 1, 2, 3].filter() // when seek is 3
last one return [1,2,1,2]

Kent Saeteurn
@sansae
@kumquatfelafel thank you!
CamperBot
@camperbot
sansae sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles: