These are chat archives for FreeCodeCamp/Help

4th
Sep 2015
Joseph Miller
@joemillervi
Sep 04 2015 00:00
Hey guys, working on pairwise:
function pairwise(arr, arg) {
  return arr.reduce(function(sumOfIndex, currentNumber, i){
      if(addsUp(arr, arg, i)) {
          console.log(sumOfIndex, i, currentNumber)
          return sumOfIndex + i;
      }
  }, 0)

  function addsUp(arr, arg, i) {
        didItMatch = false;
        for(var j = 0; j < arr.length; j++) {
            if(arr[j] + arr[i] === arg) {
                didItMatch = true;
                console.log(arr[j], arr[i])
            }
        }
        return didItMatch;
    }
}

console.log(pairwise([1,4,2,3,0,5], 7));
Aniruddh Agarwal
@anrddh
Sep 04 2015 00:00
bf pairwise
CamperBot
@camperbot
Sep 04 2015 00:00

:fire:Bonfire: Pairwise :link:

function pairwise(arr, arg) {
  return arg;
}

pairwise([1,4,2,3,0,5], 7);

Return the sum of all indices of elements of 'arr' that can be paired with one other element to form a sum that equals the value in the second argument 'arg'. If multiple sums are possible, return the smallest sum. Once an element has been used, it cannot be reused to pair with another.

more info:  bf details | bf links | hint

Joseph Miller
@joemillervi
Sep 04 2015 00:01
For some reason sumOfIndex turns into undefined
Moisés Man
@moigithub
Sep 04 2015 00:02
@jobo440 reduce needs u return something
Joseph Miller
@joemillervi
Sep 04 2015 00:02
ooooohhhhhhh
Moisés Man
@moigithub
Sep 04 2015 00:03
but u only returning something inside ur IF condition.. what if its false ?
Joseph Miller
@joemillervi
Sep 04 2015 00:04
ok of course omg thanks @moigithub
CamperBot
@camperbot
Sep 04 2015 00:04
jobo440 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 297 | @moigithub | http://www.freecodecamp.com/moigithub
Spatz
@Spatzerny
Sep 04 2015 00:11
:D
i had to because of my stupid little 'i made a thing' feeling :D
Joseph Miller
@joemillervi
Sep 04 2015 00:14
@Spatzerny haha nice
a slothy thing
Spatz
@Spatzerny
Sep 04 2015 00:15
i'm gonna call it the apathy elemental
Dylan Barnett
@czeck6
Sep 04 2015 00:24
I'm trying to do the "bringing your slot machine to life exercise" where my script is supposed to insert the 3 random numbers into the slot machine's html but I keep getting this error... missing ; before statement
Dylan Barnett
@czeck6
Sep 04 2015 00:30
I put this in...
'''
CamperBot
@camperbot
Sep 04 2015 00:30
:bulb: to format code use backticks! ``` more info
DTing
@dting
Sep 04 2015 00:32
@Spatzerny lol
Dylan Barnett
@czeck6
Sep 04 2015 00:33
 selector $(".slot")
    $($(".slot")[0]).html(slotOne);
    $($(".slot")[1]).html(slotTwo);
    $($(".slot")[2]).html(slotThree);
DTing
@dting
Sep 04 2015 00:33
nice. im scared to ask what the background photo is
Spatz
@Spatzerny
Sep 04 2015 00:33
just seamless fur
DTing
@dting
Sep 04 2015 00:33
@czeck6 you just need to remove the first line
Spatz
@Spatzerny
Sep 04 2015 00:34
is there a reason to doublewrap those?
Moisés Man
@moigithub
Sep 04 2015 00:36
@czeck6 at left side of that exercise there are an example line
basiclly u need to copy /paste 3 times and modify
itsahoax
@itsahoax
Sep 04 2015 00:38
'Waypoint: Give a Background Color to a Div Element' I've created the gray background class, but how do I assign it in the div?
Spatz
@Spatzerny
Sep 04 2015 00:40
<div class="nameoftheclass">
hollowc2
@hollowc2
Sep 04 2015 00:41
--------Bonfire: Return Largest Numbers in Arrays ------------------ need help!! i got the highest numbers from the arrays but keep getting this error ----------- arrays should match.: expected [ [ 27 ], [ 5 ], [ 39 ], [ 1001 ] ] to deeply equal [ 27, 5, 39, 1001 ]
not sure i understand what it means by deep equal
Moisés Man
@moigithub
Sep 04 2015 00:41
1 isnot "1"
DJ
@qualitymanifest
Sep 04 2015 00:41
@hollowc2 your answer is an array of arrays, they just need one array containing all numbers
Dylan Barnett
@czeck6
Sep 04 2015 00:41
ahh. well it worked, but the instructions were a little confusing. Thanks dting
CamperBot
@camperbot
Sep 04 2015 00:41
if you want to thank someone, put an @ before their name!
Dylan Barnett
@czeck6
Sep 04 2015 00:42
@dting ahh. well it worked, but the instructions were a little confusing. Thanks
CamperBot
@camperbot
Sep 04 2015 00:42
czeck6 sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1002 | @dting | http://www.freecodecamp.com/dting
hollowc2
@hollowc2
Sep 04 2015 00:42
@qualitymanifest cool thanks for the response
CamperBot
@camperbot
Sep 04 2015 00:42
hollowc2 sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 175 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Christopher Hinojosa
@Draxell
Sep 04 2015 00:44
Hi everyone
Chris25602
@Chris25602
Sep 04 2015 00:44
hello everybody, tired eyes here what am I not seeing -> $(".well:nth-child(2)").addClass("animated bounce");
itsahoax
@itsahoax
Sep 04 2015 00:45
@Spatzerny thank you
CamperBot
@camperbot
Sep 04 2015 00:45
itsahoax sends brownie points to @spatzerny :sparkles: :thumbsup: :sparkles:
:star: 319 | @spatzerny | http://www.freecodecamp.com/spatzerny
Christopher Hinojosa
@Draxell
Sep 04 2015 00:46
is there anyone who can help me with the where art thou bonfire?
CamperBot
@camperbot
Sep 04 2015 00:46
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Christopher Hinojosa
@Draxell
Sep 04 2015 00:46
nvm thanks camperbot
CamperBot
@camperbot
Sep 04 2015 00:46
if you want to thank someone, put an @ before their name!
Chris25602
@Chris25602
Sep 04 2015 00:48
@Draxell ...I remember that one taking me some brainpower not sure if can help or not but ill try
Jakob Dahl
@saadanerdetbare
Sep 04 2015 00:48
This message was deleted
Jesse Rafael Dizon
@jesserafael
Sep 04 2015 00:48
function where(collection, source) {
  var arr = [];

  var sourceProp = Object.keys(source)[0];


  for( i = 0; i<collection.length; i++) {
   if (collection[i].hasOwnProperty(sourceProp) &&
     collection[i][sourceProp] == source[sourceProp]) {
     arr.push(collection[i]);
   }    
  }
  // What's in a name?
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
Hello, can anyone tell me what's wrong with my code? Thanks.
CamperBot
@camperbot
Sep 04 2015 00:48
if you want to thank someone, put an @ before their name!
@jesserafael you are only checking the first key
source can have multiple keys and each key value pair must be in the object in the collection for it to pass the filter
Chris25602
@Chris25602
Sep 04 2015 00:49
@sandeepanm @dting thanks
CamperBot
@camperbot
Sep 04 2015 00:49
chris25602 sends brownie points to @sandeepanm and @dting :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for sandeepanm
:star: 1003 | @dting | http://www.freecodecamp.com/dting
Chris25602
@Chris25602
Sep 04 2015 00:51
@jesseraphael look into 'collection.map' instead of a for loop
Danielle "Dani" Moss
@psykobilliethekid
Sep 04 2015 00:51
ok last one for tonight and then im going to do other stuff. this fulfills all but 3 of the criteria in the mutations bonfire. can anyone see what it is im missing? i'm thinking it's something simple but who knows at this point.
function mutation(arr) {
  var string01 = arr[0].toLowerCase();
  var string02 = arr[1].toLowerCase();

  for(i = 0; i < string01.length; i++){
    var compare = string01.indexOf(string02[i]);

    if (compare == -1){
      return false;
    }  
  } 
  return true;
}

mutation(['hello', 'hey']);
Sacha DeAngeli
@jazzhands
Sep 04 2015 00:53
does anyone know why this bit of jquery isn't working?
This message was deleted
CamperBot
@camperbot
Sep 04 2015 00:53
:bulb: to format code use backticks! ``` more info
Sacha DeAngeli
@jazzhands
Sep 04 2015 00:53
setTimeout(function(){$(".seconds:nth-child("+i+")").toggle()},6000);
DTing
@dting
Sep 04 2015 00:53
filter is probably what @jesserafael would want
@psykobilliethekid you are iterating string01
Moisés Man
@moigithub
Sep 04 2015 00:54
@psykobilliethekid the lengths are differents.. so
string01 length = 5 (hello)
and string02 length = hey
string02[5] === "hey"[5] <--
DTing
@dting
Sep 04 2015 00:54
you should be iterating string02 in your for loop
Danielle "Dani" Moss
@psykobilliethekid
Sep 04 2015 00:55
so should i have string02.length instead of string01.length? making sure we are looking at the same thing
Christopher Hinojosa
@Draxell
Sep 04 2015 00:55
thanks @jesserafael
CamperBot
@camperbot
Sep 04 2015 00:55
draxell sends brownie points to @jesserafael :sparkles: :thumbsup: :sparkles:
:star: 197 | @jesserafael | http://www.freecodecamp.com/jesserafael
Mauro Mazzucco
@mauromazzucco
Sep 04 2015 01:05
How do i set a Zipline undone? the site bugged and i sended the links from one project in another project
DTing
@dting
Sep 04 2015 01:08
@mauromazzucco i dont think you can but you can resubmit again with the right links
@psykobilliethekid ya
you want to iterate over string02 and check each character of string02 is in string01
Danielle "Dani" Moss
@psykobilliethekid
Sep 04 2015 01:09
@dting thank you! that worked! ^_^
CamperBot
@camperbot
Sep 04 2015 01:09
psykobilliethekid sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1004 | @dting | http://www.freecodecamp.com/dting
shawnparrotte
@shawnparrotte
Sep 04 2015 01:27
bf Where Art Thou
CamperBot
@camperbot
Sep 04 2015 01:27

:fire:Bonfire: Where art thou :link:

function where(collection, source) {
  var arr = [];
  // What's in a name?
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });

Make a function that looks through a list (first argument) and returns an array of all objects that have equivalent property values (second argument).

more info:  bf details | bf links | hint

Christopher Hinojosa
@Draxell
Sep 04 2015 01:28

function where(collection, source) {
var arr = [],
sourceKey = Object.keys(source)[0];
// What's in a name?
for(var i = 0; i < collection.length; i++){
var currObj = collection[i];
if(currObj.hasOwnProperty(sourceKey) === sourceKey){
arr.push(currObj);
}
}
return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });

that's what I got but it's not working
shawnparrotte
@shawnparrotte
Sep 04 2015 01:28
Is it not working for any case?
Christopher Hinojosa
@Draxell
Sep 04 2015 01:28
no
I had it working earlier for 1 key in source but I forgot what I had
and now nothing works
DTing
@dting
Sep 04 2015 01:30
@Draxell you still are only looking at the first element of Object.keys
You want
var sourceKeys = Object.keys(source);
Christopher Hinojosa
@Draxell
Sep 04 2015 01:30
yes, I've tried that but it still doesn't work
DTing
@dting
Sep 04 2015 01:30
and then for each element of collection check that each key in sourceKeys is in the there and the value matches
shawnparrotte
@shawnparrotte
Sep 04 2015 01:30
I was just about to say, .hasOwnProperty looks at just the name of the key... right?
Christopher Hinojosa
@Draxell
Sep 04 2015 01:31
yes
shawnparrotte
@shawnparrotte
Sep 04 2015 01:31
hey @dting I'm really confused about how .forEach works so I'm wondering if a double for-loop would do the same?
Christopher Hinojosa
@Draxell
Sep 04 2015 01:32
yes it would
DTing
@dting
Sep 04 2015 01:32
function where(collection, source) {
  var arr = [],
  //sourceKey = Object.keys(source)[0]; // use var. not global. get the array not the first element
  var sourceKeys = Object.keys(source);
  // What's in a name?
  for(var i = 0; i < collection.length; i++){
    var currObj = collection[i];
    if(currObj.hasOwnProperty(sourceKey) === sourceKey){ // check that every key in sourceKeys a property of currObj . and that the values match
      arr.push(currObj); // only push if all the keys and values are in the curObj
    }
  }
  return arr;
}
Christopher Hinojosa
@Draxell
Sep 04 2015 01:32
I was colaborating(sp) with a friend earlier who is more advanced than I am and he was using forEach
DTing
@dting
Sep 04 2015 01:32
forEach is basically a for loop writen differently
var a = [1,2,3];
a.forEach(function(v) {
  console.log(v);
});
// 1
// 2
// 3
var a = [1,2,3];
for (var i = 0; i < a.length; i++) {
  console.log(v);
}
// 1
// 2
// 3
shawnparrotte
@shawnparrotte
Sep 04 2015 01:34
what is this line doing: var sourceKeys = Object.keys(source);
Christina
@christhemoviegeek
Sep 04 2015 01:34
hiya! i am stuck on Waypoint: Target a Specific Child of an Element using jQuery. can anyone help?
shawnparrotte
@shawnparrotte
Sep 04 2015 01:35
rather, why would you make it a variable?
Christopher Hinojosa
@Draxell
Sep 04 2015 01:35
less to type
used multiple times
easier that way
shawnparrotte
@shawnparrotte
Sep 04 2015 01:35
and isn't source an array for some of the cases?
DTing
@dting
Sep 04 2015 01:35
no
they are all objects
shawnparrotte
@shawnparrotte
Sep 04 2015 01:35
really?
but collections is an array, no?
DTing
@dting
Sep 04 2015 01:36
collections are all arrays
sources are all objects
you are filtering the collections array for objects that contain all the key value pairs of the source object
collections are all arrays of objects
sources are all just objects
Christopher Hinojosa
@Draxell
Sep 04 2015 01:37
@dting you might want to go back and look at the bonfire again. it wants you to make a function that includes source as an array
DTing
@dting
Sep 04 2015 01:37
bf where
CamperBot
@camperbot
Sep 04 2015 01:37

:fire:Bonfire: Where art thou :link:

function where(collection, source) {
  var arr = [];
  // What's in a name?
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });

Make a function that looks through a list (first argument) and returns an array of all objects that have equivalent property values (second argument).

more info:  bf details | bf links | hint

DTing
@dting
Sep 04 2015 01:37
Make a function that looks through a list (first argument) and returns an array of all objects that have equivalent property values (second argument).
Christopher Hinojosa
@Draxell
Sep 04 2015 01:38
assert.deepEqual(where([{ 'a': 1, 'b': 2 }, { 'a': 1 }, { 'a': 1, 'b': 2, 'c': 2 }], { 'a': 1, 'b': 2 }), [{ 'a': 1, 'b': 2 }, { 'a': 1, 'b': 2, 'c': 2 }], 'should
[{ 'a': 1, 'b': 2 }, { 'a': 1, 'b': 2, 'c': 2 }]
is the source
DTing
@dting
Sep 04 2015 01:38
where([{ 'a': 1, 'b': 2 }, { 'a': 1 }, { 'a': 1, 'b': 2, 'c': 2 }], { 'a': 1, 'b': 2 })
this is the assertion
[{ 'a': 1, 'b': 2 }, { 'a': 1, 'b': 2, 'c': 2 }]
Christina
@christhemoviegeek
Sep 04 2015 01:38
@Chris25602 hiya! i am having the same problem.
DTing
@dting
Sep 04 2015 01:38
or the result
 { 'a': 1, 'b': 2 }
this is the source
[{ 'a': 1, 'b': 2 }, { 'a': 1 }, { 'a': 1, 'b': 2, 'c': 2 }]
this is the collection
shawnparrotte
@shawnparrotte
Sep 04 2015 01:39
And how were we supposed to know that? Poor design man.
DTing
@dting
Sep 04 2015 01:39

the test is that:

where([{ 'a': 1, 'b': 2 }, { 'a': 1 }, { 'a': 1, 'b': 2, 'c': 2 }], { 'a': 1, 'b': 2 })

will equal

[{ 'a': 1, 'b': 2 }, { 'a': 1, 'b': 2, 'c': 2 }]
Christopher Hinojosa
@Draxell
Sep 04 2015 01:39
I agree
it's very confusing
Christina
@christhemoviegeek
Sep 04 2015 01:40
@Chris25602 i keep getting the The second element in each of your well elements should bounce. error with this: $(".well:nth-child(2)").addClass("animated bounce");
DTing
@dting
Sep 04 2015 01:40
thats how all the tests are written
@christhemoviegeek you need a space between .well and :th-child
or you use
$(".target:nth-child(2)")
shawnparrotte
@shawnparrotte
Sep 04 2015 01:40
But I could sort of understand what it was after from the earlier ones. This is incomprehensible.
DTing
@dting
Sep 04 2015 01:41
assert is just a function. in this case they are calling it with 2 arguments
the first is your function: where
the second is the expected result
so find where your function call starts and stops
Christina
@christhemoviegeek
Sep 04 2015 01:41
@dting thank you so much!!! it's working now.
CamperBot
@camperbot
Sep 04 2015 01:41
christhemoviegeek sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1005 | @dting | http://www.freecodecamp.com/dting
DTing
@dting
Sep 04 2015 01:41
look for the comma
then the second argument after the comma is the expected result
Christopher Hinojosa
@Draxell
Sep 04 2015 01:42
their (i think it's called) whitespace is wrong
very confusing to see
takes a few minutes of looking at to understand
I see what you mean by look for the ,
but it shouldn't be this difficult to understand
samuel1290
@samuel1290
Sep 04 2015 01:43
i am coufus on number 6
DTing
@dting
Sep 04 2015 01:44
make an issue that says that the test cases and how they are structured should be explained maybe? it is pretty easy to spot after you understand tho.
Christopher Hinojosa
@Draxell
Sep 04 2015 01:44
AFTER yes but it took a while to get there lol
@samuel1290 number 6?
samuel1290
@samuel1290
Sep 04 2015 01:44
can some one help me
Jose M Viloria
@josevill
Sep 04 2015 01:44
bf Falsey Bouncer
CamperBot
@camperbot
Sep 04 2015 01:44

:fire:Bonfire: Falsey Bouncer :link:

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  return arr;
}

bouncer([7, 'ate', '', false, 9]);

Remove all falsey values from an array.

more info:  bf details | bf links | hint

Jose M Viloria
@josevill
Sep 04 2015 01:44
hint
CamperBot
@camperbot
Sep 04 2015 01:44
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Christopher Hinojosa
@Draxell
Sep 04 2015 01:45
oh that one was a pain in the ass
DTing
@dting
Sep 04 2015 01:45
@josevill that ones a trick question
its probably the shorted bonfire to solve
bf links
CamperBot
@camperbot
Sep 04 2015 01:45
Christopher Hinojosa
@Draxell
Sep 04 2015 01:46
I'm looking at mine right now and I don't understand what I did to make it pass
Jose M Viloria
@josevill
Sep 04 2015 01:46
If i'm trully honest..
Christopher Hinojosa
@Draxell
Sep 04 2015 01:46
look up .indexOf()
DTing
@dting
Sep 04 2015 01:47
you dont need indexOf for that one
Christopher Hinojosa
@Draxell
Sep 04 2015 01:47
?
I'm not going to post the whole code but
DTing
@dting
Sep 04 2015 01:47
i'll give you a hint.
arr.filter will evaluate the return value of the callback function for truthy or falsy
Christopher Hinojosa
@Draxell
Sep 04 2015 01:47
[false, null, 0, "", undefined].indexOf(value) < 0 && value === value;
DTing
@dting
Sep 04 2015 01:48
ya you dont need that
Christopher Hinojosa
@Draxell
Sep 04 2015 01:48
huh... okay
Jose M Viloria
@josevill
Sep 04 2015 01:48
The way they explain it @ MDN was very confusing..
I feel like i'm still missing so much to learn of the very basic JS :(
Christopher Hinojosa
@Draxell
Sep 04 2015 01:48
I feel the same way @josevill
Christopher Hinojosa
@Draxell
Sep 04 2015 01:48
I feel the docs are poorly written
shawnparrotte
@shawnparrotte
Sep 04 2015 01:49
I used Boolean() to make that one work
DTing
@dting
Sep 04 2015 01:49
filter will coerce the value returned by callback function.
Christopher Hinojosa
@Draxell
Sep 04 2015 01:49
brb
Robert Richey
@0x0936
Sep 04 2015 01:50
var arr  = [1, 2, 3];

arr.filter(function(el) { return el > 1; }); // returns a new array [2, 3]
DTing
@dting
Sep 04 2015 01:50
This message was deleted
This message was deleted
Jose M Viloria
@josevill
Sep 04 2015 01:52
I might finally start reading Eloquent JS
DTing
@dting
Sep 04 2015 01:53
thats a good book i've heard.
Jose M Viloria
@josevill
Sep 04 2015 01:54
It's the best free book out there afaik
Prashanth Chandra
@prashcr
Sep 04 2015 01:56
That and YDKJS
Christopher Hinojosa
@Draxell
Sep 04 2015 01:57
alright guys good luck I'm heading to bed, gotta stream in a few hours. gonna see if I can get some sleep before taht
that*
Jose M Viloria
@josevill
Sep 04 2015 01:57
@prashcr Thanks for the tip, i'll check that one out too
CamperBot
@camperbot
Sep 04 2015 01:57
josevill sends brownie points to @prashcr :sparkles: :thumbsup: :sparkles:
:star: 307 | @prashcr | http://www.freecodecamp.com/prashcr
Prashanth Chandra
@prashcr
Sep 04 2015 01:57
Be warned that eloquent has a really really steep curve
Jose M Viloria
@josevill
Sep 04 2015 01:58
@Draxell Aight man, good night :) Keep it up
@prashcr really? Hmm
shawnparrotte
@shawnparrotte
Sep 04 2015 02:02
ooooooh Object.keys returns an array.
that changes EVERYTHING
Jose M Viloria
@josevill
Sep 04 2015 02:02
Well, i'll still try it. We don't get easy access to phisical books about programming or something. So i'll have to use those :)
My code does what it's supposed to do
but it
but it's supposed to fulfill some chai.js deep equal thing that I don't know about
DTing
@dting
Sep 04 2015 02:04
what's your code look like now?
avatarhzh
@avatarhzh
Sep 04 2015 02:05
function largestOfFour(arr) {;
  var grtNum = 0;
    for (var i = 0; i < arr.length; i++) {
      for (j = 0; j < arr[i].length; j++) {
        if (arr[i][j] > grtNum) {
          grtNum = arr[i][j];
        }
      }
      arr[i] = grtNum;
    }
  return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
`
It works fine it's just the deep equal thing that's throwing me off
Jose M Viloria
@josevill
Sep 04 2015 02:06
You're returning arr
DTing
@dting
Sep 04 2015 02:07
hes mutating array
Jose M Viloria
@josevill
Sep 04 2015 02:07
Yes, i just saw it
mb
DTing
@dting
Sep 04 2015 02:07
your code works except you hafve grtNum defined in the wrong place
right now it keeps its value over the iterations
you need to move it some where so it is redefined for every sub array
theres also a better value than 0. if you set grtNum to 0 your code doesnt work with an array with all negative numbers. but to pass the tests you just need to move it somewhere
avatarhzh
@avatarhzh
Sep 04 2015 02:10
not quite sure what you mean @dting
do you mean it should be in the inner for loop?
DTing
@dting
Sep 04 2015 02:11
function largestOfFour(arr) {;
  var grtNum = 0;
    for (var i = 0; i < arr.length; i++) {
      console.log(grtNum);
      for (j = 0; j < arr[i].length; j++) {
        if (arr[i][j] > grtNum) {
          grtNum = arr[i][j];
        }
      }
      arr[i] = grtNum;
    }
  return arr;
}
Jose M Viloria
@josevill
Sep 04 2015 02:12
There's an extra semicolon at the end of the 1st line
avatarhzh
@avatarhzh
Sep 04 2015 02:12
I think I know what you mean
my code at the moment is only working because each later sub array has a greatest number higher than the previous sub array
cool got it working by setting grtNum to equal null after the first loop
cheers guys
kangyao
@kay78
Sep 04 2015 02:19
$($('.slot')[0]).html('<img src ="'+ images[slotOne-1] +'">');
what's the puporse of the '+ and +' in the code?
Matt Everson
@matteverson
Sep 04 2015 02:20
@kay78 concatenation to turn it all into a single string
@kay78 it will take the value in the images array at an index (which is found by subtracting one from the value in the slotOne variable) and use that as the src attribute in an img tag.
kangyao
@kay78
Sep 04 2015 02:24
i can understand images[slotOne-1]. but doesnt quite get the '+ +' , shall i ignore this part first? the tutorials doesnt mentioned anything about such usage
@matteverson thanks for helping
CamperBot
@camperbot
Sep 04 2015 02:25
kay78 sends brownie points to @matteverson :sparkles: :thumbsup: :sparkles:
:star: 359 | @matteverson | http://www.freecodecamp.com/matteverson
Farhad ali
@alifarhad
Sep 04 2015 02:27
can someone help me with regex here?
Matt Everson
@matteverson
Sep 04 2015 02:28
@alifarhad sure
Farhad ali
@alifarhad
Sep 04 2015 02:29
ok so I have a string "apple, app" . what would be the regex to get a match here for both since both the words have "app" in them @matteverson
again, i don't want to get a match if the string is "apple, ap" since not every char in the second word is present in the first word
Matt Everson
@matteverson
Sep 04 2015 02:30
Is this for a particular bonfire?
tesseractss
@tesseractss
Sep 04 2015 02:30
Hello All :] Can someone help me with a CSS border please?
Farhad ali
@alifarhad
Sep 04 2015 02:30
yeah mutation @matteverson
bonfire mutation
CamperBot
@camperbot
Sep 04 2015 02:30
Sorry, can't find a bonfire called mutation . [ Check the map? ]
Farhad ali
@alifarhad
Sep 04 2015 02:30
bonfire mutations
CamperBot
@camperbot
Sep 04 2015 02:30
Sorry, can't find a bonfire called mutatuions. [ Check the map? ]
Matt Everson
@matteverson
Sep 04 2015 02:31
bf mutations
CamperBot
@camperbot
Sep 04 2015 02:31

:fire:Bonfire: Mutations :link:

function mutation(arr) {
  return arr;
}

mutation(['hello', 'hey']);

Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.

more info:  bf details | bf links | hint

Farhad ali
@alifarhad
Sep 04 2015 02:31
you got it
I can't get it to work with "indexOf()" it fails two tests
so I thought let's do it with regex. then again I can't get the regex right
Matt Everson
@matteverson
Sep 04 2015 02:32
You actually want to check each letter, and since they don't have to be in the same order that's a tough regex to write
Farhad ali
@alifarhad
Sep 04 2015 02:32
:(
Matt Everson
@matteverson
Sep 04 2015 02:32
Are you sorting the letters first?
Farhad ali
@alifarhad
Sep 04 2015 02:32
nope
i have got this
function mutation(arr) {  
  var fE = arr[0].toLowerCase();
  var sE = arr[1].toLowerCase();

  for(var i = 0; i < fE.length; i++){
    var see = fE.indexOf(sE[i]);
    if (see === -1){
      return false;
    }
  }
  return true;
}

mutation(['hello', 'hey']);
but it fails two tests for some reasons
got this expect(mutation(['zyxwvutsrqponmlkjihgfedcba', 'qrstu'])).to.be.true;expected false to be true
Matt Everson
@matteverson
Sep 04 2015 02:33
that looks very close to my solution
ah, i see
Farhad ali
@alifarhad
Sep 04 2015 02:34
are you saying there's no way to do this in regex?
Matt Everson
@matteverson
Sep 04 2015 02:34
your for loop iterates over fE, so i changes. Then you access sE with i.
you should change the for loop to sE.length
Farhad ali
@alifarhad
Sep 04 2015 02:34
i can create a regex on the fly with new regex() based on the values in the arr but i don't know enough regex to actually get it right
that sounds like the solution let me try ti @matteverson
Matt Everson
@matteverson
Sep 04 2015 02:36
indexOf is much simpler for this
Farhad ali
@alifarhad
Sep 04 2015 02:36
changing fE to sE did the trick. thank you @matteverson
CamperBot
@camperbot
Sep 04 2015 02:36
alifarhad sends brownie points to @matteverson :sparkles: :thumbsup: :sparkles:
:star: 360 | @matteverson | http://www.freecodecamp.com/matteverson
Yan Kozlovskiy
@YanKozlovskiy
Sep 04 2015 02:42
why is this undefined? console.log(list.length[i]);
but when i use an index of the array i get the value of the index returned
Patrick McWilliams
@patrickmac110
Sep 04 2015 02:46
why is my #bottomspacer not showing up or moving down the number of px I'm telling it to?
http://codepen.io/patrcikmac110/pen/xwKXdm?editors=110
Matt Everson
@matteverson
Sep 04 2015 02:47
@YanKozlovskiy you wan list[i].length
@YanKozlovskiy list.length is an integer, the length of the array
Yan Kozlovskiy
@YanKozlovskiy
Sep 04 2015 02:49
@matteverson sorry i typed it wrong i'm getting this error at the end of my loop
TypeError: Cannot read property 'length' of undefined
David Galloso
@dgalloso
Sep 04 2015 02:49
Hello, i am trying to add two classes to an img element. One is for the border and the other one is for the width. The border was apply successfully but the image width is not changing still the same. Do you how to apply both border and width to the img element? i will appreciate any help
Yan Kozlovskiy
@YanKozlovskiy
Sep 04 2015 02:49
when i do console.log(list[i].length);
this is my code currently:

function test(str) {
    list = str.split(' ');
    longestItem = list[0];
    // count = ['hello', 'this', 'is', 'an array'];
//tring to figure out the return value below
    console.log("The count is: ");
    console.log(count.length);



    for (i = 0; i <= list.length; i++) {
        console.log(list[i].length);
    }
    // } if (longestItem > list.length[i])
}

test('one two three four five');
Matt Everson
@matteverson
Sep 04 2015 02:50
that only works if list contains lists
are you sure that error isn't because of count.length?
Yan Kozlovskiy
@YanKozlovskiy
Sep 04 2015 02:51
oh thank you
CamperBot
@camperbot
Sep 04 2015 02:51
if you want to thank someone, put an @ before their name!
Yan Kozlovskiy
@YanKozlovskiy
Sep 04 2015 02:51
thank you @matteverson
CamperBot
@camperbot
Sep 04 2015 02:51
yankozlovskiy sends brownie points to @matteverson :sparkles: :thumbsup: :sparkles:
:star: 362 | @matteverson | http://www.freecodecamp.com/matteverson
Yan Kozlovskiy
@YanKozlovskiy
Sep 04 2015 02:51
but why is the error being returned last?
Matt Everson
@matteverson
Sep 04 2015 02:54
<=
length is one more than the 0-based index
David Galloso
@dgalloso
Sep 04 2015 02:57
blob
this is my current code
is not using both classes is only applying the border class and not the width class
x34passenger
@x34passenger
Sep 04 2015 02:58
Bonfire: Mutations - how do you check for each letter against the other word?
CamperBot
@camperbot
Sep 04 2015 02:58
Sorry, can't find a bonfire called mutations - how do you check for each letter against the other word. [ Check the map? ]
Elaine Coe
@ElaineCoe
Sep 04 2015 02:58
@patrickmac110 try naming your div class "footer" instead of "foot". That moves it down so that it's only visible on the last page.
Patrick McWilliams
@patrickmac110
Sep 04 2015 03:01
@ElaineCoe my footer is as I like it, always shown on the page at the bottom
I'm trying to get my bottom spacer to be just that, a spacer that adds height at least temporarily so I can adequately scroll
Elaine Coe
@ElaineCoe
Sep 04 2015 03:02
@patrickmac110 ok. I just thought maybe that was why you were having trouble with it.
Patrick McWilliams
@patrickmac110
Sep 04 2015 03:03
I have this:
<div id='bottomspacer'></div>
and this:
#bottomspacer { position: relative; width: 100%; background: blue; top: 5000px; }
and they're seemingly not working together
Matt Everson
@matteverson
Sep 04 2015 03:07
@patrickmac110 try
.footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  /* Set the fixed height of the footer here */
  height: 60px;
}
Elaine Coe
@ElaineCoe
Sep 04 2015 03:08
@patrickmac110 does adding height to .footer help you get what you want? LOL.. @matteverson
Matt Everson
@matteverson
Sep 04 2015 03:09
position: relative places elements inside the flow of the document. For anything that floats or sticks you'll probably have to use position: absolute
x34passenger
@x34passenger
Sep 04 2015 03:09
Bonfire: Mutations - I don't know how to check for letters of one word in another word
CamperBot
@camperbot
Sep 04 2015 03:09
Sorry, can't find a bonfire called mutations - i dont know how to check for letters of one word in another word. [ Check the map? ]
Matt Everson
@matteverson
Sep 04 2015 03:09
@x34passenger check out Array.indexOf(). A string is an array.
x34passenger
@x34passenger
Sep 04 2015 03:10
@matteverson I did, doesn't seem helpful
Matt Everson
@matteverson
Sep 04 2015 03:12
If you use 'word'.indexOf('r') you'll get the index of 'r'. If 'r' wasn't in the string you'd get -1.
So it tells you whether a character is in the word
Patrick McWilliams
@patrickmac110
Sep 04 2015 03:14
@ElaineCoe @matteverson I'm not concerned with the footer, it's doing what I wish it to do, I just want a temporary spacer to create height on my page, that's why I have it set to 5,000px from the top
Matt Everson
@matteverson
Sep 04 2015 03:15
@patrickmac110 Why not create another div above your footer and set its height?
Patrick McWilliams
@patrickmac110
Sep 04 2015 03:16
nevermind, fixed it, had to use margin-top: 5000px;
instead of just top:
deaninous
@deaninous
Sep 04 2015 03:25
anyone could have a look at my code?
x34passenger
@x34passenger
Sep 04 2015 03:25
Bonfire: Mutations - I am having problems with lowering the case
function mutation(arr) {
  var firstElem = arr.indexOf(0);
  var secondElem = arr.indexOf(1);
  var result = false;

  var firstElemStr = firstElem.toString();
  var secondElemStr = secondElem.toString();

  firstElemStr = firstElemStr.toLowerCase();
  secondElemStr = secondElemStr.toLowerCase();

  for( var i = 0; i < firstElemStr; i++ )
  {
    if(secondElemStr.indexOf(i) != firstElemStr.indexOf(i))
    {
      result = false;
    }
    else
    {
      result = true;
    }
  }

  return result;
}

mutation(['hello', 'hey']);
CamperBot
@camperbot
Sep 04 2015 03:25
Sorry, can't find a bonfire called mutations - i am having problems with lowering the casefunction mutationarr var firstelem arrindexof0 var secondelem arrindexof1 var result false var firstelemstr firstelemtostring var secondelemstr secondelemtostring firstelemstr firstelemstrtolowercase secondelemstr secondelemstrtolowercase for var i 0 i firstelemstr i ifsecondelemstrindexofi firstelemstrindexofi result false else result true return resultmutationhello hey. [ Check the map? ]
Matt Everson
@matteverson
Sep 04 2015 03:27
@x34passenger That should be var firstElem = arr[0];
arr.indexOf(0) returns -1
x34passenger
@x34passenger
Sep 04 2015 03:36
Can't get the first and last test to pass:
function mutation(arr) {
  var firstElem = arr[0];
  var secondElem = arr[1];
  var result = false;

  firstElem = firstElem.toLowerCase();
  secondElem = secondElem.toLowerCase();

  for( var i = 0; i < firstElem.length; i++ )
  {
    if(secondElem.indexOf(i) != firstElem.indexOf(i))
    {
      result = false;
    }
    else
    {
      result = true;
    }
  }

  return result;
}

mutation(['hello', 'hey']);
Mateja Trifunovski
@Matko95
Sep 04 2015 03:37
Remove .indexOf(i) in your for loop
x34passenger
@x34passenger
Sep 04 2015 03:39
@Matko95 the all the other tests don't pass
Mateja Trifunovski
@Matko95
Sep 04 2015 03:39
.indexOf(i) will ask if the string contains numbers like 0,1,2,3,4
x34passenger
@x34passenger
Sep 04 2015 03:39
@Matko95 if I remove indexOf(i), then all the other tests don't pass
shawnparrotte
@shawnparrotte
Sep 04 2015 03:39
Why is my array giving me what's in index 1 when I called index 0????
Hans van Riet
@hansinla
Sep 04 2015 03:41
@shawnparrotte Show your code and we’ll take a look.
shawnparrotte
@shawnparrotte
Sep 04 2015 03:42
I was debugging my code and I couldn't find any errors then when I tried to manually return some of the variables I found that the index is screwed up...

function where(collection, source) {

 var arr = collection

 var boxKeys = Object.keys(source)


for (i = 0; i < boxKeys.length; i++){

    for (j = 0; j < collection.length; j++){

    if (source[boxKeys[i]] !== collection[j][boxKeys[i]]) {

      arr.splice(j,1);

            }          

        }  

    }  
  // testing the variable    
  return collection[0]

}
this is in the Where Art Thou bonfire
Mateja Trifunovski
@Matko95
Sep 04 2015 03:43
@x34passenger the idea is that you take your firstElem, split it using("") so you have a string of characters, and then ask if those characters belong to the other one
@x34passenger but in this manner test.indexOf(target[i]);
shawnparrotte
@shawnparrotte
Sep 04 2015 03:45
how or why would that change the index of the function array?
Matt Everson
@matteverson
Sep 04 2015 03:45
Because arr = collection
That's not a copy, they point to the same array
Hans van Riet
@hansinla
Sep 04 2015 03:46
Correct and splice mutates the array.
shawnparrotte
@shawnparrotte
Sep 04 2015 03:47
Okay, so how would I dump the contents of 'collection' into a variable that I can edit?
Matt Everson
@matteverson
Sep 04 2015 03:47
@shawnparrotte use var arr = collection.splice()
bah
.slice()
shawnparrotte
@shawnparrotte
Sep 04 2015 03:48
@matteverson would I put that in the if statement?
Matt Everson
@matteverson
Sep 04 2015 03:48
No, when you define var arr
shawnparrotte
@shawnparrotte
Sep 04 2015 03:50
I'm lost.
So why again is the index messed up?
Thomas Vaeth
@thomasvaeth
Sep 04 2015 03:53
Can anyone help with the Build a Random Quote zipline?
I'm stuck on the Twitter button.
Matt Everson
@matteverson
Sep 04 2015 03:53
@thomasvaeth try this: https://dev.twitter.com/web/intents
Thomas Vaeth
@thomasvaeth
Sep 04 2015 03:55
@matteverson Thanks. I'll read it and give it another shot.
CamperBot
@camperbot
Sep 04 2015 03:55
thomasvaeth sends brownie points to @matteverson :sparkles: :thumbsup: :sparkles:
:star: 365 | @matteverson | http://www.freecodecamp.com/matteverson
Hans van Riet
@hansinla
Sep 04 2015 03:55
@shawnparrotte It’s messed up because you only assign a reference to collection to arr. These names now point to the same array. In splice() you mutate this array (inside the nested for loops) which is a nono.
Lux3
@Lux3
Sep 04 2015 03:55
bf sum all
CamperBot
@camperbot
Sep 04 2015 03:55

:fire:Bonfire: Sum All Numbers in a Range :link:

function sumAll(arr) {
  return(1);
}

sumAll([1, 4]);

We'll pass you an array of two numbers. Return the sum of those two numbers and all numbers between them.

more info:  bf details | bf links | hint

Lux3
@Lux3
Sep 04 2015 03:55
hint
CamperBot
@camperbot
Sep 04 2015 03:55
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
shawnparrotte
@shawnparrotte
Sep 04 2015 03:57
So what do I do @hansinla if I want a new variable that I can mutate that contains the stuff in collection?
And is splice in bad in general?
Hans van Riet
@hansinla
Sep 04 2015 03:59
@shawnparrotte like @matteverson said: use var arr = collection.splice(); Now you have made a copy of collection and can safely modify arr. splice is NOT bad in general. Mutating an array that you refer to in the counter of the for looop is.
Matt Everson
@matteverson
Sep 04 2015 03:59
use .slice(0) to create a copy
splice() is fine, but you should know that variables that point to arrays and objects are not copied just because you assign them to another variable. You need what's called a "deep copy"
Hans van Riet
@hansinla
Sep 04 2015 04:01
@shawnparrotte Another way to handle this problem is to start with an empty array and push to it when you find a match instead of deleting items from a populated array.
shawnparrotte
@shawnparrotte
Sep 04 2015 04:01
and .slice(0) is a "deep copy"?
Matt Everson
@matteverson
Sep 04 2015 04:01
yes
The two variables are just like roadsigns pointing to the same place.
shawnparrotte
@shawnparrotte
Sep 04 2015 04:02
I couldn't figure out the logic for a positive case @hansinla so I thought a negative case would be better
Hans van Riet
@hansinla
Sep 04 2015 04:04
@matteverson I think the issue here is that FCC maybe should include some traditional CS lessons on pointers.
shawnparrotte
@shawnparrotte
Sep 04 2015 04:06
Alright so that fixed that problem thanks guys. I have new problems to deal with now, haha!
CamperBot
@camperbot
Sep 04 2015 04:06
if you want to thank someone, put an @ before their name!
Hans van Riet
@hansinla
Sep 04 2015 04:12
@shawnparrotte The first variable passed in is an array of Objects. So I would loop over that array. The inner loop should look at the keys in that object and check if the value for that key matches the value for that same key in the second variable passed into teh function. Hope that makes sense.
x34passenger
@x34passenger
Sep 04 2015 04:13
Bonfire: Falsey Bouncer - not sure if I am on the right track
function innerFilter(arr)
{
  for( var i = 0; i < arr.length i++ )
  {
    if(arr[i] == false) && (arr[i] == null) && (arr[i] == 0) && (arr[i] == "")
      (arr[i] == undefined) && (arr[i] == NaN)
    {
      arr.splice(i, 1);
    }
  }
  return arr;
}


function bouncer(arr) 
{
  // Don't show a false ID to this bouncer.
  return arr.filter(innerFilter);
}

bouncer([7, 'ate', '', false, 9]);
CamperBot
@camperbot
Sep 04 2015 04:13
Sorry, can't find a bonfire called falsey bouncer - not sure if i am on the right trackfunction innerfilterarr for var i 0 i arrlength i ifarri false arri null arri 0 arri arri undefined arri nan arrsplicei 1 return arrfunction bouncerarr dont show a false id to this bouncer return arrfilterinnerfilterbouncer7 ate false 9. [ Check the map? ]
Matt Everson
@matteverson
Sep 04 2015 04:14
@hansinla Indeed. @shawnparrotte For deeper reading on the subject, if you're interested: http://stackoverflow.com/questions/518000/is-javascript-a-pass-by-reference-or-pass-by-value-language
When stackoverflow is that long, you know it's complicated.
Hans van Riet
@hansinla
Sep 04 2015 04:16
@x34passenger You could do tha (althoug you should use OR ||)t, but a simpler way is th check if arr[i] == true and then push that value in a new array and return that array. That way you don’t have to test all those cases.
shawnparrotte
@shawnparrotte
Sep 04 2015 04:17
What gets me is how do you do the same thing (positive case we're talking about) when there are more than one object keys to check against (and where the number of keys is unknown)?
Hans van Riet
@hansinla
Sep 04 2015 04:19
@shawnparrotte You use:
for (var key in thisObject){
//do something
}
Thomas Vaeth
@thomasvaeth
Sep 04 2015 04:19
Okay. I got the Twitter button working on Random Quote Generator.
x34passenger
@x34passenger
Sep 04 2015 04:19
@hansinla I am getting a program execution failure
function innerFilter(arr)
{
  var arrTruthy = [];

  for( var i = 0; i < arr.length i++ )
  {
    if(arr[i] == true) 
    {
      arrTruthy.push(arr[i]);
    }
  }
  return arrTruthy;
}

function bouncer(arr) 
{
  // Don't show a false ID to this bouncer.
  return arr.filter(innerFilter);
}

bouncer([7, 'ate', '', false, 9]);
Matt Everson
@matteverson
Sep 04 2015 04:19
@thomasvaeth yay
Thomas Vaeth
@thomasvaeth
Sep 04 2015 04:19
But how do I change the a href of something using jQuery?
shawnparrotte
@shawnparrotte
Sep 04 2015 04:19
My thought was to loop over the first array with the keys in the second object and if there was a false then remove that object from the first array
Can you explain how that works @hansinla ?
Jose M Viloria
@josevill
Sep 04 2015 04:21
@thomasvaeth This one should help you out
shawnparrotte
@shawnparrotte
Sep 04 2015 04:21
The thing for...in loop?
Thomas Vaeth
@thomasvaeth
Sep 04 2015 04:22
@josevill I'm actually looking at it now. I need to take some time. Since I'm using jQuery to add new quotes I don't know how I am going to get that jQuery into the Twitter link.
Hans van Riet
@hansinla
Sep 04 2015 04:22
@x34passenger You can not return an array in the filter function, you return true or false.
Ben Hart
@Benjmhart
Sep 04 2015 04:23
anyone know how to get rid of vertical gaps between <div>s?
x34passenger
@x34passenger
Sep 04 2015 04:25
@hansinla I don't understand. If you return only true or false from the filter function, then how do you return the array with only the correct values?
Kenneth Black
@LawlietBlack
Sep 04 2015 04:26
@Benjmhart it's the top margin on the h1 that's causing that gap
Hans van Riet
@hansinla
Sep 04 2015 04:26
@x34passenger The filter function takes care of that for you. I advise to visit this link, because I have to give away the answer if I explain it more: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
Ben Hart
@Benjmhart
Sep 04 2015 04:26
@LawlietBlack thank you! that would have taken forever.
CamperBot
@camperbot
Sep 04 2015 04:26
benjmhart sends brownie points to @lawlietblack :sparkles: :thumbsup: :sparkles:
:star: 194 | @lawlietblack | http://www.freecodecamp.com/lawlietblack
Kenneth Black
@LawlietBlack
Sep 04 2015 04:27
@Benjmhart That one got me a lot in the beginning, too. Adding padding to the container will fix it too.
shawnparrotte
@shawnparrotte
Sep 04 2015 04:28
when you use .splice does it change the index of the thing you are splicing?
Ben Hart
@Benjmhart
Sep 04 2015 04:29
@LawlietBlack why would there be a whitespace at the bottom?
Kenneth Black
@LawlietBlack
Sep 04 2015 04:29
@Benjmhart same issue, this time it's the margin on your copyright p element
Jose E. Pimentel
@jedpimentel
Sep 04 2015 04:30
@shawnparrotte yes. An items index is it's relative distance from the first item
@shawnparrotte though, it might depend on you'r specific case, .splice can be used a lot of different ways
shawnparrotte
@shawnparrotte
Sep 04 2015 04:32
I want to iterate through an array and remove cases that aren't true
Hans van Riet
@hansinla
Sep 04 2015 04:32
@shawnparrotte Consider this:
var myArray = [10, 20, 30, 40, 50];

var newArray =  myArray.slice();
// myArray is stil the same
// newArray is deep copy of myArray
Kenneth Black
@LawlietBlack
Sep 04 2015 04:33
@shawnparrotte if you modify your iteration parameters mid-way, by removing items and changing length for example, it will affect your loop
Jose E. Pimentel
@jedpimentel
Sep 04 2015 04:33
yeah, the next items will have '-1' from their previous index
shawnparrotte
@shawnparrotte
Sep 04 2015 04:33
@LawlietBlack that's what I just realized.
@hansinla making tons of copies!
Kenneth Black
@LawlietBlack
Sep 04 2015 04:35
saving the parameter to a variable generally does the trick
one that you don't change in the loop, of course
Jose E. Pimentel
@jedpimentel
Sep 04 2015 04:36
you'd have to do some voodoo on the iterator, some people remove one from it (so it'll be the same value next loop)
shawnparrotte
@shawnparrotte
Sep 04 2015 04:36
@jedpimentel I just tried that, didn't work. Maybe there is some other bugs though.
Kenneth Black
@LawlietBlack
Sep 04 2015 04:37
just save the iterator to a static variable if you're using a for loop
Jose E. Pimentel
@jedpimentel
Sep 04 2015 04:38
I did something similar with a while loop,
var i = 0;
while(i < arr.length) {
    if(badentry) {
        arr.slice(i, 1);
    } else {
    i++;
    }
}
Kenneth Black
@LawlietBlack
Sep 04 2015 04:39
@jedpimentel ah, yeah, that would work, wouldn't it. I don't use while loops much lol
Jose E. Pimentel
@jedpimentel
Sep 04 2015 04:41
well... for(var i = 0; i < arr.length; ) should also do the trick
Kenneth Black
@LawlietBlack
Sep 04 2015 04:43
arr.length can change. that one's gotten me before. unless the omission of i++ is intentional, in which case, that only works if the function emptys the array
Farhad ali
@alifarhad
Sep 04 2015 04:43
guys i cant get past the last two challenges in bonfire: where art thou. here is my code. can someone help?
function where(collection, source) {  
  var keys = Object.keys(source);
  for (var name in source) {
    var gotName = source[name];
  }
  return collection.filter(function(item) {
    return item[keys] === gotName;
  });
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
Abhisek Pattnaik
@abhisekp
Sep 04 2015 04:43
bf thou
CamperBot
@camperbot
Sep 04 2015 04:43

:fire:Bonfire: Where art thou :link:

function where(collection, source) {
  var arr = [];
  // What's in a name?
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });

Make a function that looks through a list (first argument) and returns an array of all objects that have equivalent property values (second argument).

more info:  bf details | bf links | hint

Farhad ali
@alifarhad
Sep 04 2015 04:46
?-?
Abhisek Pattnaik
@abhisekp
Sep 04 2015 04:46
bf details
CamperBot
@camperbot
Sep 04 2015 04:46

:fire:Bonfire: Where art thou :link:

function where(collection, source) {
  var arr = [];
  // What's in a name?
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
Make a function that looks through a list (first argument) and returns an array of all objects that have equivalent property values (second argument).
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.
links:
Kenneth Black
@LawlietBlack
Sep 04 2015 04:46
@alifarhad I'm looking at it, you took a different approach than I did
Raj Vansia
@rajvansia
Sep 04 2015 04:47
can anyone review my code for dates friendly
Abhisek Pattnaik
@abhisekp
Sep 04 2015 04:47
@alifarhad read about the methods in the links :point_up: September 4, 2015 10:16 AM
This message was deleted
Jose E. Pimentel
@jedpimentel
Sep 04 2015 04:47
@LawlietBlack I did it on purpose. With my if/else either the array length decreases, or i increases, so eventually i = arr.length (though both will vary). It's basically the same as my previous while() loop, but with i declared inside the for,,
Kenneth Black
@LawlietBlack
Sep 04 2015 04:48
oh, so you increase the i inside the loop?
gotcha
I didn't put the two code snippets together
Farhad ali
@alifarhad
Sep 04 2015 04:50
im using for-in @LawlietBlack it takes care of the index itself
Kenneth Black
@LawlietBlack
Sep 04 2015 04:50
sorry @alifarhad , that was me responding to @jedpimentel on an earlier conversation
Farhad ali
@alifarhad
Sep 04 2015 04:50
the only use I can think of Object.hasOwnProperty() is if it's used in some kind of condition
its fine @LawlietBlack
Jose E. Pimentel
@jedpimentel
Sep 04 2015 04:53

apparently it's failing when there is more than one thing to filter

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { first: 'Tybalt', last: 'Capulet' });

is returning an empty array

Farhad ali
@alifarhad
Sep 04 2015 04:54
yep I have no idea how to account for an array instead of a string for the "source" argument
i can trick it may be
DTing
@dting
Sep 04 2015 04:55
@jedpimentel @alifarhad you dont want to trick it. Object.keys(source) will return all the keys for the key value pairs of the source object
then for each object in the collections array you need to check that every key is in the collections object and that each key the value matches the source
Farhad ali
@alifarhad
Sep 04 2015 04:56

it's using the key "last" for the first two tests so doing "

condition.filter(function(item) {
return item.last === source.last});

works too

Vikrant Negi
@vikrantnegi
Sep 04 2015 04:56
I need help in Bonfire: Find the Longest Word in a String:
My code gives right answer but still error. why??
function findLongestWord(str) {
  var string= str.split(" ");
  var longest=0;
  for(i=0; i<string.length; i++){
    if(longest<string[i].length){
      longest=string[i].length;
      word=string[i];
     }
  }
  return word;
}
findLongestWord('The quick brown fox jumped over the lazy dog');
CamperBot
@camperbot
Sep 04 2015 04:56
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Farhad ali
@alifarhad
Sep 04 2015 04:57
xD
Abhisek Pattnaik
@abhisekp
Sep 04 2015 04:57
about @dting
CamperBot
@camperbot
Sep 04 2015 04:57
:star: 1006 | @dting | http://www.freecodecamp.com/dting
Abhisek Pattnaik
@abhisekp
Sep 04 2015 04:57
yay! @dting :+1:
DTing
@dting
Sep 04 2015 04:58
conditions.filter(function(item) {
return item.last === source.last}); // change this too a loop over the elements of the Object.keys(source) return true only if the item has every key and the item's value for the keys matches the source's value for the key
yay me
Farhad ali
@alifarhad
Sep 04 2015 04:59
that was very insightful let me try @dting and thanks, yes
CamperBot
@camperbot
Sep 04 2015 04:59
alifarhad sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1007 | @dting | http://www.freecodecamp.com/dting
Jose E. Pimentel
@jedpimentel
Sep 04 2015 04:59
that's a lot of yellow stickers....
x34passenger
@x34passenger
Sep 04 2015 04:59
I don't know how to check for null
function innerFilter(obj)
{
  if(obj != true && obj == false && obj == '' )
  {
    return false;
  } 
  else
  {
    return true;
  }
}


function bouncer(arr) 
{
  // Don't show a false ID to this bouncer.
  return arr.filter(innerFilter);
}

//bouncer([7, 'ate', '', false, 9]);
bouncer([false, null, 0])
Jose E. Pimentel
@jedpimentel
Sep 04 2015 05:01
@vikrantnegi007 the function is supposed to return the length of the longest word (not the word itself)
DTing
@dting
Sep 04 2015 05:01
@x34passenger i'll give you a hint
you dont need to use any comparisons for your function
filter will evaluate your return value for truthy and falsy automatically
Vikrant Negi
@vikrantnegi
Sep 04 2015 05:02
@jedpimentel Thanks. Test passed. :)
CamperBot
@camperbot
Sep 04 2015 05:02
vikrantnegi007 sends brownie points to @jedpimentel :sparkles: :thumbsup: :sparkles:
:star: 277 | @jedpimentel | http://www.freecodecamp.com/jedpimentel
x34passenger
@x34passenger
Sep 04 2015 05:02
@dting can you be more specific, I have no idea what you are getting at
DTing
@dting
Sep 04 2015 05:02
any value you return from your callback function to filter will be evaluated for truthy or falsyness
also there is the built-in function Boolean that will take any value you call it with and return if it is truthy or falsy
x34passenger
@x34passenger
Sep 04 2015 05:05
@dting very sophisticated, thank you
CamperBot
@camperbot
Sep 04 2015 05:05
x34passenger sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1008 | @dting | http://www.freecodecamp.com/dting
marcusmatthias1
@marcusmatthias1
Sep 04 2015 05:09
@CruelCoin qq, if you don't mind. re. the Title Case Bonfire - can you please explain the need for this line? ```words[i] = newWord; ?? I realize it's necessary, but I don't understand why...
Ashraful Islam
@iashraful
Sep 04 2015 05:16
words[i] = newWord;
Geri Escandor
@geriesc
Sep 04 2015 05:23
Thank you @geekgal97 for helping me! :) Appreciate it.
CamperBot
@camperbot
Sep 04 2015 05:23
geriesc sends brownie points to @geekgal97 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for geekgal97
MD Arefin Saad
@arefinsaaad
Sep 04 2015 05:23
Basic Algorithm Scrpit - "Waypoint 4 "
actually i dont understand the question ......!!!
can anyone elaborate the question in short ???
Prashanth Chandra
@prashcr
Sep 04 2015 05:26
@arefinsaaad search and replace?
which exercise are you talking about?
Jose E. Pimentel
@jedpimentel
Sep 04 2015 05:26
@arefinsaaad you need to check if the string's letters are the same forwards and backwards (after removing the spaces)
for example, 'mom' spelled backwards is 'mom',
MD Arefin Saad
@arefinsaaad
Sep 04 2015 05:27
okeyyy...!!
let me try @jedpimentel :)
Ashraful Islam
@iashraful
Sep 04 2015 05:40
@arefinsaaad hello!
@arefinsaaad you are from uttara? :D
Derek Oyama
@Chills4Shiverin
Sep 04 2015 05:41
i try to size my image, it lets me, but if i try to put a class into the image, the image does not take the resize into effect
<style> img {width: 100px;} </style>
if i enter ".smaller-image" anywhere into the script the image resize will not take effect
MD Arefin Saad
@arefinsaaad
Sep 04 2015 05:44
i think i got the question ... and thnx man @jedpimentel
CamperBot
@camperbot
Sep 04 2015 05:44
arefinsaaad sends brownie points to @jedpimentel :sparkles: :thumbsup: :sparkles:
:star: 279 | @jedpimentel | http://www.freecodecamp.com/jedpimentel
Ashraful Islam
@iashraful
Sep 04 2015 05:44
@Chills4Shiverin to do that you should apply the width in the class like this
<style>
.smaller-image { width: 100px; }
</style>
MD Arefin Saad
@arefinsaaad
Sep 04 2015 05:45
yaap @iashraful
Ashraful Islam
@iashraful
Sep 04 2015 05:46
@arefinsaaad am fairly close to you :D
MD Arefin Saad
@arefinsaaad
Sep 04 2015 05:46
our tht's great ....!!! @iashraful
Ashraful Islam
@iashraful
Sep 04 2015 05:46
@arefinsaaad which challenge/bonfire/zipline are you doing?
MD Arefin Saad
@arefinsaaad
Sep 04 2015 05:47
i'm working bonfire now .. @iashraful
Ashraful Islam
@iashraful
Sep 04 2015 05:47
wow!
MD Arefin Saad
@arefinsaaad
Sep 04 2015 05:47
u ? @iashraful
Ashraful Islam
@iashraful
Sep 04 2015 05:48
starting basejump: voting app
MD Arefin Saad
@arefinsaaad
Sep 04 2015 05:49
great ..!!
u almost finished ...!!! (y)
Fidel Severino
@fidelscodes
Sep 04 2015 05:51
Hello everyone. Just came back to FCC after a short break and I'm going through the new stuff. I seem to have forgotten a lot so I'm refreshing as well
Ashraful Islam
@iashraful
Sep 04 2015 05:51
nope, basejump takes time :D
@fidelscodes yep, lots of new stuff
@arefinsaaad if you need help let me know :)
MD Arefin Saad
@arefinsaaad
Sep 04 2015 05:52
go ahead .... n best of luck
sure .... i'll !!!!
Fidel Severino
@fidelscodes
Sep 04 2015 05:53
I'm on this waypoint "Create a JS Slot Machine" and I fail to understand why we need to use Math.floor(Math.random() * (3 - 1 + 1)) + 1; to create a random number beweeen 1-3
why can't we just use
Math.floor(Math.random() * 3) +1)
Ashraful Islam
@iashraful
Sep 04 2015 05:54
@fidelscodes it's just to make sure you understand what we are doing
x34passenger
@x34passenger
Sep 04 2015 05:54
Bonfire: Where art thou - I am not exactly sure how the Object comes into play with the 2 arrays?
CamperBot
@camperbot
Sep 04 2015 05:54
Sorry, can't find a bonfire called where art thou - i am not exactly sure how the object comes into play with the 2 arrays. [ Check the map? ]
Ashraful Islam
@iashraful
Sep 04 2015 05:54
@fidelscodes it means Math.floor(Math.random() * (max - min + 1)) + 1
DTing
@dting
Sep 04 2015 05:55
@x34passenger whats your code look like now?
Fidel Severino
@fidelscodes
Sep 04 2015 05:56
I understand that. Just seems more complicated than Math.floor(Math.random() * 3) + 1
Ashraful Islam
@iashraful
Sep 04 2015 06:01
@fidelscodes just a reminder what you are doing :)
x34passenger
@x34passenger
Sep 04 2015 06:04
@dting I don't know how to write the code yet
DTing
@dting
Sep 04 2015 06:05
@x34passenger the second argument isnt an array. it's an object
x34passenger
@x34passenger
Sep 04 2015 06:05
@dting Do I convert each element of the array into Objects?
DTing
@dting
Sep 04 2015 06:05
collections is an array of objects to filter
souce is an object with the key value pairs you need to filter the collections array with
Fidel Severino
@fidelscodes
Sep 04 2015 06:05
Alright. Thanks @iashraful
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:13
can anyone explain how this line of code works
unction mutation(arr) {
  var test = arr[1].toLowerCase();
  var target = arr[0].toLowerCase();
  test = test.split('');
  target = target.split('');
  for (i=0;i<test.length;i++) {
    if (target.indexOf(test[i]) < 0) // <--- walk me through how this works
      return false;
  }
  return true;
 }
if test[i] is not found in the target array it will return -1
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:15
yeah i tried reading what indexOf actually does but its still kinda confusing
DTing
@dting
Sep 04 2015 06:15
if it returns -1 then that means it is not in the target array.
-1 is less than 0
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:16
it basically means its finding the place where its located
DTing
@dting
Sep 04 2015 06:16
so then the function returns false. b/c test[i] is not in target
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:16
im trying to cycle through it though like what the code looks like.. so say my function is this
DTing
@dting
Sep 04 2015 06:16
which is what you want to return if any element of test is not in target
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:16
mutation([alien, line])
the loop starts at l in line..
so then it goes into the if statement
if (target.indexOf(test[0]) < 0)
test 0 would be l
so its target.indexOf.. so it finds at which index that l is in alien correct?
which would be index 2 which is not less than 0 so it would return true?
DTing
@dting
Sep 04 2015 06:19
no
it doesnt return true until after the for loop
Fidel Severino
@fidelscodes
Sep 04 2015 06:20
target.indexOf(test[0]) < 0) is looping through each character of the first element in the array
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:20
oh okay.. so it keeps going through the loop
so the for loop is looping through the test variable.. while the target.index is cycling through the target variable
so back to my example of alien and line..
im using line in my for loop and alien in my if statment
Fidel Severino
@fidelscodes
Sep 04 2015 06:23
right
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:24
so lets say my for loop is at index 0.. the l..
DTing
@dting
Sep 04 2015 06:24
  for (var i=0;i<test.length;i++) {
    var found = false;
    for (var j = 0; j < target.length; j++) {
      if (target[j] === test[i]) {
        found = true;
        break;
      }
    }
    if (!found) return false;
  }
  return true;
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:24
the if statment finds the l?
DTing
@dting
Sep 04 2015 06:24
that loop can also be written like so
indexOf just can reduce all that into a single like
Fidel Severino
@fidelscodes
Sep 04 2015 06:24
^
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:26
bah im still confused lol.. i remember doing that but dont remember how it works
the first for loop stays at 0
Fidel Severino
@fidelscodes
Sep 04 2015 06:27
run through the code in steps so you can better understand what it's doing. On the first run of the for loop, you're looking at 'l'. Then the if statement kicks in target.indexOf() loops through each character in target to check whether it is a match to that 'l' or not. If it's not, it will return -1 which means it's a false
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:27
while the second for loop starts at 0 and cycles through until the end of target.length
then the first for loop goes up by 1 and start the process over again?
Fidel Severino
@fidelscodes
Sep 04 2015 06:28
after that it will moe onto 'i' and repeat the same processs of looping through target (using target.indexOf() looking for a match with 'i'
so on
DTing
@dting
Sep 04 2015 06:28
@Dueldrawer8 ya
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:29
okay makes more sense.. just need it to marinade and look at it again
thanks @dting and @fidelscodes
CamperBot
@camperbot
Sep 04 2015 06:29
dueldrawer8 sends brownie points to @dting and @fidelscodes :sparkles: :thumbsup: :sparkles:
:star: 290 | @fidelscodes | http://www.freecodecamp.com/fidelscodes
:star: 1015 | @dting | http://www.freecodecamp.com/dting
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:29
let it marinade
Fidel Severino
@fidelscodes
Sep 04 2015 06:31
You're welcome
DTing
@dting
Sep 04 2015 06:31
hah nps ya thats an important thing to know very well. how to walk though loops and follow values
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:32
hmm..
oh im retarded..
i was thinking..
if (target.indexOf(test[i]) < 0) // means
if(target.indexOf(test[0])<0 // which simplies to..
if(target.indexOf(l)<0
so its searching the target index for l.. which in alien its index 1
which 1 is less than 0.. so im confused as to what it does after that?
if 1 < 0.. it should return false
wait
1 is not less than 0.. so its false.. lol
DTing
@dting
Sep 04 2015 06:40
1 is not less than 0 so the condtional is false
if the conditional is false. it doesn't return false
so it just continues the loop
if target.indexOf(...) is -1, then -1 is < 0, the conditional is true. at that point the function would return false.
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:41
ah
yeah i was looking at it closely and it clicked.. i just could not have come up with that myself
DTing
@dting
Sep 04 2015 06:43
thats why i always suggest the imperative code
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:43
dont think ill ever get the hang of this programming stuff
DTing
@dting
Sep 04 2015 06:43
the functional stuff is a bit more abstract
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:44
imperative code meaning what u gave me an example of earlier?
DTing
@dting
Sep 04 2015 06:44
useful but when learning 2 nested for loops should be easier to follow
yea
Mbos95
@Mbos95
Sep 04 2015 06:47
function comparator(input){
  if(input[0] > input[1]) {
    largest.push(input[0]) 
    return largest;
  }

}
  var largest = [];

largestOfFour([[6, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Can someone tell me why this doesn't save things in the variable largest ?
If I run the code it keeps saying 'undefined'
DTing
@dting
Sep 04 2015 06:48
you dont have a function named largestOfFour
that's what the test calls to test your code
Mbos95
@Mbos95
Sep 04 2015 06:49
function comparator(input){
  if(input[0] > input[1]) {
    largest.push(input[0]) 
    return largest;
  }

}
  var largest = [];

comparator(largestOfFour[1]);

var largestOfFour = [[6, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]];
now it says it can't read 1 of property :(
property 1 of undefined, sorry
sorry for bothering you again Dting xD
I know I am not really fun to help
DTing
@dting
Sep 04 2015 06:52
your function needs to be named largestOfFour
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:53
I believe largestOfFour is suppose to be your function
DTing
@dting
Sep 04 2015 06:53
right now you have largestOfFour equal to an array
Mbos95
@Mbos95
Sep 04 2015 06:53
largestOfFour = [[6, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]];
like this ?
function largestOfFour(arr) {
    for(i = 0; i < arr.length - 12; i++){
      arr[i]

    }

  return arr;
}


largestOfFour = [[6, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]];
DTing
@dting
Sep 04 2015 06:55
function largestOfFour(arr) {
// your code here
}
largestOfFour([[6, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:55
yes but you also need parenthesis around your array at the bottom because you are calling a function
so ^^
Mbos95
@Mbos95
Sep 04 2015 06:55
yea, sorry It was like that in the beginning but I want it to be an array so I deleted stuff from it.
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:56
largestOfFour (arr).. is equal to largestOfFour([[...], [..]]);
Mbos95
@Mbos95
Sep 04 2015 06:56
Why would it need to be an function instead of an variable holding information ?
hmmm oke
But yea, I can iterate through stuff and and I can check if something is bigger and do something..
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 06:57
you have a variable holding the largest of each number in the first piece of code you wrote i believe

function comparator(input){
if(input[0] > input1) {
largest.push(input[0])
return largest;
}

}
var largest = []; // <=== is making an empty array that holds the number from your push method

largestOfFour([[6, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

function comparator(input){
  if(input[0] > input[1]) {
    largest.push(input[0]) 
    return largest;
  }

}
  var largest = []; // <--- is creating a new array and pushing the largest numbers into it from your 
                                  // push method


largestOfFour([[6, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Mbos95
@Mbos95
Sep 04 2015 06:59
You think I did that good ? would input[0] and input[1] work like this ? (if I were to inject largestOfFour[0] for example
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:00
@dting could you answer that?
Mbos95
@Mbos95
Sep 04 2015 07:00
I am really not sure how to get the information out of that function! If i return largestOfFour[1] for example it is just undfined
DTing
@dting
Sep 04 2015 07:02
hmm i'm not sure where to start
let me think
Mbos95
@Mbos95
Sep 04 2015 07:02
is the thing complicated or am I complicated ? :D
DTing
@dting
Sep 04 2015 07:03
lets start with how these challenges work
when you start there is some code there
a function declaration with missing code
bf largest
CamperBot
@camperbot
Sep 04 2015 07:03

:fire:Bonfire: Return Largest Numbers in Arrays :link:

function largestOfFour(arr) {
  // You can do this!
  return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays.

more info:  bf details | bf links | hint

DTing
@dting
Sep 04 2015 07:03
function largestOfFour(arr) {
  // Your code should all go in here
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
that is an example of calling the function you are writing with an example test case
to finish the challenge, you need to pass all the test cases on the left. how these test cases are run is it will call the function that you wrote
function largestOfFour(arr) { // <-- this function is called by the test
  // Your code should all go in here
}
it checks that when calling that function the result returned is equal to the expected results.
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:05
i think he is also asking if his code is right
Mbos95
@Mbos95
Sep 04 2015 07:06
yea but it helps, this explanation
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:06
which your definatley going to need a for loo[
*loop
Mbos95
@Mbos95
Sep 04 2015 07:06
Like, I get how it works and everything but some little details weren't clear to me. :)
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:06
oh ok
Mbos95
@Mbos95
Sep 04 2015 07:07
Dting is good at explaning :) although I have the feeling I piss him off with my stupidity sometimes xD
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:07
nah, im sure he is glad to help. I feel the same way.. if i know something i want to explain it to someone because it also helps me
CAS0609
@CAS0609
Sep 04 2015 07:08
Hi there guys
im stucked in something
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:08
because i struggled through it also and want to clarify it to someone else and make that lightbulb go off like it did for me
CAS0609
@CAS0609
Sep 04 2015 07:08
who can help me?
pleasee!
:)
Mbos95
@Mbos95
Sep 04 2015 07:08
So this is how the assignments work. And @Dueldrawer8 mentioned I would definetly need a for loop. I can iterate through everything but how can I function this to a certain sub array? for I need to check for the largest number in all the sub arrays 1 at a time
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:09
dting is the best person to ask @CAS0609 bc i can't guarantee im best person to ask at the moment
Mbos95
@Mbos95
Sep 04 2015 07:09
thank you @Dueldrawer8 Sharing knowledge is amazing. also @dting thank you for your explanation :)
CamperBot
@camperbot
Sep 04 2015 07:09
mbos95 sends brownie points to @dueldrawer8 and @dting :sparkles: :thumbsup: :sparkles:
:star: 175 | @dueldrawer8 | http://www.freecodecamp.com/dueldrawer8
:star: 1017 | @dting | http://www.freecodecamp.com/dting
CAS0609
@CAS0609
Sep 04 2015 07:09
im stucked in this thing
DTing
@dting
Sep 04 2015 07:10
hmm maybe that wont help let me see
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:10
heh
CAS0609
@CAS0609
Sep 04 2015 07:10
blob
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:10

Explanation:
You will get an array that contains sub arrays of numbers and you need to return an array with the largest number from each of the sub arrays.

Hint: 1

You will need to keep track of the array with the answer and the largest number of each sub-array.

Hint: 2

You can work with multidimensional arrays by Array[Index][SubIndex]

Hint: 3

Pay close attention to the timing of the storing of variables when working with loops

thats from the wiki..
Mbos95
@Mbos95
Sep 04 2015 07:11
@dting Well, the thing is that if I return largestOfFour1 (accesing the element) It gives me undefined because it is an function, I thought
Ah :D oke Iĺl read through this stuff. thanks guys! I'll go mess around a bit more and see if I can get it working now.
CamperBot
@camperbot
Sep 04 2015 07:11
if you want to thank someone, put an @ before their name!
DTing
@dting
Sep 04 2015 07:11
you dont return largestOfFour
Mbos95
@Mbos95
Sep 04 2015 07:11
return arr!
yes sorry xD
Youi explained 2 days back .. sorry sorry
CAS0609
@CAS0609
Sep 04 2015 07:12
I get the reversed word hello but the red dot are still there
DTing
@dting
Sep 04 2015 07:12
you call largestOfFour inside largestOfFour you can declare whatever variables you need and return that
@CAS0609 your code needs to go inside the function
Mbos95
@Mbos95
Sep 04 2015 07:12
as soon as it entered, that array in the function largestOfFour becomes arr ,right? :) That's how it works.
DTing
@dting
Sep 04 2015 07:12
i just explained it earlier
that might help you out
CAS0609
@CAS0609
Sep 04 2015 07:13
jikes
im noob
Mbos95
@Mbos95
Sep 04 2015 07:13
don't worry. we're all in the same boat @CAS0609
thank you @dting @dting @Dueldrawer8 @dting @Dueldrawer8 @Dueldrawer8
CamperBot
@camperbot
Sep 04 2015 07:13
mbos95 sends brownie points to @dting and @dting and @dueldrawer8 and @dting and @dueldrawer8 and @dueldrawer8 :sparkles: :thumbsup: :sparkles:
:warning: mbos95 already gave dting points
:warning: mbos95 already gave dueldrawer8 points
:warning: mbos95 already gave dting points
:warning: mbos95 already gave dueldrawer8 points
:warning: mbos95 already gave dting points
:warning: mbos95 already gave dueldrawer8 points
Mbos95
@Mbos95
Sep 04 2015 07:13
hehe
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:13
yeah im a total nood also
noob
DTing
@dting
Sep 04 2015 07:14
@Mbos95 ya you can access the array that largestOfFour is called with inside the function as arr
CAS0609
@CAS0609
Sep 04 2015 07:14
it is still not workin though
:(
x34passenger
@x34passenger
Sep 04 2015 07:15
Bonfire: Where art thou - I am not getting it, please help:
function lookThroughArr(arrOne, objectMatch)
{
  arrOne.forEach(element)
  {
    if( objectMatch == arrOne(element))
    {
      return objectMatch
    }
  }
}

function where(collection, source) {
  var arr = [];
  // What's in a name?
  arr.push(lookThroughArr(collection, source));
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
CamperBot
@camperbot
Sep 04 2015 07:15
Sorry, can't find a bonfire called where art thou - i am not getting it please helpfunction lookthrougharrarrone objectmatch arroneforeachelement if objectmatch arroneelement return objectmatch function wherecollection source var arr whats in a name arrpushlookthrougharrcollection source return arrwhere first romeo last montague first mercutio last null first tybalt last capulet last capulet . [ Check the map? ]
DTing
@dting
Sep 04 2015 07:16
@x34passenger forEach doesnt do anything with a return value
it just ignores it
also your lookThroughArr doesnt return anything
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:18
@CAS0609 split("") seperates the string by the letter characters while split(" ") with a space seperates the string by words
DTing
@dting
Sep 04 2015 07:18
so your code would just return [undefined] everytime
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:19
so since its only a word you are taking a apart and reversing.. only the split('') with no space is needed
x34passenger
@x34passenger
Sep 04 2015 07:20
@dting
I changed the code but I'm still not getting it:
function lookThroughArr(arrOne, objectMatch)
{
  arrOne.forEach(element)
  {
    if( objectMatch == arrOne(element))
    {
      objectMatch = arrOne(element);
    }
  }
  return objectMatch;
}

function where(collection, source) {
  var arr = [];
  // What's in a name?
  arr.push(lookThroughArr(collection, source));
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:20
each method of split, reverse, and join is only required once..
DTing
@dting
Sep 04 2015 07:21
now you return objectMatch everytime
i think you should go back to using imperative for loops
function where(collection, source) {
  var result = [];
  for (var i = 0; i < collection.length; i++) {
    // some code goes here
    // add collection[i] to result if what?
  }
  return result;
}
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:21
.split("").reverse().join(""); // should do the trick
CAS0609
@CAS0609
Sep 04 2015 07:22
@Dueldrawer8 let me check
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:23
@CAS0609 you can even console.log the results to see what you get in a web brower's console
CAS0609
@CAS0609
Sep 04 2015 07:23
i dont undestand console.log use yet
:s
i have too many doubts on JS
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:24
ah gotcha.. basically when you use that it will print or output back to the console what that line of code is doing or bascially acting on
yeah JS is hard.. i started with python and didnt finish it but i love python so much more
CAS0609
@CAS0609
Sep 04 2015 07:25
:)
it says
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:25
i just figured the best way to learn code is by creating something so making a webpage is the best way to do it for me
CAS0609
@CAS0609
Sep 04 2015 07:25
expected 'hello' to equal 'olleh'
how the hell i can get that
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:26
whats your code look like?
CAS0609
@CAS0609
Sep 04 2015 07:26
wait
blob
DTing
@dting
Sep 04 2015 07:26
function lookThroughArr(arrOne, objectMatch)
{
  arrOne.forEach(element) 
  {
    if( objectMatch == arrOne(element)) // arrOne is an array, you cant call an array using "(...)"
    {
      objectMatch = arrOne(element); // same as above
    }
  }
  return objectMatch; // this never gets reached because of the above errors
}

function where(collection, source) {
  var arr = [];
  // this will only ever add one value to arr. 
  arr.push(lookThroughArr(collection, source)); 
  return arr;
}
CAS0609
@CAS0609
Sep 04 2015 07:26
there it is
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:28
@CAS0609
CAS0609
@CAS0609
Sep 04 2015 07:28
aye
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:28
function reverseString(str) {
  // Your code goes here...

  return str;
}

reverseString('hello'); /* leave this here as its part of the excercise
                        that will determind if your code is right /*
CAS0609
@CAS0609
Sep 04 2015 07:29
oh shht
wait
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:30
so you need to move your split/reverse/join to where it says your code goes here
Costas Chaitas
@CostasChaitas
Sep 04 2015 07:30
can anybody explain a bit this to me?
function diff(arr1, arr2) {
// Danger Will Robinson, Danger!!
return R.concat(R.difference(arr1,arr2),R.difference(arr2,arr1));
}
its for the diff two arrays bonfire
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:31
@CAS0609 your function is reverseString correct? that takes in a string.. like so : reverseString(str)
Costas Chaitas
@CostasChaitas
Sep 04 2015 07:31
why i cant find the difference metho?
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:31
so lets start from scratch
DTing
@dting
Sep 04 2015 07:31
@rasakos what is R?
CAS0609
@CAS0609
Sep 04 2015 07:31
@Dueldrawer8 im trying to correct it
Costas Chaitas
@CostasChaitas
Sep 04 2015 07:32
a random arr
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:33
@CAS0609 You also don't need those extra declared variables as the excercise already has some strings pre programmed into it
CAS0609
@CAS0609
Sep 04 2015 07:33
so?

function reverseString(str) {
return str;

var reverseString= "hello";
var segundoReves="Howdy";
var tercerReves="Greetings from earth";

reverseString.split("").reverse().join("");
segundoReves.split("").reverse().join("");
tercerReves.split("").reverse().join("");

}
reverseString('hello');

Costas Chaitas
@CostasChaitas
Sep 04 2015 07:34
@dting can you understand it ?is there any method difference?
CAS0609
@CAS0609
Sep 04 2015 07:35
Bold geez
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:35
@CAS0609 you have the right idea with the methods but the point of making functions is to simplify it so you don't have to repeat things such as creating a new variable each time and then using those methods mutiple times
wouldnt it be easier to do this..
CAS0609
@CAS0609
Sep 04 2015 07:35
so, what should i do?
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:36
function reverseString(str) {
  str.split('').reverse().join('');

  return str;
}

reverseString('hello');
@CAS0609 that way no matter what str you put into the function.. it will execute the split/reverse/join for all strings you put inside the functino
so if you were to call the function.. reverseString.. with the string hello.. it would look like the last line in the code ive typed
and it would then execute those methods
CAS0609
@CAS0609
Sep 04 2015 07:38
@Dueldrawer8 aint working
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:38
@CAS0609 but i didnt finish the code
Bastien Lemaire
@blemaire
Sep 04 2015 07:38
function reverseString(str) {
  return str.split('').reverse().join('');
}
CAS0609
@CAS0609
Sep 04 2015 07:39
@blemaire geez thanks maan
CamperBot
@camperbot
Sep 04 2015 07:39
cas0609 sends brownie points to @blemaire :sparkles: :thumbsup: :sparkles:
:star: 18 | @blemaire | http://www.freecodecamp.com/blemaire
CAS0609
@CAS0609
Sep 04 2015 07:39
@Dueldrawer8 Thanks mate
Bastien Lemaire
@blemaire
Sep 04 2015 07:39
@CAS0609 no worries
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:40
welcome
CAS0609
@CAS0609
Sep 04 2015 07:40
@Dueldrawer8 @blemaire
im still having problems to understand JS, thanks for your help
CamperBot
@camperbot
Sep 04 2015 07:41
if you want to thank someone, put an @ before their name!
DTing
@dting
Sep 04 2015 07:47
@rasakos what's the entire code? that cant be it or it wouldn't run
Xavier Hanrot
@xhanrot
Sep 04 2015 07:52
hi
I've got a problem with Basic Javascript waypoint #20
Bastien Lemaire
@blemaire
Sep 04 2015 07:53
hey. what's the exercice?
got it, what have you got so far?
Xavier Hanrot
@xhanrot
Sep 04 2015 07:54
here is my code
var myArray = ["John", 23, ["cat", 2]];
// Only change code below this line.
var rem = myArray.pop();
var removed = myArray; // This should be ["cat", 2] and myArray should now be ["John", 23]
removed[0] = rem[0];
removed[1] = rem[1];
CAS0609
@CAS0609
Sep 04 2015 07:54
var
Xavier Hanrot
@xhanrot
Sep 04 2015 07:55
when I modify "removed", the array "myArray" is modified the same way. why ?
operator= doesn't make a copy of its right operand ?
CAS0609
@CAS0609
Sep 04 2015 07:56
var  JUSTtesting
DTing
@dting
Sep 04 2015 07:57
@xhanrot
var removed = myArray;
this line does not copy myArray
Bastien Lemaire
@blemaire
Sep 04 2015 07:57
you need to store the removed content in a var called removed
var removed = myArray.pop();
DTing
@dting
Sep 04 2015 07:57
it simply says removed also points to the same memory location that myArray points to. they both point to the same array object in memory
now modifying either one will change the array in that memory location and accessing either variable will reflect the changes
Xavier Hanrot
@xhanrot
Sep 04 2015 07:58
@dting : ok, so I have to clone myArray ?
DTing
@dting
Sep 04 2015 07:58
you can make a shallow copy using .slice()
Bastien Lemaire
@blemaire
Sep 04 2015 07:58
there's no need, just store the extracted content in the removed var...
DTing
@dting
Sep 04 2015 07:59
i dont think hes asking about the problem hes asking about why his code is acting the way it is
Xavier Hanrot
@xhanrot
Sep 04 2015 07:59
@blemaire, that's what I'm doing ("var rem = myArray.pop()")
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 07:59
where can i find how this works.. for( x in something..)
DTing
@dting
Sep 04 2015 07:59
that sets rem = to what is poped off
not removed
Bastien Lemaire
@blemaire
Sep 04 2015 07:59
it should be called removed...
Randy Goldsmith
@Dueldrawer8
Sep 04 2015 08:00
nvm found it
CAS0609
@CAS0609
Sep 04 2015 08:00

@xhanrot ```
var myArray = ["John", 23, ["cat", 2]];
// Only change code below this line.

var removed = myArray.pop(); // This should be ["cat", 2] and myArray should now be ["John", 23]

```

x34passenger
@x34passenger
Sep 04 2015 08:00
Bonfire: Where art thou - getting back empty array:
function where(collection, source) {
  var result = [];
  for (var i = 0; i < collection.length; i++) {
    // some code goes here
    // add collection[i] to result if what?
    if( source == collection[i] )
    {
      result.push(collection[i]);
    }
  }
  return result;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
CamperBot
@camperbot
Sep 04 2015 08:00
Sorry, can't find a bonfire called where art thou - getting back empty arrayfunction wherecollection source var result for var i 0 i collectionlength i some code goes here add collectioni to result if what if source collectioni resultpushcollectioni return resultwhere first romeo last montague first mercutio last null first tybalt last capulet last capulet . [ Check the map? ]
DTing
@dting
Sep 04 2015 08:00
@x34passenger source is an object
CAS0609
@CAS0609
Sep 04 2015 08:00
@xhanrot
DTing
@dting
Sep 04 2015 08:00
bf where
CamperBot
@camperbot
Sep 04 2015 08:00

:fire:Bonfire: Where art thou :link:

function where(collection, source) {
  var arr = [];
  // What's in a name?
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });

Make a function that looks through a list (first argument) and returns an array of all objects that have equivalent property values (second argument).

more info:  bf details | bf links | hint

DTing
@dting
Sep 04 2015 08:00
bf link
CamperBot
@camperbot
Sep 04 2015 08:00
Sorry, can't find a bonfire called link. [ Check the map? ]
DTing
@dting
Sep 04 2015 08:01
bf links
CAS0609
@CAS0609
Sep 04 2015 08:01
var myArray = ["John", 23, ["cat", 2]];
// Only change code below this line.

var removed = myArray.pop(); // This should be ["cat", 2] and myArray should now be ["John", 23]
Xavier Hanrot
@xhanrot
Sep 04 2015 08:02
ok, I got it, thank you all :-)
CamperBot
@camperbot
Sep 04 2015 08:02
if you want to thank someone, put an @ before their name!
Bastien Lemaire
@blemaire
Sep 04 2015 08:02
@CAS0609 that should work, 'removed' will equal ["cat", 2]
and myArray will equal ["John", 23]
CAS0609
@CAS0609
Sep 04 2015 08:03
really?
thats weird
Milos Markovic
@MilosMarkovic
Sep 04 2015 08:03
Please, can some1 help me with this :smile: function palindrome(str) {
// Good luck!
var tmp=str.toLowerCase().replace(' ','').replace('.','').replace(',','').split('').reverse().join('');
if(tmp===str.toLowerCase().replace(' ','').replace('.','').replace(',',''))
return true;
else
return false;
}
Milos Markovic
@MilosMarkovic
Sep 04 2015 08:04
why is this logic not good enough for palindrome? :D
CAS0609
@CAS0609
Sep 04 2015 08:04
wait @MilosMarkovic tell me please how to factorize!!!
Milos Markovic
@MilosMarkovic
Sep 04 2015 08:05
its about recursive calling of a function
DTing
@dting
Sep 04 2015 08:05
@x34passenger
function where(collection, source) {
  var result = [];
  for (var i = 0; i < collection.length; i++) {
    //  your code here is comparing and object directly. 
    // you need to iterate over the object's keys and check if collection[i] has every key.
    // and that for every key in source that collection[i]'s value for the key is equal to the source's value for key.
    // only if that is true for every key do you want to push to result
    if( source == collection[i] )
    {
      result.push(collection[i]);
    }
  }
  return result;
}
bf palindrom
CamperBot
@camperbot
Sep 04 2015 08:06

:fire:Bonfire: Check for Palindromes :link:

function palindrome(str) {
  // Good luck!
  return true;
}



palindrome("eye");

Return true if the given string is a palindrome. Otherwise, return false.

more info:  bf details | bf links | hint

x34passenger
@x34passenger
Sep 04 2015 08:06
@dting I am not sure how to reference the key in the array
Pabidabowi
@Pabidabowi
Sep 04 2015 08:08
hey guys i want to check if a character is a letter but my condition always return false i'm having trouble with regex :worried: here is my condition if (str[i].charAt(0) === /[a-z]/) i don't know what is wrong with this i need help :(
Bastien Lemaire
@blemaire
Sep 04 2015 08:09
/[a-z]/.test(str[i].charAt(0)) (I think)
just ensure casing is right
Pabidabowi
@Pabidabowi
Sep 04 2015 08:10
i'm doing a str.toLowerCase before checking
i'll test your solution
DTing
@dting
Sep 04 2015 08:11
@x34passenger which array?
@MilosMarkovic string.replace only replaces the first occurance if you use a string as the first argument of the replace function
consider using a regexp
Milos Markovic
@MilosMarkovic
Sep 04 2015 08:11
@blemaire TY :smile: I
Pabidabowi
@Pabidabowi
Sep 04 2015 08:12
@blemaire it works thank you :smile:
CamperBot
@camperbot
Sep 04 2015 08:12
pabidabowi sends brownie points to @blemaire :sparkles: :thumbsup: :sparkles:
:star: 19 | @blemaire | http://www.freecodecamp.com/blemaire
Bastien Lemaire
@blemaire
Sep 04 2015 08:13
@dting @MilosMarkovic string.replace can be made global using the flags
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
string.replace(' ','', g)
DTing
@dting
Sep 04 2015 08:13

@blemaire

flags
Note: The flags argument does not work in v8 Core (Chrome and Node.js). A string specifying a combination of regular expression flags. The use of the flags parameter in the String.prototype.replace() method is non-standard and deprecated. Instead of using this parameter, use a RegExp object with the corresponding flags. The value of this parameter if it is used should be a string consisting of one or more of the following characters to affect the operation as described:

also g i undefined
x34passenger
@x34passenger
Sep 04 2015 08:14
@dting
function where(collection, source) {
  var result = [];
  for (var i = 0; i < collection.length; i++) {
    // some code goes here
    // add collection[i] to result if what?
    if( source.keys() == collection[i] )
    {
      result.push(collection[i]);
    }
  }
  return result;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
`
Bastien Lemaire
@blemaire
Sep 04 2015 08:14
@dting fair enough, I prefere regex anyway..
DTing
@dting
Sep 04 2015 08:14
@x34passenger
var keys = Object.keys(source);
DTing
@dting
Sep 04 2015 08:20
function where(collection, source) {
  var result = [];

  // create a variable here to store the keys of source. 
  // these will never change so you dont need it in the loop
  var sourceKeys = Object.keys(source); 

  for (var i = 0; i < collection.length; i++) {
    // set a variable here to keep track if we should add this object in collection to the result
    var valid = true;
    // loop over sourceKeys. if any key in source key is not in collection[i] or the value for collection[i][key]
    // does not match source[key] then set valid to false 
    // if valid is still true after the loop, then push collection[i] to the result.
  }
  return result;
}
CAS0609
@CAS0609
Sep 04 2015 08:23
guys can you tell me how you made this exercise?
blob
i already got this correct but i dont know if theres another way
var f=[5]
function factorialize(num) {
  if (num == 0 || num == 1)
    return 1;
  if (f[num] > 0)
    return f[num];
  return f[num] = factorialize(num-1) * num;
}

factorialize(5);
Milos Markovic
@MilosMarkovic
Sep 04 2015 08:24
please, guys, why this thing fails again? :D

function palindrome(str) {
// Good luck!
var tmp=str.toLowerCase().replace(/ /g,'').replace(/./g,'').replace(/,/g,'').split('').reverse().join('');
if(tmp===str.toLowerCase().replace(/ /g,'').replace(/./g,'').replace(/,/g,''))
return true;
else
return false;
}

palindrome("eye");

CAS0609
@CAS0609
Sep 04 2015 08:25
i have this and its correct, is there an easier way?
@MilosMarkovic any suggestions?
DTing
@dting
Sep 04 2015 08:27
@MilosMarkovic /./ matches any character
you need to escape that .

you can use

/\./g

or consider combining your regex:

.replace(/[ .,]/g, '')

or using a special character https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Using_special_characters

CAS0609
@CAS0609
Sep 04 2015 08:32
g
guys which other alternative exists to factorilize a number using code?
var f=[5]
function factorialize(num) {
  if (num == 0 || num == 1)
    return 1;
  if (f[num] > 0)
    return f[num];
  return f[num] = factorialize(num-1) * num;
}

factorialize(5);
i got this
DTing
@dting
Sep 04 2015 08:33
@CAS0609
function factorialize(num) {
  if (num < 0) return undefined;
  if (num === 0) return 1;
  return num < 3 ? num : num * factorialize(num-1);
}
factorialize(5);
function factorialize(num) {
  if (num < 0) return undefined;
  if (num === 0) return 1;
  var result = num;
  while(--num) {
      result *= num;
  }
  return result
}
factorialize(5);
CAS0609
@CAS0609
Sep 04 2015 08:34
awesome!! thanks @diting
CamperBot
@camperbot
Sep 04 2015 08:34
cas0609 sends brownie points to @diting :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for diting
DTing
@dting
Sep 04 2015 08:37
what's your code so far?
@CAS0609 also
function factorialize(num) {
  if (num < 0) return undefined;
  var result = 1;
  for (var i = 2; i <= num; i++) {
      result *= i;
  }
  return result
}
factorialize(5);
22turning23
@22turning23
Sep 04 2015 08:38
I have reset everything
ooh sorry I thought you'd speaken to me :P @dting
DTing
@dting
Sep 04 2015 08:39
i am
what problems are you having?
22turning23
@22turning23
Sep 04 2015 08:40
I get stuck with the styling
I got it blue, but it's still not good :s
DTing
@dting
Sep 04 2015 08:42
Screen Shot 2015-09-04 at 1.41.33 AM.png
did you follow these instructions?
22turning23
@22turning23
Sep 04 2015 08:42
yes I did
DTing
@dting
Sep 04 2015 08:42
I can give you the answer but you are probably better off if you do it yourself
try it again and i can see what is wrong if you post some code
Alberto Vara
@kalivara
Sep 04 2015 08:43
Hello, I´m trying to build the weather app in the basic zipline 4...but I see that I need to use an API and during the course we have never covered that. I don´t knw anything about AJAX, or how to use an API.
How do I am supose to do it?
Thank you!
CamperBot
@camperbot
Sep 04 2015 08:43
if you want to thank someone, put an @ before their name!
22turning23
@22turning23
Sep 04 2015 08:43
ok I will try it again ;)
DTing
@dting
Sep 04 2015 08:44
@kalivara i would use google and search. but i can give you a hint. a lot of people have said using simpleweatherjs.com was very easy
@22turning23 let me know when you get stuck i can take a look at your code and maybe point you in the right direction
22turning23
@22turning23
Sep 04 2015 08:46
@dting I got everything good only one stays red, because I can't find the curly braces
Alberto Vara
@kalivara
Sep 04 2015 08:47
@dting Thanks! I will try that
CamperBot
@camperbot
Sep 04 2015 08:47
kalivara sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1018 | @dting | http://www.freecodecamp.com/dting
Binny Kim
@removed~BinnyK
Sep 04 2015 08:50
bonfire Validate US Telephone Numbers
CamperBot
@camperbot
Sep 04 2015 08:50

:fire:Bonfire: Validate US Telephone Numbers :link:

function telephoneCheck(str) {
  // Good luck!
  return true;
}



telephoneCheck("555-555-5555");

Return true if the passed string is a valid US phone number

more info:  bf details | bf links | hint

Binny Kim
@removed~BinnyK
Sep 04 2015 08:50
hint
CamperBot
@camperbot
Sep 04 2015 08:50
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Binny Kim
@removed~BinnyK
Sep 04 2015 08:51
bonfire Validate US Telephone Numbers hint
CamperBot
@camperbot
Sep 04 2015 08:51
Sorry, can't find a bonfire called validate us telephone numbers hint. [ Check the map? ]
DTing
@dting
Sep 04 2015 08:53
@22turning23 can you post the code?
help formatting
CamperBot
@camperbot
Sep 04 2015 08:53

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

```js ⇦ Type 3 backticks, then type js or html and then press [shift + enter ⏎]

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Pratik Ratnaparkhi
@pratikr1593
Sep 04 2015 08:53
<style>
  body {
    background-color: black;
    font-family: Monospace;
    color: green;
  }
  .pink-text {
    color: pink;
  }
  .blue-text{
    background-color:blue;
  }
</style>
<h1 class="pink-text blue-text">Hello World!</h1>
Is there anything wrong with code?
I'm stuck with override styles in Subsequent CSS
Your h1 element should be blue.
DTing
@dting
Sep 04 2015 08:54
which challenge are you on?
Pratik Ratnaparkhi
@pratikr1593
Sep 04 2015 08:55
it says it has to be blue. Override styles in subsequent CSS.
anyone?
DTing
@dting
Sep 04 2015 09:00
which challenge are you on?
Pratik Ratnaparkhi
@pratikr1593
Sep 04 2015 09:01
@dting Override styles in subsequent CSS.
DTing
@dting
Sep 04 2015 09:02
@pratikr1593 it wants you to overide the color
not change the background color
does that help?
Pratik Ratnaparkhi
@pratikr1593
Sep 04 2015 09:03
@dting let me check
Aniruddh Agarwal
@anrddh
Sep 04 2015 09:03
Will we be having a livestream tomorrow?
Pratik Ratnaparkhi
@pratikr1593
Sep 04 2015 09:05
@dting Thanks man! it worked
CamperBot
@camperbot
Sep 04 2015 09:05
pratikr1593 sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1019 | @dting | http://www.freecodecamp.com/dting
DTing
@dting
Sep 04 2015 09:05
nps
Aleksandar B.
@aleksandar-b
Sep 04 2015 09:09
Does anyone knows good tutorials on Angular, except the codeshool ? I want to learn more.
Costas Chaitas
@CostasChaitas
Sep 04 2015 09:11
i am on Bonfire: Roman Numeral Converter
why this code work
function convert(num) {
  var lookup = {M:1000,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1};
  var roman = '';
  for (var i in lookup ) {
    while (num >= lookup[i] ) {
      roman += i;
      num -= lookup[i];
    }
  }
  return roman;
}
convert(1200);
and this no
function convert(num) {
  var lookup = {M:1000,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1};
  var roman = '';
  for (var i=0; i<lookup.length; i++ ) {
    while (num >= lookup[i] ) {
      roman += i;
      num -= lookup[i];
    }
  }
  return roman;
}
convert(1200);
Benjamin Dengler
@ekx
Sep 04 2015 09:13
because "lookup" isn't an array
so you cant lookup the values with a number
Costas Chaitas
@CostasChaitas
Sep 04 2015 09:14
but i is a number in the first case also isnt it?
Benjamin Dengler
@ekx
Sep 04 2015 09:14
no
it iterates through the properties
so its "M", then "CM"
and so on
Costas Chaitas
@CostasChaitas
Sep 04 2015 09:15
got it
and if i want to loop over a object this way is the only
?
Benjamin Dengler
@ekx
Sep 04 2015 09:16
you could also get all the properties by calling "Object.keys(lookup)"
which returns an array
and iterate over that
it would return ["M", "CM", ...]
in the above case
Costas Chaitas
@CostasChaitas
Sep 04 2015 09:19
function convert(num) {
  var lookup = {M:1000,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1};
  var lookupArr=Object.keys(lookup);
  var roman = '';
  for (var i=0; i<lookupArr.length; i++ ) {
    while (num >= lookupArr[i] ) {
      roman += i;
      num -= lookupArr[i];
    }
  }
  return roman;
}
convert(1200);
this doesnt work either
Benjamin Dengler
@ekx
Sep 04 2015 09:21
function convert(num) {
  var lookup = {M:1000,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1};
  var lookupArr=Object.keys(lookup);
  var roman = '';
  for (var i=0; i<lookupArr.length; i++ ) {
    while (num >= lookup[lookupArr[i]] ) {
      roman += lookupArr[i];
      num -= lookup[lookupArr[i]] ;
    }
  }
  return roman;
}
convert(1200);
should work
lookupArr[0] should return "M"
and lookup["M"] the numeric value of 1000
Aniruddh Agarwal
@anrddh
Sep 04 2015 09:22
@samosale check out scotch.io
They have pretty good tutorials on the MEAN stack
Costas Chaitas
@CostasChaitas
Sep 04 2015 09:24
right !but lookupArr[i] now returns the numeric values right(1000,900...) and not "M" ,"CM"...
NainaPS
@Navyya
Sep 04 2015 09:25
Hello I need help
Benjamin Dengler
@ekx
Sep 04 2015 09:27
@rasakos really? just tried it and lookupArr has the value ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"] on my machine
Costas Chaitas
@CostasChaitas
Sep 04 2015 09:28
but Object.keys(x) return the properties of a object so on our example the properties are the numbers
i am confused:)
Benjamin Dengler
@ekx
Sep 04 2015 09:28
no it returns the property names
not the actual properties
to get the value from an object you can then use objectInstance["propertyName"]
it works the same as objectInstance.propertyName
except that you can use a variable the first way
Costas Chaitas
@CostasChaitas
Sep 04 2015 09:31
bro here says that Object.keys return the position of the items ex. Object.keys("foo");
// ["0", "1", "2"]
NainaPS
@Navyya
Sep 04 2015 09:31
How to solve document not defind issues???
@cassidypignatello Can U help
Benjamin Dengler
@ekx
Sep 04 2015 09:36
it returns the positions if the properties are not named
but even then as strings and not numbers
Costas Chaitas
@CostasChaitas
Sep 04 2015 09:36
aaaa nice got it!!!:)
and finnaly lookup[lookupArr[i]] returns the value of the lookupArr item for example for M returns 1000
right?
Benjamin Dengler
@ekx
Sep 04 2015 09:41
exactly
Costas Chaitas
@CostasChaitas
Sep 04 2015 09:42
thanks a lot @ekx
CamperBot
@camperbot
Sep 04 2015 09:42
rasakos sends brownie points to @ekx :sparkles: :thumbsup: :sparkles:
:star: 177 | @ekx | http://www.freecodecamp.com/ekx
Costas Chaitas
@CostasChaitas
Sep 04 2015 09:43
function convert(num) {
 var answer ='';
 var numb = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
 var rnumb = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'];

  for(var i=0; i<=numb.length;i++) {
    while(num >= numb[i]) {
      answer += rnumb[i];
      num -= numb[i];
    }
  }
  return answer;

}

convert(36);
another solution that i broke the object on 2 same length arrays
Benjamin Dengler
@ekx
Sep 04 2015 09:44
probably a little nicer to read than the object solution without for each loop
:smile:
Costas Chaitas
@CostasChaitas
Sep 04 2015 09:45
function convert(num) {

  var numArray = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
  var romArray = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"];
  var romanConv = [];


  for (var i=0; i<= numArray.length; i++) {
    if (num - numArray[i] >= 0) {
      romanConv += romArray[i];
      num -= numArray[i];
      i=0;
    }
  }

  return romanConv;
}
here why cant use the romanConv.push(roomArray[i])?
instead of +=?
DTing
@dting
Sep 04 2015 09:46
@rasakos thats actually a better solution because object property order is not defined.
meaning it isn't guarnteed
Costas Chaitas
@CostasChaitas
Sep 04 2015 09:47
yeah but in the first solution you have only 1 object no 2 arrays
DTing
@dting
Sep 04 2015 09:48
but may behave incorrectly in certain cases
Elizabeth Hatleli
@TheHighPriestess
Sep 04 2015 09:52
Can someone explain the parameters in this .reduce() example? I read the docs and I found them to be less than clear:
```
var total = [0, 1, 2, 3].reduce(function(a, b) {
  return a + b;
});
// total == 6
What exactly are a and b?
DTing
@dting
Sep 04 2015 09:52
a is previous b is current
a is the value that is being passed along the reduce calls
b is the current element of the array you are reducing
if you dont provide a second argument for reduce the a starts at index 0 and b starts at index 1
Elizabeth Hatleli
@TheHighPriestess
Sep 04 2015 09:53
Do I need to know how this works in order to use .reduce?
DTing
@dting
Sep 04 2015 09:53
ya
Elizabeth Hatleli
@TheHighPriestess
Sep 04 2015 09:54
Ok...let's start with a
what exactly is a...in this array above?
Aniruddh Agarwal
@anrddh
Sep 04 2015 09:54
a is the first value
DTing
@dting
Sep 04 2015 09:54
var arr = [0,1,2,3];
arr.reduce(function(a, b) { 
  console.log(a, b);
  return a +b;
});
Elizabeth Hatleli
@TheHighPriestess
Sep 04 2015 09:54
so..in this example...a is 0
Aniruddh Agarwal
@anrddh
Sep 04 2015 09:55
in the first iteration
DTing
@dting
Sep 04 2015 09:55
0 1
1 2
3 3
6
Elizabeth Hatleli
@TheHighPriestess
Sep 04 2015 09:55
so it starts at 0
Aniruddh Agarwal
@anrddh
Sep 04 2015 09:55
It helps if you think in terms of a basic for loop
Elizabeth Hatleli
@TheHighPriestess
Sep 04 2015 09:55
this is confusing
ok...I will try to think of it that way
let me play around with console.log
DTing
@dting
Sep 04 2015 09:56
var arr = [0,1,2,3];
arr.reduce(function(a, b) { 
  console.log(a, b);
  return a +b;
}, 5); // notice i have a second argument for this reduce
5 0
5 1
6 2
8 3
11
Elizabeth Hatleli
@TheHighPriestess
Sep 04 2015 09:56
ah yes
DTing
@dting
Sep 04 2015 09:57
if you provide second argument it will use it as the initial value of a, and the initial value of b is the element at index 0
Aniruddh Agarwal
@anrddh
Sep 04 2015 09:57
a is basically the current value, and b the next value
if you don't provide a second argument, arr[i] is a, and arr[i+1] is b
Elizabeth Hatleli
@TheHighPriestess
Sep 04 2015 09:58
ok thank you @awesomeaniruddh and thank you @dting
CamperBot
@camperbot
Sep 04 2015 09:58
thehighpriestess sends brownie points to @awesomeaniruddh and @dting :sparkles: :thumbsup: :sparkles:
:star: 342 | @awesomeaniruddh | http://www.freecodecamp.com/awesomeaniruddh
:star: 1020 | @dting | http://www.freecodecamp.com/dting
Elizabeth Hatleli
@TheHighPriestess
Sep 04 2015 09:58
I will play around with it
Aniruddh Agarwal
@anrddh
Sep 04 2015 09:58
The reduce function is one of the hardest to make sense of
but play around with it, and you eventually will
Elizabeth Hatleli
@TheHighPriestess
Sep 04 2015 09:59
It's hideous LOL
Rahul
@RahulReddy75
Sep 04 2015 10:00
hi all... what does this statement mean exactly :
expected [ null ] to deeply equal []
Aniruddh Agarwal
@anrddh
Sep 04 2015 10:00
it means the output it got was [ null ]
but it was expecting [] to be the output
DTing
@dting
Sep 04 2015 10:01
it means your function returned an array that contains one element null
it expected an empty array
Rahul
@RahulReddy75
Sep 04 2015 10:02
ok thanks guys
CamperBot
@camperbot
Sep 04 2015 10:02
if you want to thank someone, put an @ before their name!
Elizabeth Hatleli
@TheHighPriestess
Sep 04 2015 10:18
Ok...MDN's info on .reduce() is making a bit more sense. However, I gotta ask......why would someone use it rather than a for loop?
for loops are intuitive...easy to understand.
Aleksandar B.
@aleksandar-b
Sep 04 2015 10:20
@TheHighPriestess less code.
Elizabeth Hatleli
@TheHighPriestess
Sep 04 2015 10:20
@samosale Is that the only reason?
Aleksandar B.
@aleksandar-b
Sep 04 2015 10:21
yes
Elizabeth Hatleli
@TheHighPriestess
Sep 04 2015 10:21
ok
x34passenger
@x34passenger
Sep 04 2015 10:21
Bonfire: Where art thou: I'm having trouble comparing the key in the source with the keys in the array:
function where(collection, source) {
  var result = [];
  var keys = Object.keys(source);
  for (var i = 0; i < collection.length; i++)
  {
    if( keys == collection[i] )
    {
      result.push(collection[i]);
    }
  }
  return result;
}
CamperBot
@camperbot
Sep 04 2015 10:21
Sorry, can't find a bonfire called where art thou im having trouble comparing the key in the source with the keys in the arrayfunction wherecollection source var result var keys objectkeyssource for var i 0 i collectionlength i if keys collectioni resultpushcollectioni return result. [ Check the map? ]
Aniruddh Agarwal
@anrddh
Sep 04 2015 10:26
@TheHighPriestess Also, more abstraction
You are distancing yourself further from screwdrivers, and starting to use some more advanced tools that build upon the basic tools
To provide more functionality at a lesser cost
Soumya Rauth
@soumyaRauth
Sep 04 2015 10:30
Anyone there to help me with pomodoro clock?
Can anyone help me with the Pomodoro clock zipline???
MD Arefin Saad
@arefinsaaad
Sep 04 2015 10:51
stuck in waypoint 4 (Basic Algorithm)
help !!!!!
CamperBot
@camperbot
Sep 04 2015 10:51

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. ex: find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • bonfire BONFIRENAME info on a bonfire

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Roy
@CruelCoin
Sep 04 2015 11:30
@marcusmatthias1
function titleCase(str)
{
  var wordArray = str.split(' ');
  for (var i = 0; i < wordArray.length; i++)
    {
      var tempWord = wordArray[i];
      var firstLetter = tempWord.charAt(0).toUpperCase();
      var restOfWord = tempWord.substring(1).toLowerCase();
      var newWord = firstLetter.concat(restOfWord); 
      wordArray[i] = newWord;
    }

  var returnString = wordArray.join(' ');

  return returnString;
}

titleCase("I'm a little tea pot");
Malik Piara
@malikpiara
Sep 04 2015 11:31
Hey Guys! Can I get some help with exercice 126 (Waypoint: Use Bracket Notation to Find the NthtoLast Character in a String)?
I was pretty sure I wrote everything correctly but it's not working though :worried:
Roy
@CruelCoin
Sep 04 2015 11:32
@marcusmatthias1 The "wordArray[i] = newWord;" line exists to store the results of having concantenated the word, otherwise, the word would be lost when the loop moves to its next iteration. I later then join the array to return the string that's being asked for.
Malik Piara
@malikpiara
Sep 04 2015 11:33
Don't need to worry about my issue, I just misspelled a word
Roy
@CruelCoin
Sep 04 2015 11:33
Mind you, i could have had one less line of code had i just done this:
function titleCase(str)
{
  var wordArray = str.split(' ');
  for (var i = 0; i < wordArray.length; i++)
    {
      var tempWord = wordArray[i];
      var firstLetter = tempWord.charAt(0).toUpperCase();
      var restOfWord = tempWord.substring(1).toLowerCase();
      wordArray[i] = firstLetter.concat(restOfWord); 
    }

  var returnString = wordArray.join(' ');

  return returnString;
}

titleCase("I'm a little tea pot");
Elizabeth Hatleli
@TheHighPriestess
Sep 04 2015 11:37
OK....if newArray=[1,2,3]; ......why does this work:
```
```
```
Aniruddh Agarwal
@anrddh
Sep 04 2015 11:38
Shit-enter
Elizabeth Hatleli
@TheHighPriestess
Sep 04 2015 11:38
var sum = newArr.reduce(function(a,b){
 return sum;

 console.log(sum);

});
my god
i mean...why DOESN'T this work
Aniruddh Agarwal
@anrddh
Sep 04 2015 11:38
You can edit messages, btw :P
Elizabeth Hatleli
@TheHighPriestess
Sep 04 2015 11:38
haha
I can never remember the correct command there
Aniruddh Agarwal
@anrddh
Sep 04 2015 11:39
var sum = newArr.reduce(function(a,b){
 return a+b;
});
console.log(sum);
Does that work?
I'm not very good with reduce either, so yeah
wiki format
CamperBot
@camperbot
Sep 04 2015 11:39

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

```js ⇦ Type 3 backticks, then type js or html and then press [shift + enter ⏎]

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Aniruddh Agarwal
@anrddh
Sep 04 2015 11:39
Just run that command whenever you forget :)
Elizabeth Hatleli
@TheHighPriestess
Sep 04 2015 11:40
yes..and I moved the console.log
it works
thank you @awesomeaniruddh
CamperBot
@camperbot
Sep 04 2015 11:40
thehighpriestess sends brownie points to @awesomeaniruddh :sparkles: :thumbsup: :sparkles:
:star: 344 | @awesomeaniruddh | http://www.freecodecamp.com/awesomeaniruddh
Aniruddh Agarwal
@anrddh
Sep 04 2015 11:41
np
I hope you understand why?
That's very important
Refer to @dting's explanation
Xchel Hernandez
@xchelm
Sep 04 2015 11:43
What's the best way to learn about calling APIs? Any tutorials someone could recommend?
Aniruddh Agarwal
@anrddh
Sep 04 2015 11:44
You can refer to jQuery docs
Xchel Hernandez
@xchelm
Sep 04 2015 11:45
ty!
Yazed Jamal
@muyaszed
Sep 04 2015 11:45
HI guys, im working on the portfolio page
Xchel Hernandez
@xchelm
Sep 04 2015 11:45
thanks @awesomeaniruddh
CamperBot
@camperbot
Sep 04 2015 11:45
xchelm sends brownie points to @awesomeaniruddh :sparkles: :thumbsup: :sparkles:
:star: 346 | @awesomeaniruddh | http://www.freecodecamp.com/awesomeaniruddh
Rory Smith
@alanbuchanan
Sep 04 2015 11:46
need a little help for my twitch searcher http://codepen.io/alanbuchanan/full/VvYyzz/
Yazed Jamal
@muyaszed
Sep 04 2015 11:46
can anyone help why is the last <li> element push upward. thanks
CamperBot
@camperbot
Sep 04 2015 11:46
if you want to thank someone, put an @ before their name!
Rory Smith
@alanbuchanan
Sep 04 2015 11:46
the search function is problematic when going between online and offline
and the whole thing changes position when going back to All from the other two
raykoff
@raykoff
Sep 04 2015 11:46
I need some help with Bonfire: Falsey Bouncer pls
CamperBot
@camperbot
Sep 04 2015 11:46
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Aniruddh Agarwal
@anrddh
Sep 04 2015 11:47
@alanbuchanan Working fine for me?
Or maybe I didn't understand the problem
Rory Smith
@alanbuchanan
Sep 04 2015 11:47
@awesomeaniruddh please see my above msg
Aniruddh Agarwal
@anrddh
Sep 04 2015 11:48
What do you mean by changes position?
Rory Smith
@alanbuchanan
Sep 04 2015 11:49
@awesomeaniruddh if you click online, then all, the thing moves down, as though it's docked to the navbar
i want it docked to the very top of the page
Aniruddh Agarwal
@anrddh
Sep 04 2015 11:49
Oh
Stickler for details, aren't you? :D
Let me check your code
Rory Smith
@alanbuchanan
Sep 04 2015 11:51
@awesomeaniruddh that's the smaller problem - the big one is that it messes up when you search while in 'online mode' or 'offline mode'. it simple acts as though it's back to 'all mode'
Aniruddh Agarwal
@anrddh
Sep 04 2015 11:52
Angular would make this so simple (I guess)
Let me see
Rory Smith
@alanbuchanan
Sep 04 2015 11:52
@awesomeaniruddh yeah, i did similar in angular before, but i was determined to figure out the equivalent in jquery
raykoff
@raykoff
Sep 04 2015 11:53
what was the regex for filter empty string?
Rory Smith
@alanbuchanan
Sep 04 2015 11:53
@awesomeaniruddh i think it needs to know what is active
Aniruddh Agarwal
@anrddh
Sep 04 2015 11:57
search doesn't seem to mess up for me?
Rory Smith
@alanbuchanan
Sep 04 2015 11:57
@awesomeaniruddh you can actually see the style of online/offline change when you click in the input box
what i mean is the search doesn't filter according to all/online/offline state
it searches all, in every case
Aniruddh Agarwal
@anrddh
Sep 04 2015 11:58
Seems like you're using a jQuery plugin?
Rory Smith
@alanbuchanan
Sep 04 2015 11:58
@awesomeaniruddh yes, i am
Aniruddh Agarwal
@anrddh
Sep 04 2015 11:59
What's the name?
I'll have a look at their documentation
raykoff
@raykoff
Sep 04 2015 12:00
anyone willing to help with Bonfire: Falsey Bouncer?
CamperBot
@camperbot
Sep 04 2015 12:00
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Aniruddh Agarwal
@anrddh
Sep 04 2015 12:01
@raykoff In a sec
@alanbuchanan Why not set a class class '.searchThis' or something along those lines
Whenever you click on a tab, all elements inside that div get that class
and your itemSelector can be set to '.searchThis'
That should work
Rory Smith
@alanbuchanan
Sep 04 2015 12:02
@awesomeaniruddh that's a good idea
@awesomeaniruddh well thanks for your help so far
Aniruddh Agarwal
@anrddh
Sep 04 2015 12:02
nop
Rory Smith
@alanbuchanan
Sep 04 2015 12:03
@awesomeaniruddh well thanks for your help so far
CamperBot
@camperbot
Sep 04 2015 12:03
alanbuchanan sends brownie points to @awesomeaniruddh :sparkles: :thumbsup: :sparkles:
:star: 348 | @awesomeaniruddh | http://www.freecodecamp.com/awesomeaniruddh
Aniruddh Agarwal
@anrddh
Sep 04 2015 12:03
np
jelden
@jelden
Sep 04 2015 12:06
I'm stuck on waypoint 18. When I add two classes to img element, only the first executes
Aniruddh Agarwal
@anrddh
Sep 04 2015 12:07
@raykoff What was your issue?
Serse
@Sersee
Sep 04 2015 12:09
Hello
Can somebody help me with the weather app pls ?
raykoff
@raykoff
Sep 04 2015 12:09
@awesomeaniruddh
/*
Remove all falsey values from an array.

Falsey values in javascript are false, null, 0, "", undefined, and NaN.
*/
function bouncer(arr) {

 var invalidEntries = 0;
    function filter(obj) {
      if (typeof(obj) === 'number' && !isNaN(obj) || typeof(obj) === 'string' && 
      obj !== undefined && obj !== '') {
        return true;
    } else {
        invalidEntries++;
      return false;
  }
}
 var filtro = arr.filter(filter);
  console.log(filtro);
  console.log(invalidEntries);
}
bouncer([7, 'ate', '', false, 9, NaN, undefined, null]);
Serse
@Sersee
Sep 04 2015 12:10
I can't make the "change units" button work
raykoff
@raykoff
Sep 04 2015 12:10
i don't know why this won't work
Aniruddh Agarwal
@anrddh
Sep 04 2015 12:12
@raykoff
/*
Remove all falsey values from an array.

Falsey values in javascript are false, null, 0, "", undefined, and NaN.
*/
function bouncer(arr) {

 arr = arr.map(function(item) { return item; });
return arr;
}
bouncer([7, 'ate', '', false, 9, NaN, undefined, null]);
Does that work?
raykoff
@raykoff
Sep 04 2015 12:15
@awesomeaniruddh It's about removing false entrys
Aniruddh Agarwal
@anrddh
Sep 04 2015 12:15
Ik
But did the solution work?
Wait, replace map with filter
bf bouncer
CamperBot
@camperbot
Sep 04 2015 12:16

:fire:Bonfire: Falsey Bouncer :link:

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  return arr;
}

bouncer([7, 'ate', '', false, 9]);

Remove all falsey values from an array.

more info:  bf details | bf links | hint

raykoff
@raykoff
Sep 04 2015 12:16
wtf
how this works? i don't understand
Serse
@Sersee
Sep 04 2015 12:17
Anybody can help me with the weather app pls ?
Aniruddh Agarwal
@anrddh
Sep 04 2015 12:17
@Sersee Just a sec
@raykoff you know how the filter function works?
Serse
@Sersee
Sep 04 2015 12:17
ok, thanks!
CamperBot
@camperbot
Sep 04 2015 12:17
if you want to thank someone, put an @ before their name!
raykoff
@raykoff
Sep 04 2015 12:18
@awesomeaniruddh yes but ....
Aniruddh Agarwal
@anrddh
Sep 04 2015 12:18
@raykoff the return statement evaluates the expression next to it
raykoff
@raykoff
Sep 04 2015 12:18
i don't get how it filters all this stuff
Aniruddh Agarwal
@anrddh
Sep 04 2015 12:18
similar to how the if statement does
so when item = any falsey value, the evaluation returns false and return does not return it