Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
Dan Logajan
@hiltydiggs
The currentItem.hasOwnProperty part was unnecessary.
function whereAreYou(collection, source) {
  var arr = [];
  // Only change code below this line
  var testKeys = Object.keys(source),
      rqrd = testKeys.length,
      collectionLength = collection.length,
      i,
      j,
      matched,
      currentKey,
      currentItem;

  for (i = 0; i < collectionLength; i++) {
    matched = 0;
    currentItem = collection[i];

    for (j = 0; j < rqrd; j++) {
      currentKey = testKeys[j];
      if (currentItem[currentKey] === source[currentKey]) {
        matched++;
      }
    }
    if (matched === rqrd) {
      arr.push(currentItem);
    }
  }
  // Only change code above this line
  return arr;
}

whereAreYou([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "c": 2 });
Gabriel Alexandre
@GabrielShaad
Hello world! I am developing my Portfolio page and I have an issue with the navbar. When it is small, the list of links becomes vertical, but I want it horizontal, like when it is in a big screen. How can I do it?
http://codepen.io/gabrielshaad/pen/BzLRdm?editors=1100
CamperBot
@camperbot

welcome to FreeCodeCamp @GabrielShaad!

Gabriel Alexandre
@GabrielShaad
Oh, and it is also overlapping the website.
I tried modifying the padding of the body like it is mentioned in the Bootstrap documentation, but it seems it failed.
Jack Lyons
@JackEdwardLyons
hey im wondering why my console.log in the nested loop isn't working?

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

  /* Set variables */
  var sourceKey = Object.keys(source); // create array for source key
  console.log(sourceKey);

  var testKey = Object.keys(source)[0]; // show source key as string
  console.log(testKey);

  var testValue = source[testKey]; // show source value as string
  console.log(testValue);


for ( var i = 0; i < collection.length; i++ ) {
    var collectedItems = collection[i];

  for (var j = 0; j < source.length; j++ ) {
    if ( collection[i].hasOwnProperty(sourceKey[j]) ) {
      console.log("hellllllllooooo?");
    }
  }  
}

  return arr;
}

whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Dan Logajan
@hiltydiggs
@JackEdwardLyons I see it. source is an object, so it doesn't have a length property.
Jack Lyons
@JackEdwardLyons
ah ok
so...
Dan Logajan
@hiltydiggs
you could use sourceKey.length
Islam Ibakaev
@dagman
@JackEdwardLyons what about this :smile:
function whereAreYou(first, second){
  var cond = JSON.stringify(second).slice(1, -1).split(',');
  console.log(cond);
  return first
  .map(function(el) {
    return JSON.stringify(el);
  })
  .filter(function(el) {
      for(var condition of cond) {
          if(!el.includes(condition)) return false;
      }
      return true;
  })
  .map(function(el) {
      return JSON.parse(el);
  });
}
@JackEdwardLyons have just made it for u
Jack Lyons
@JackEdwardLyons
haha my eyes just glaze over that code
thanks @dagman
CamperBot
@camperbot
jackedwardlyons sends brownie points to @dagman :sparkles: :thumbsup: :sparkles:
:cookie: 586 | @dagman |http://www.freecodecamp.com/dagman
Jack Lyons
@JackEdwardLyons
but i have no idea whats going
Islam Ibakaev
@dagman
@JackEdwardLyons it is not hard at all
Jack Lyons
@JackEdwardLyons
so you slice away the brackets on source ?
Islam Ibakaev
@dagman
@JackEdwardLyons yep
Jack Lyons
@JackEdwardLyons
then return first right away? why?
Islam Ibakaev
@dagman
@JackEdwardLyons the first get under .map .fiter and .map
Dan Logajan
@hiltydiggs
@dagman nice work!
Islam Ibakaev
@dagman
@JackEdwardLyons you should check docs on this methods and also JSON.stringify and JSON.parse and i bet all stuff suddenly will be easy to understand
CamperBot
@camperbot
dagman sends brownie points to @hiltydiggs :sparkles: :thumbsup: :sparkles:
Islam Ibakaev
@dagman
@hiltydiggs thx :smile:
CamperBot
@camperbot
:cookie: 554 | @hiltydiggs |http://www.freecodecamp.com/hiltydiggs
Jack Lyons
@JackEdwardLyons
ok thanks @dagman
CamperBot
@camperbot
jackedwardlyons sends brownie points to @dagman :sparkles: :thumbsup: :sparkles:
:warning: jackedwardlyons already gave dagman points
Islam Ibakaev
@dagman
@JackEdwardLyons yw
Gabriel Alexandre
@GabrielShaad
Any help with the navbar?
Jack Lyons
@JackEdwardLyons
can someone please explain nested for loops with variables that have something like this
variable[i][j]
when it is nested in two loops
what does that mean
Greg Duncan
@GregatGit
@JackEdwardLyons i simple one would be to console.log each number in this arr var myArr = [ [1, 2 ], [3, 4 ] ];

@JackEdwardLyons

var myArr = [ [1,2], [3,4]];

for (var i = 0; i < myArr.length; i++){
    for (var j = 0; j < myArr[i].length; j++)
        console.log(myArr[i][j]);
}

the second for loop is nested in the first

Jack Lyons
@JackEdwardLyons
ah ok
so its not like bracket notation?
so it adds [i] first then [j]
Greg Duncan
@GregatGit
console.log(myArr[1][0]); / / => 3
@JackEdwardLyons there is no adding
Jack Lyons
@JackEdwardLyons
it displays
Greg Duncan
@GregatGit
it accesses it
var myArr = [ [1,2], [3,4]];
myArr[0][1] = 'apple';

for (var i = 0; i < myArr.length; i++){
    for (var j = 0; j < myArr[i].length; j++)
        console.log(myArr[i][j]);
}
that for loop would put out
1
apple
3
4
Greg Duncan
@GregatGit
@JackEdwardLyons I looked at your code
source.length is undefined
Jack Lyons
@JackEdwardLyons
ok
Greg Duncan
@GregatGit
source is an object.
Jack Lyons
@JackEdwardLyons
thanks @GregatGit i think i got it