These are chat archives for FreeCodeCamp/HelpJavaScript

16th
Feb 2016
Norman Dela Cruz
@dcnr
Feb 16 2016 00:02 UTC
@BLayman if you want to do it like that with loops and not array methods, you'll have to first make sure that all of source properties are in your collection before you push the collection. You can for example just set a variable to true if all source props are in collection before you push the object in your answer array.
bentongarrett
@bentongarrett
Feb 16 2016 00:04 UTC
alright, i could use some help on "profile lookup". any tips?
    for ( i = 0; i <= contacts.length; i++) {
         if ( contacts[i] === firstName && contacts.hasOwnProperty(prop) ) {
          return contacts[i][prop];
      } else if ( contacts.hasOwnProperty(firstName) === false ) {
          return "No such contact";
      } else if ( contacts.hasOwnProperty(prop) === false ) {
          return "No such property";
      }
  }
Harsha Vamsi
@harshavamsi
Feb 16 2016 00:07 UTC

// Setup
var collection = {
"2548": {
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": [
"Let It Rock",
"You Give Love a Bad Name"
]
},
"2468": {
"album": "1999",
"artist": "Prince",
"tracks": [
"1999",
"Little Red Corvette"
]
},
"1245": {
"artist": "Robert Palmer",
"tracks": [ ]
},
"5439": {
"album": "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) {
var test=prop;
if(value!=="" && prop!="tracks")
collection[id]={"prop":value};
else if(value!=="" && prop=="tracks")
collection.id[prop].push(value);
else
delete collection.id[prop].value;

return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");

anyidea how to push the prop value and not the work prop?
Brett
@BLayman
Feb 16 2016 00:11 UTC
@dcnr That's right, I was thinking that only one property had to match, but looking over the instructions I think it's all of them.
@dcnr I think I may just start over using array methods, since that seems to be the easy way of doing it.
rybka02
@rybka02
Feb 16 2016 00:14 UTC
@harshavamsi Is it an array value you're trying to push?
Harsha Vamsi
@harshavamsi
Feb 16 2016 00:15 UTC
No object value.
rybka02
@rybka02
Feb 16 2016 00:16 UTC
Can only use push with arrays
you have to set the value for object
Tom Hodgkinson
@LibLogic
Feb 16 2016 00:26 UTC
can someone help me with "Sum of Odd Fibanacci's"??
Bartek
@dyczol
Feb 16 2016 00:27 UTC
@Mooli88 thanks
CamperBot
@camperbot
Feb 16 2016 00:27 UTC
dyczol sends brownie points to @mooli88 :sparkles: :thumbsup: :sparkles:
:star: 169 | @mooli88 | http://www.freecodecamp.com/mooli88
Ari Winokur
@ariwinokur
Feb 16 2016 00:27 UTC
Doing "Using Objects for Lookups" and I have no clue what it is talking about. It throws you into using lookups with no explanations
Tom Hodgkinson
@LibLogic
Feb 16 2016 00:28 UTC
var fibs = [0, 1];
function sumFibs(num) {
    if ( num === 0 ) { return }
fibs.push(fibs[fibs.length-2] + fibs[fibs.length-1]);
var fibTotals = fibs
    .filter(function(el){
    if ( el % 2 !== 0 ) { return true }
    })
    .reduce(function(all, item) {
    all += item;
    return all;
    });
    console.log(fibTotals);
    sumFibs(num-1);
}

console.log(sumFibs(4));
can console.log the answer but I can't figure out how to return it
rybka02
@rybka02
Feb 16 2016 00:33 UTC
uhm without looking at the code,. why not just return sumFibs(4);
actual,ly no
do return fibTotals;
Tom Hodgkinson
@LibLogic
Feb 16 2016 00:34 UTC
I am accumulating the value one iteration at a time, but just want to output the last iteration
that gives the wrong answer
Emanuel Quimper
@EQuimper
Feb 16 2016 00:38 UTC
function truncate(str, num) {
  // Clear out that junk in your trunk
  if(str.length > num){
    return str.slice(0, num-3) + "...";
  } else if(num > 0 && num <= 3){
      return str.slice(-num) + "...";
  } else {
    return str;
  }

}

truncate("Absolutely Longer", 2);
need help here plz
Alex N.
@N0bl3
Feb 16 2016 00:39 UTC
@EQuimper -num is not a valid statement, what do you want to do?
Emanuel Quimper
@EQuimper
Feb 16 2016 00:39 UTC
sry I change this after I put that
this is the Truncate a string
Alex N.
@N0bl3
Feb 16 2016 00:40 UTC
bf truncate
CamperBot
@camperbot
Feb 16 2016 00:40 UTC

:fire:Bonfire: Truncate a string :link:

function truncate(str, num) {
  // Clear out that junk in your trunk
  return str;
}

truncate('A-tisket a-tasket A green and yellow basket', 11);

Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a '...' ending.

more info:  bf details | bf links | hint

Alex N.
@N0bl3
Feb 16 2016 00:41 UTC
bf truncate hint
CamperBot
@camperbot
Feb 16 2016 00:41 UTC
Sorry, can't find a bonfire called truncate hint. [ Check the map? ]
Alex N.
@N0bl3
Feb 16 2016 00:41 UTC
hint
CamperBot
@camperbot
Feb 16 2016 00:41 UTC
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
rybka02
@rybka02
Feb 16 2016 00:41 UTC
im getting undefined Liba
Alex N.
@N0bl3
Feb 16 2016 00:41 UTC
@EQuimper it's because it's not about cutting three letters : look at the left of the window on the test cases
Emanuel Quimper
@EQuimper
Feb 16 2016 00:43 UTC
@N0bl3 yes but my -3 is for put the "..." into the count
Erland Lami
@Texber
Feb 16 2016 00:43 UTC
function palindrome(str) {
  // Good luck!

  str=str.toLowerCase();

  for (var i=0; i<str.length; i++) {
    str.replace(' ', '');
    str.replace(',', '');
    str.replace('.', '');

var copy=str.split('').reverse().join('');

    if (copy==str) {
  return true;
}
}

  return str;
}

palindrome("A man, a plan, a canal. Panama");
When I test the palindrome, it's not removing the space, period and comma
Please advise anyone
Emanuel Quimper
@EQuimper
Feb 16 2016 00:44 UTC
bf palindrome
CamperBot
@camperbot
Feb 16 2016 00:44 UTC

: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

DJ
@qualitymanifest
Feb 16 2016 00:44 UTC
@Texber str = str.replace(blahblah)
@Texber also you don't need to put your replaces in a loop
Francisco Darré
@frandarre
Feb 16 2016 00:45 UTC
bf larger
CamperBot
@camperbot
Feb 16 2016 00:45 UTC
Sorry, can't find a bonfire called larger. [ Check the map? ]
Erland Lami
@Texber
Feb 16 2016 00:45 UTC
I don't follow @qualitymanifest about str = str.replace()
DJ
@qualitymanifest
Feb 16 2016 00:46 UTC
@Texber you're not assigning your str.replace to anything, so you're throwing the value that you created away. you want to assign it back to str so you're actually changing str.
Emanuel Quimper
@EQuimper
Feb 16 2016 00:46 UTC
@Texber I did that with regex
Tom Hodgkinson
@LibLogic
Feb 16 2016 00:47 UTC
Anybody here that will take a look at my code?? I want to understand what I am doing wrong. I can solve this another way but I am trying to learn about using recursive functions..But I have a glitch
Emanuel Quimper
@EQuimper
Feb 16 2016 00:47 UTC
@LibLogic can you repost ?
Tom Hodgkinson
@LibLogic
Feb 16 2016 00:47 UTC
@EQuimper absolutely
Lee Tratnyek
@kaplejon
Feb 16 2016 00:47 UTC
Looking for some guidance on Stand In Line challenge.
Erland Lami
@Texber
Feb 16 2016 00:47 UTC
@EQuimper I'm not as familiar with that method
Emanuel Quimper
@EQuimper
Feb 16 2016 00:48 UTC
@Texber regexr.com
Lee Tratnyek
@kaplejon
Feb 16 2016 00:48 UTC
function queue(arr, item) { // Your code here arr = arr.push(item); item = arr.shift(); return item; // Change this line }
Tom Hodgkinson
@LibLogic
Feb 16 2016 00:48 UTC
var fibs = [0, 1];
function sumFibs(num) {
    if ( num === 0 ) { return }
fibs.push(fibs[fibs.length-2] + fibs[fibs.length-1]);
    var fibTotals = fibs.filter(function(el){
        if ( el % 2 !== 0 ) { return true }
    }).reduce(function(all, item) {
        all += item;
        return all;
    });
console.log(fibTotals);
    sumFibs(num-1);
}

console.log(sumFibs(4));
Emanuel Quimper
@EQuimper
Feb 16 2016 00:48 UTC
@kaplejon what you have for now?
Lee Tratnyek
@kaplejon
Feb 16 2016 00:48 UTC
function queue(arr, item) {
  // Your code here
  arr = arr.push(item);
  item = arr.shift();
  return item;  // Change this line
}
Emanuel Quimper
@EQuimper
Feb 16 2016 00:49 UTC
@LibLogic which question ?
Tom Hodgkinson
@LibLogic
Feb 16 2016 00:49 UTC
I'd like to just return the final value
Casey Heath
@ExhibitArts
Feb 16 2016 00:49 UTC
If anyone is interested there is a HelpDesign room for feedback on Design :smile:
https://gitter.im/ExhibitArts/HelpDesign?utm_source=share-link&utm_medium=link&utm_campaign=share-link
Emanuel Quimper
@EQuimper
Feb 16 2016 00:49 UTC
bf stand
CamperBot
@camperbot
Feb 16 2016 00:49 UTC
Sorry, can't find a bonfire called stand. [ Check the map? ]
Emanuel Quimper
@EQuimper
Feb 16 2016 00:49 UTC
bf Stand In The Line
CamperBot
@camperbot
Feb 16 2016 00:49 UTC
Sorry, can't find a bonfire called stand in the line. [ Check the map? ]
Tom Hodgkinson
@LibLogic
Feb 16 2016 00:49 UTC
I get the right answer in the last iteration here
Alex N.
@N0bl3
Feb 16 2016 00:49 UTC
@EQuimper can you send me your code in private please? I'm doing something else at the same time. So that i can help you
Tom Hodgkinson
@LibLogic
Feb 16 2016 00:50 UTC
but I cant figure out how to return the answer on the last iteration
Lee Tratnyek
@kaplejon
Feb 16 2016 00:51 UTC
The error message I'm getting is: "TypeError: arr.shift is not a function."
Emanuel Quimper
@EQuimper
Feb 16 2016 00:51 UTC
@kaplejon you not far to the good answer but you need to have a other variable for call the shift
Lee Tratnyek
@kaplejon
Feb 16 2016 00:52 UTC
However, I've looked at the .shift function on MDN.
Brian
@sludge256
Feb 16 2016 00:52 UTC
@kaplejon It's because you're transforming your variable arr from an array into a number wtih this code
arr = arr.push(item);
Lee Tratnyek
@kaplejon
Feb 16 2016 00:52 UTC
@EQuimper Do you mean a local variable?
Emanuel Quimper
@EQuimper
Feb 16 2016 00:53 UTC
var singleItem;
  arr.push(item);
Brian
@sludge256
Feb 16 2016 00:53 UTC
.push() returns the length of the new array
Lee Tratnyek
@kaplejon
Feb 16 2016 00:53 UTC
Oh!
Okay, that makes sense.
Didn't realize .push() was returning the length.
Emanuel Quimper
@EQuimper
Feb 16 2016 00:53 UTC
and take the singleItem for singleItem=arr.shift()
Lee Tratnyek
@kaplejon
Feb 16 2016 00:54 UTC
Okay, bravo!
function queue(arr, item) {
  // Your code here
  arr.push(item);
  item = arr.shift();
  return item;  // Change this line
}
Now works!
Emanuel Quimper
@EQuimper
Feb 16 2016 00:55 UTC
yes goo job @kaplejon
Lee Tratnyek
@kaplejon
Feb 16 2016 00:55 UTC
Thanks @sludge256 and @EQuimper for your help.
CamperBot
@camperbot
Feb 16 2016 00:55 UTC
kaplejon sends brownie points to @sludge256 and @equimper :sparkles: :thumbsup: :sparkles:
:star: 260 | @equimper | http://www.freecodecamp.com/equimper
:star: 1494 | @sludge256 | http://www.freecodecamp.com/sludge256
Lee Tratnyek
@kaplejon
Feb 16 2016 00:56 UTC
I was still thinking in logic terms of doing a += operation, which didn't make sense since I was using a function with a return value, and instead storing that in my variable intended to hold an array.
Oh happy day!
Casey Heath
@ExhibitArts
Feb 16 2016 00:58 UTC
This message was deleted
Tom Hodgkinson
@LibLogic
Feb 16 2016 00:58 UTC
@EQuimper is my code beautiful if you ignore the fact that it doesn't work?? lol
Casey Heath
@ExhibitArts
Feb 16 2016 00:58 UTC
Emanuel Quimper
@EQuimper
Feb 16 2016 00:59 UTC
@LibLogic look good let me check more
Ari Winokur
@ariwinokur
Feb 16 2016 01:09 UTC
Working on "Using Objects for Lookups" and unless I am mistaken, there was never an explanation of lookups. Can someone point me in the right direction?
Emanuel Quimper
@EQuimper
Feb 16 2016 01:14 UTC
bf lookups
CamperBot
@camperbot
Feb 16 2016 01:14 UTC
Sorry, can't find a bonfire called lookups. [ Check the map? ]
Emanuel Quimper
@EQuimper
Feb 16 2016 01:14 UTC
bf Using Objects for Lookups
CamperBot
@camperbot
Feb 16 2016 01:14 UTC
Sorry, can't find a bonfire called using objects for lookups. [ Check the map? ]
Ari Winokur
@ariwinokur
Feb 16 2016 01:15 UTC
its a challenge, not a bonfire
Norman Dela Cruz
@dcnr
Feb 16 2016 01:15 UTC
@ariwinokur simplified explanation
var foo = {
  bar: "baz"
}
  1. Dot with literal property name
    var result = foo.bar;  //  result is baz
  2. Bracket with literal property name
    var result = foo["bar"]; // result is baz
  3. Bracket with variable property name
    var myProp = "bar";
    var result = foo[myProp]; // result is baz
Emanuel Quimper
@EQuimper
Feb 16 2016 01:15 UTC
yes I see
hellotojello
@hellotojello
Feb 16 2016 01:15 UTC
function repeat(str, num) {
  var stringLayout = console.log(str);
  if (num >= 0){
    return stringLayout * num;
  }
  // repeat after me
else{
  return "";
}
  }

repeat("abc", 3);
i need a hint
Emanuel Quimper
@EQuimper
Feb 16 2016 01:15 UTC
@ariwinokur just reed the example all you need his here
@ariwinokur tips when you gonna return you need to put [val]
Prithvi-A
@Prithvi-A
Feb 16 2016 01:16 UTC
This message was deleted
What is wrong with my code

var Car = function(wheels, seats, engines) {
//Change this constructor
this.wheels = 6;
this.seats = 3;
this.engines = 4;
};

//Try it out here
var myCar = new Car(4, 2, 2);

Emanuel Quimper
@EQuimper
Feb 16 2016 01:17 UTC
@Prithvi-A put your code into ``` plz
Prithvi-A
@Prithvi-A
Feb 16 2016 01:18 UTC
var Car = function(wheels, seats, engines) {
  //Change this constructor
  this.wheels = 6;
  this.seats = 3;
  this.engines = 4;
};

//Try it out here
var myCar = new Car(4, 2, 2);
Norman Dela Cruz
@dcnr
Feb 16 2016 01:18 UTC
@Prithvi-A you can edit your post by clicking the ... right of the timestamp, so you don't have to repost
Prithvi-A
@Prithvi-A
Feb 16 2016 01:19 UTC
fixed that
Norman Dela Cruz
@dcnr
Feb 16 2016 01:20 UTC
what exercise is that anyway
Ari Winokur
@ariwinokur
Feb 16 2016 01:20 UTC
@dcnr: so lookup is not actually used
^^^meaning the word lookup in the code
Norman Dela Cruz
@dcnr
Feb 16 2016 01:20 UTC
@ariwinokur well unless you make a variable named lookup I guess :P
Prithvi-A
@Prithvi-A
Feb 16 2016 01:20 UTC
Make Unique Objects by Passing Parameters to our Constructor
Emanuel Quimper
@EQuimper
Feb 16 2016 01:22 UTC
@Prithvi-A you nee to pass your argument into each of variables cause now what you passign is 4 6 2 3 2 4
Ari Winokur
@ariwinokur
Feb 16 2016 01:22 UTC
Well put @dcnr
Emanuel Quimper
@EQuimper
Feb 16 2016 01:22 UTC
@Prithvi-A example this.wheels = wheels
etc
Norman Dela Cruz
@dcnr
Feb 16 2016 01:23 UTC
@Prithvi-A you'll need to modify the car constructor function like what @EQuimper said :point_up: February 16, 2016 9:22 AM
Tom Hodgkinson
@LibLogic
Feb 16 2016 01:23 UTC
Anybody here good at recursive functions?
Ari Winokur
@ariwinokur
Feb 16 2016 01:24 UTC
@dcnr how would that work in my challenge? http://www.freecodecamp.com/challenges/using-objects-for-lookups
Norman Dela Cruz
@dcnr
Feb 16 2016 01:24 UTC
@ariwinokur read and understand the directions carefully, it's practically laid out for you :P
Alex N.
@N0bl3
Feb 16 2016 01:24 UTC
@LibLogic send your code, i like these problems :)
Tom Hodgkinson
@LibLogic
Feb 16 2016 01:25 UTC
@N0bl3 thanks
CamperBot
@camperbot
Feb 16 2016 01:25 UTC
liblogic sends brownie points to @n0bl3 :sparkles: :thumbsup: :sparkles:
:star: 157 | @n0bl3 | http://www.freecodecamp.com/n0bl3
Tom Hodgkinson
@LibLogic
Feb 16 2016 01:25 UTC
send it in private?
Emanuel Quimper
@EQuimper
Feb 16 2016 01:25 UTC
sry @LibLogic wasn't in this right now still just start
Alex N.
@N0bl3
Feb 16 2016 01:25 UTC
@LibLogic send it here , with before it and after it
Emanuel Quimper
@EQuimper
Feb 16 2016 01:26 UTC
@LibLogic that's why I don't answer
Tom Hodgkinson
@LibLogic
Feb 16 2016 01:27 UTC
This message was deleted
var fibs = [0, 1];
function sumFibs(num) {
    if ( num === 0 ) { return }
    fibs.push(fibs[fibs.length - 2] + fibs[fibs.length - 1]);
        var fibTotals = fibs.filter(function (el) {
            if (el % 2 !== 0) {
                return true
            }
        }).reduce(function (all, item) {
            all += item;
            return all;
        });
    console.log(fibTotals);
    sumFibs(num-1);
}

console.log(sumFibs(9));
I appreciate your help guys...hate to give up on this
Alex N.
@N0bl3
Feb 16 2016 01:33 UTC
@LibLogic Let's continue here :)
Ari Winokur
@ariwinokur
Feb 16 2016 01:34 UTC
@dcnr I got it finally, but the explanation was really lacking!
Alex N.
@N0bl3
Feb 16 2016 01:35 UTC
@LibLogic the problem is the way you organize your code with return statements. return breaks the sumFibs() in a way that having fibTotals variable doesn't make sense
@LibLogic to put you on the tracks, you should reorganize everything and do something like return sumFibs(num-1)
i know i always give the docs to read but these are a great way to imrove as even professionals may find new things there
Tom Hodgkinson
@LibLogic
Feb 16 2016 01:38 UTC
ok I will try reading up
Alex N.
@N0bl3
Feb 16 2016 01:38 UTC
in short: docs are LIFE :+1:
Tom Hodgkinson
@LibLogic
Feb 16 2016 01:38 UTC
I thought I understood return though..lol
Alex N.
@N0bl3
Feb 16 2016 01:40 UTC
@LibLogic have a look at a JSFiddle i did to understand recursion better (https://jsfiddle.net/Sp3cialK/mq17nhu5/)
Tom Hodgkinson
@LibLogic
Feb 16 2016 01:41 UTC
@N0bl3 thanks I'll look at that first...since I think I am using recursion wrong (I think)
CamperBot
@camperbot
Feb 16 2016 01:41 UTC
liblogic sends brownie points to @n0bl3 :sparkles: :thumbsup: :sparkles:
:warning: liblogic already gave n0bl3 points
Alex N.
@N0bl3
Feb 16 2016 01:41 UTC
@LibLogic yes it looks like you know about retun nd it is more a recursion problem :)
Tom Hodgkinson
@LibLogic
Feb 16 2016 01:42 UTC
ahh TY :)
Norman Dela Cruz
@dcnr
Feb 16 2016 01:45 UTC
@ariwinokur yeah most of the "lessons" here will be like that, you will have to do other searches about topics new to you
Mafalda
@otmeek
Feb 16 2016 01:47 UTC
i swear the advanced algorithms section starts out with the hardest exercises and then move on to much easier ones
i was struggling so hard with the first few ones
Stephen Antony
@Stephen-antony
Feb 16 2016 01:53 UTC
hello
Francisco Darré
@frandarre
Feb 16 2016 01:54 UTC
Docs love us as much as we love them?
Stephen Antony
@Stephen-antony
Feb 16 2016 01:55 UTC

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(var i=0;i<arr.length;i++) {

for(var j=0;j<arr[i].lenght;j++)
{
    product*=arr[i][j];
}   

}

// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Having trouble with this code

Norman Dela Cruz
@dcnr
Feb 16 2016 02:00 UTC
@otmeek the later ones used to be called "upper-intermediate" so I guess they were a little easier
@otmeek they got merged into advanced
@Stephen-antony typo on arr[i].lenght
Alex Evans
@alex-evans
Feb 16 2016 02:02 UTC
Missing something on the "No repeats please" and struggling to see it. I know I'm not removing any of the repeats yet but currently just trying to get all permutations. I got some help from wiki help but trying to not fully rely on it. Anyone able to point me in the right direction on what I have to keep me moving forward. Appreciate any help but otherwise I'll call it a night and look at it again tomorrow morning.
var permArr = [];
var str = "";

function perm(curPos, usedSpot, builtStr) {
  if(builtStr.length == str.length) {
    permArr.push(builtStr);
  } else {
    for(i=0; i < str.length; i++) {
      if(usedSpot.indexOf(i) < 0) {
        builtStr += str[i];
        usedSpot.push(i);
        perm(i, usedSpot, builtStr);
        usedSpot.pop();
      }
    }
  }
}

function permAlone(chkStr) {
  str = chkStr;
  perm(0,[],"");
  return permArr;
}

permAlone('aab');
Ari Winokur
@ariwinokur
Feb 16 2016 02:03 UTC
What am I doing wrong with this challenge? Testing Objects for Properties?
and clearly markdown doesn't like me
Mafalda
@otmeek
Feb 16 2016 02:03 UTC
@dcnr that makes sense
Norman Dela Cruz
@dcnr
Feb 16 2016 02:04 UTC
@alcatrats I'll just assume you have the proper algo, but with the FCC editor, never use global vars because it won't reset for the other test cases.
Cian
@ciant
Feb 16 2016 02:04 UTC
@Stephen-antony I'm currently stuck on this same waypoint
Norman Dela Cruz
@dcnr
Feb 16 2016 02:04 UTC
@alcatrats and you'll only prolly past the first one
Alex Evans
@alex-evans
Feb 16 2016 02:05 UTC
Yep only getting 'aab' currently. So no var permArr and str?
Norman Dela Cruz
@dcnr
Feb 16 2016 02:08 UTC
@alcatrats it seems like you're just returning the permutation
@alcatrats and not the total number of permutations that has no consecutive characters
Alex Evans
@alex-evans
Feb 16 2016 02:10 UTC
Right, I was just first trying to figure out how to build an array of those permutations. After I have that array I was going to pull out any that had repeating letters.
Radha Krishna Kavuluru
@champrakri
Feb 16 2016 02:10 UTC
stuck on symmetric difference
Cian
@ciant
Feb 16 2016 02:11 UTC
This message was deleted
Alex Evans
@alex-evans
Feb 16 2016 02:11 UTC
I think I see where I can head with it. Going to let it sit overnight though and dive into it tomorrow. Appreciate the input @dcnr . Thanks.
CamperBot
@camperbot
Feb 16 2016 02:11 UTC
alcatrats sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 629 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 16 2016 02:11 UTC
@alcatrats aah I see, I actually didn't bother implementing my own perm function so I can't help you with that part, I'm sorry :P
Alex Evans
@alex-evans
Feb 16 2016 02:11 UTC
No worries
Norman Dela Cruz
@dcnr
Feb 16 2016 02:11 UTC
thanks too and good luck @alcatrats
CamperBot
@camperbot
Feb 16 2016 02:11 UTC
dcnr sends brownie points to @alcatrats :sparkles: :thumbsup: :sparkles:
:star: 309 | @alcatrats | http://www.freecodecamp.com/alcatrats
Stephen Antony
@Stephen-antony
Feb 16 2016 02:11 UTC
@dcnr i havent still figured out
Norman Dela Cruz
@dcnr
Feb 16 2016 02:12 UTC
@Stephen-antony your length is misspelled in your second for loop
Radha Krishna Kavuluru
@champrakri
Feb 16 2016 02:12 UTC

function diff(arr1, arr2) {
var newArr = [];
// Same, same; but different.
var check=0;
var indexlog=0;
for(var j=0;j<arr2.length;j++)
{
check=0;
for(var i=0;i<arr1.length;i++)
{
if(arr2[j]==arr1[i])
{
check=1;
}
}
if(check===0)
{
newArr[indexlog]=arr2[j];
indexlog++;
}
}
return newArr;
}

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);

Norman Dela Cruz
@dcnr
Feb 16 2016 02:12 UTC
@Stephen-antony it should be arr[i].length NOT arr[i].lenght
Stephen Antony
@Stephen-antony
Feb 16 2016 02:12 UTC
@dcnr lol thanks , i was thinking my code was dumb for a second
CamperBot
@camperbot
Feb 16 2016 02:12 UTC
stephen-antony sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 630 | @dcnr | http://www.freecodecamp.com/dcnr
Stephen Antony
@Stephen-antony
Feb 16 2016 02:13 UTC
damn it :{
Norman Dela Cruz
@dcnr
Feb 16 2016 02:14 UTC
@Stephen-antony eh? still getting errors?
Cian
@ciant
Feb 16 2016 02:14 UTC
@Stephen-antony That still doesn't work right? It passes test 1 but fails on the second 2. I had the exact same code
Stephen Antony
@Stephen-antony
Feb 16 2016 02:14 UTC
@ciant it's working for me now
Norman Dela Cruz
@dcnr
Feb 16 2016 02:14 UTC
oh
Stephen Antony
@Stephen-antony
Feb 16 2016 02:14 UTC
@dcnr nah , i got it done
Cian
@ciant
Feb 16 2016 02:14 UTC
okay let me compare again
Norman Dela Cruz
@dcnr
Feb 16 2016 02:15 UTC
@Stephen-antony awesome! sometimes, you'll have to reset/refresh though even though you have the right answer because of cache and stuff
Radha Krishna Kavuluru
@champrakri
Feb 16 2016 02:15 UTC
hello guys i am a starter, i have a little problem. When i copy my code here how can i get it in nice format?
Ari Winokur
@ariwinokur
Feb 16 2016 02:15 UTC
What am I doing wrong?
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp) === true) {
    return myObj.checkProp;
  } else {

  return "Not Found";
  }
}

// Test your code by modifying these values
checkObj("gift");
Greg D
@mosaic-greg
Feb 16 2016 02:16 UTC
\help
CamperBot
@camperbot
Feb 16 2016 02:16 UTC

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
  • Algorithm BONFIRENAME info on a Algorithm

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Moisés Man
@moigithub
Feb 16 2016 02:16 UTC
u using dot notation.. shoudl be brackets... @ariwinokur
Ari Winokur
@ariwinokur
Feb 16 2016 02:16 UTC
^^^Testing Objects for Properties
Greg D
@mosaic-greg
Feb 16 2016 02:16 UTC
find formatting
CamperBot
@camperbot
Feb 16 2016 02:16 UTC

find formatting

:zero: code formatting

Norman Dela Cruz
@dcnr
Feb 16 2016 02:16 UTC

@champrakri hi you will need to type three backticks (the key above tab, left of 1, and below esc) (shift + enter to make a new line) (paste your code) (shift + enter again) then three more backtics so it looks like this
```js

<your code pasted here>
```

Ari Winokur
@ariwinokur
Feb 16 2016 02:16 UTC
@moigithub which one? on the return nline?
Moisés Man
@moigithub
Feb 16 2016 02:17 UTC
yes
Ari Winokur
@ariwinokur
Feb 16 2016 02:17 UTC
Thanks @moigithub
CamperBot
@camperbot
Feb 16 2016 02:17 UTC
ariwinokur sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 612 | @moigithub | http://www.freecodecamp.com/moigithub
Ari Winokur
@ariwinokur
Feb 16 2016 02:17 UTC
Wondering why it matters there?
Moisés Man
@moigithub
Feb 16 2016 02:18 UTC
u only use dot notation if the name following the dot is a real property name
but chekcprop is a variable...
Radha Krishna Kavuluru
@champrakri
Feb 16 2016 02:18 UTC
I am a starter. I am stuck at symmetric difference. What's wrong in this code :) please help
function diff(arr1, arr2) {
  var newArr = [];
  // Same, same; but different.
 var check=0;
  var indexlog=0;
  for(var j=0;j<arr2.length;j++)
    {
      check=0;
    for(var i=0;i<arr1.length;i++)
      {
        if(arr2[j]==arr1[i])
          {
            check=1;
          }
      }
      if(check===0)
        {
          newArr[indexlog]=arr2[j];
          indexlog++;
        }
    }
  return newArr;
}

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Ari Winokur
@ariwinokur
Feb 16 2016 02:19 UTC
@moigithub so bracket is always used when variables are involved and dot when constants are involved?
Cian
@ciant
Feb 16 2016 02:19 UTC
Still unsure what I am doing wrong here in waypoint "nesting for loops"
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line

    for (var i=0; i<arr.length; i++) {
    for(var j=0; j<[i].length; j++){
      product*=arr[i][j];
    }
  }



  // Only change code above this line
  return product;
}
Stephen Antony
@Stephen-antony
Feb 16 2016 02:20 UTC

@ciant function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(var i=0;i<arr.length;i++) {

for(var j=0;j<arr[i].length;j++)
{
    product*=arr[i][j];
}   

}

// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Radha Krishna Kavuluru
@champrakri
Feb 16 2016 02:20 UTC
@ciant in the second for loop you have to use arr[i]
Moisés Man
@moigithub
Feb 16 2016 02:20 UTC
@ariwinokur if by "contants" u mean the object key/property name.. yes
Stephen Antony
@Stephen-antony
Feb 16 2016 02:21 UTC
@ciant arr[i].length
Moisés Man
@moigithub
Feb 16 2016 02:21 UTC
@ariwinokur but.. u can also use brackets when using property/keys.. but the difference . is u need to use quotes.... (if variables no quotes )
Cian
@ciant
Feb 16 2016 02:24 UTC
thanks @champrakri
CamperBot
@camperbot
Feb 16 2016 02:24 UTC
ciant sends brownie points to @champrakri :sparkles: :thumbsup: :sparkles:
:star: 3 | @champrakri | http://www.freecodecamp.com/champrakri
Ari Winokur
@ariwinokur
Feb 16 2016 02:25 UTC
@moigithub so in short: bracket notation is always safe (and of course you need to pay attention to quotes)
Moisés Man
@moigithub
Feb 16 2016 02:27 UTC
@ariwinokur yep :)
Ari Winokur
@ariwinokur
Feb 16 2016 02:29 UTC
Thanks @moigithub
CamperBot
@camperbot
Feb 16 2016 02:29 UTC
ariwinokur sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: ariwinokur already gave moigithub points
Kevin Myrick
@aphextwin234
Feb 16 2016 02:29 UTC
does anyone know how to make an onmouseover event contain a url?
Marisol C
@Mariisun
Feb 16 2016 02:29 UTC
can anyone help me on I am a "double quoted" string inside "double quotes"?
landtyler
@landtyler
Feb 16 2016 02:30 UTC
Hey I need help on weather app. I'm trying to pull info from JSON app and printing the data pulled. It's not showing up for me. Someone help me out? http://codepen.io/imtylerland/pen/yeZQVO
Marisol C
@Mariisun
Feb 16 2016 02:31 UTC
/copy code
landtyler
@landtyler
Feb 16 2016 02:31 UTC
Just the button, don't worry about the zip code text box
Marisol C
@Mariisun
Feb 16 2016 02:31 UTC

var myStr = "I am a \"double quoted\" string inside \"double quotes\";

my code for Escaping Literal Quotes in Strings

my X: Variable myStr should equal to ("I am a "double quoted" string inside "double quotes"").
console: syntaxError: Unexpected token ILLEGAL
Cian
@ciant
Feb 16 2016 02:33 UTC
You are missing your final double quote @Mariisun
var myStr = "I am a \"double quoted\" string inside \"double quotes\"";
Marisol C
@Mariisun
Feb 16 2016 02:34 UTC
GAH! thank you @ciant
Jason
@J-Pitt
Feb 16 2016 02:36 UTC
Hey everyone, I'm stuck on module 184, stand in line, the directions are a little confusing and I dont know what I'm doing wrong. "Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed."
'''
CamperBot
@camperbot
Feb 16 2016 02:36 UTC
:bulb: to format code use backticks! ``` more info
Alex N.
@N0bl3
Feb 16 2016 02:36 UTC
@Mariisun I'm Alex , nice to meet you double quoted string :+1:
Jason
@J-Pitt
Feb 16 2016 02:37 UTC
where the heck are the backticks haha
```
Alex N.
@N0bl3
Feb 16 2016 02:37 UTC
@J-Pitt just copy paste haha
Jason
@J-Pitt
Feb 16 2016 02:37 UTC

```function queue(arr, item) {
// Your code here
testArr.push(1);

return testArr.shift(0); // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr)); ```

well that didnt work haha
Moisés Man
@moigithub
Feb 16 2016 02:38 UTC
@landtyler $.getJSON("api.openweathermap.org/dat
add "http://"; or "https://"; to ur url
Alex N.
@N0bl3
Feb 16 2016 02:38 UTC
@J-Pitt you have to make a line break after ``` !
Jason
@J-Pitt
Feb 16 2016 02:39 UTC
function queue(arr, item) {
  // Your code here
testArr.push(1);

  return testArr.shift(0);  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Moisés Man
@moigithub
Feb 16 2016 02:39 UTC
@J-Pitt shift dont need argument values
Jason
@J-Pitt
Feb 16 2016 02:39 UTC
ahh ha!
Alex N.
@N0bl3
Feb 16 2016 02:39 UTC
:+1:
landtyler
@landtyler
Feb 16 2016 02:39 UTC
@moigithub thanks!
CamperBot
@camperbot
Feb 16 2016 02:39 UTC
landtyler sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 613 | @moigithub | http://www.freecodecamp.com/moigithub
Jason
@J-Pitt
Feb 16 2016 02:40 UTC
I was just trying to show the argument that got dropped
Alex N.
@N0bl3
Feb 16 2016 02:40 UTC
@landtyler next time have a look at your console, you would have sen it didnt push to a normal url
@J-Pitt it is the normal behaviour of this function then you dont need to pass it an argument (https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Array/shift)
Moisés Man
@moigithub
Feb 16 2016 02:41 UTC
@J-Pitt anlso u pushing value 1.. u should use the argument provided..
Jason
@J-Pitt
Feb 16 2016 02:42 UTC
Ok thanks, @moigithub @N0bl3 , I will give it another shot!
CamperBot
@camperbot
Feb 16 2016 02:42 UTC
j-pitt sends brownie points to @moigithub and @n0bl3 :sparkles: :thumbsup: :sparkles:
:star: 614 | @moigithub | http://www.freecodecamp.com/moigithub
:star: 160 | @n0bl3 | http://www.freecodecamp.com/n0bl3
Ari Winokur
@ariwinokur
Feb 16 2016 03:22 UTC
From Record Collection challenge:
Kendra Lyndon
@KendraLyndon
Feb 16 2016 03:22 UTC
Is anyone working on the Mutations bonfire?
Ari Winokur
@ariwinokur
Feb 16 2016 03:23 UTC
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) {

  if (value !== "" && prop !== "tracks") {
    collection[id][prop] = value;
  } else if (value !== "" && prop == "tracks") {
    collection[id].tracks.push(value);
  } else {
    collection[id].remove(prop);
  }

  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
^^^Record Collection challenge
something is wrong, but I'm not sure what
philipsiu
@philipsiu
Feb 16 2016 03:33 UTC
@ariwinokur I used the delete option for the last statement
xEpicDanielx
@xEpicDanielx
Feb 16 2016 03:35 UTC
Hey everyone! :)
Ari Winokur
@ariwinokur
Feb 16 2016 03:36 UTC
Thanks @philthyfill Can you help me with the difference
CamperBot
@camperbot
Feb 16 2016 03:36 UTC
ariwinokur sends brownie points to @philthyfill :sparkles: :thumbsup: :sparkles:
Ari Winokur
@ariwinokur
Feb 16 2016 03:36 UTC
?
CamperBot
@camperbot
Feb 16 2016 03:36 UTC
:warning: could not find receiver for philthyfill
Kendra Lyndon
@KendraLyndon
Feb 16 2016 03:36 UTC
Hi @xEpicDanielx !
xEpicDanielx
@xEpicDanielx
Feb 16 2016 03:36 UTC
I got about 15 minutes to kill! anyone need some help? :)
philipsiu
@philipsiu
Feb 16 2016 03:39 UTC
@ariwinokur I'm still new at this but I had a similar solution to your by rearranging the elseif statements.
@ariwinokur For the if/elseif statements, if the conditions come back true for the first statement, and you have a 'return', then that will be the end.
yoryosv
@yoryosv
Feb 16 2016 03:41 UTC
@ariwinokur first else if: what is "tracks"?
Ari Winokur
@ariwinokur
Feb 16 2016 03:46 UTC
@philthyfill I changed remove to delete but it didn't solve it
Kela
@kela7
Feb 16 2016 03:46 UTC
i need help on the counting cards problem
Chris Katzmann
@cwkatzmann
Feb 16 2016 03:47 UTC
var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.

singleVal = array.reduce(function(previousVal, currentVal) {
  return previousVal + currentVal;
}, 0);
Ari Winokur
@ariwinokur
Feb 16 2016 03:47 UTC
@yoryosv it is all from the Record Collection challenge
Moisés Man
@moigithub
Feb 16 2016 03:47 UTC
wrong syntax probably.. google "delete object"
Chris Katzmann
@cwkatzmann
Feb 16 2016 03:47 UTC
what is going wrong there^
Ari Winokur
@ariwinokur
Feb 16 2016 03:47 UTC
@kela7 That one took me a while, what code do you have so far?
Kela
@kela7
Feb 16 2016 03:47 UTC
im still learning how to write the if/else statements its just not sticking with me, so i am lost on how to do this problem
Chris Katzmann
@cwkatzmann
Feb 16 2016 03:47 UTC
the instructions were unclear
Moisés Man
@moigithub
Feb 16 2016 03:48 UTC
what it want u to do ? @cwkatzmann
Chris Katzmann
@cwkatzmann
Feb 16 2016 03:48 UTC
@kela7 thats a pretty hard one. I think I used switch statements for it.
Kela
@kela7
Feb 16 2016 03:48 UTC
if(card >= 2 && card <= 6){
return 5 + "Bet";
}else if(card >=7 && card <= 9){
return -count + "Hold";
}else{
return "Change Me";
} @ariwinokur
Chris Katzmann
@cwkatzmann
Feb 16 2016 03:48 UTC
@moigithub it's supposed to add all the elements of var array into one var singleVal
Kela
@kela7
Feb 16 2016 03:48 UTC
oh really? @cwkatzmann
Ari Winokur
@ariwinokur
Feb 16 2016 03:48 UTC
@kela7 I agree with @cwkatzmann that you should be using switch statements
Kela
@kela7
Feb 16 2016 03:49 UTC
i can pretty much understand switch statements its a bit easier to do rather than doing the if/else statements
ok i will try that
yoryosv
@yoryosv
Feb 16 2016 03:49 UTC
@ariwinokur yes, i know... i'm asking why are you using it like this in the else if statment.
philipsiu
@philipsiu
Feb 16 2016 03:49 UTC
@ariwinokur Try rearranging your last two elseif statements
Moisés Man
@moigithub
Feb 16 2016 03:49 UTC
@cwkatzmann thats all the code ?? or missing something.. can u paste all plz ?
Chris Katzmann
@cwkatzmann
Feb 16 2016 03:49 UTC
@kela7 you are supposed to create a count that is based on what cards are dealt, and if the count is over a certain number, you return the count and either "bet " or "hold"
@moigithub thats the whole code, I'm doing the .reduce method challenge
Kela
@kela7
Feb 16 2016 03:51 UTC
ok i will try this again
Okan
@Okandja
Feb 16 2016 03:51 UTC
hey
I'm doing a challenge about golfing , defining strings based on the relation between par and strokes
I'm having trouble defining the code for Hole in one, since it doesn't have a relation between par and strokes
Chris Katzmann
@cwkatzmann
Feb 16 2016 03:53 UTC
@moigithub It's possible I'm missing something but the instructions seem bad then
Okan
@Okandja
Feb 16 2016 03:54 UTC
function golfScore(par, strokes) {
// Only change code below this line
if (strokes <= par -2){
return "Eagle";
}
else if (strokes <= par -1){
return "Birdie";
}
else if (strokes <= par-0){
return "Par";
}
else if (strokes <= par +1 ){
return "Bogey";
}
else if (strokes <= par + 2){
return "Double Bogey";
}
else if (strokes >= par + 3){
return "Go Home!";
}
else if (1, par ) {
return "Hole-in-one!";
}
cannelflow
@cannelflow
Feb 16 2016 03:55 UTC
@Okandja you are missing condition for if(strokes==1)
Chris Katzmann
@cwkatzmann
Feb 16 2016 03:56 UTC
@cannelflow good call
Okan
@Okandja
Feb 16 2016 03:56 UTC
should that be at the top?
cannelflow
@cannelflow
Feb 16 2016 03:57 UTC
@Okandja yes your first condition @cwkatzmann :+1:
Chris Katzmann
@cwkatzmann
Feb 16 2016 03:57 UTC
your last else if statement doesnt make sense
cannelflow
@cannelflow
Feb 16 2016 03:57 UTC
@cwkatzmann is right
@Okandja
Okan
@Okandja
Feb 16 2016 03:58 UTC
yeah that was me trying anything, it's gone now
It worked, thank you so much @cannelflow and @cwkatzmann
CamperBot
@camperbot
Feb 16 2016 03:59 UTC
okandja sends brownie points to @cannelflow and @cwkatzmann :sparkles: :thumbsup: :sparkles:
:star: 804 | @cannelflow | http://www.freecodecamp.com/cannelflow
:star: 251 | @cwkatzmann | http://www.freecodecamp.com/cwkatzmann
Chris Katzmann
@cwkatzmann
Feb 16 2016 04:01 UTC
youre welcome
cannelflow
@cannelflow
Feb 16 2016 04:03 UTC
@Okandja :+1:
Ari Winokur
@ariwinokur
Feb 16 2016 04:04 UTC
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) {

  if (value !== "" && prop !== "tracks") {
    collection[id][prop] = value;
  } else if (value !== "" && prop == "tracks") {
    collection[id].tracks.push(value);
  } else if (value === "") {
    collection[id].delete(prop);
  }

  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
What am I doing wrong with the last condition?
philipsiu
@philipsiu
Feb 16 2016 04:05 UTC
@ariwinokur delete collection[id][prop];
Ari Winokur
@ariwinokur
Feb 16 2016 04:07 UTC
Thanks @philthyfill
CamperBot
@camperbot
Feb 16 2016 04:07 UTC
ariwinokur sends brownie points to @philthyfill :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for philthyfill
Ari Winokur
@ariwinokur
Feb 16 2016 04:07 UTC
not sure why I didn't realize that
Neeraj Lad
@neeraj-lad
Feb 16 2016 04:12 UTC
Hi there!
I am doing the Profile lookup challenge in Basic Javascript
Here is my code:
function lookUp(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++)
  {
    //console.log(contacts[i].firstName);
    if (contacts[i].firstName == firstName)
    {
      if (contacts[i].hasOwnProperty(prop))
        return (contacts[i][prop]);
      else
        return "No such property";
    }
    else
      return "No such contact";
  }
// Only change code above this line
}

// Change these values to test your function
lookUp("Sherlock", "address");
Laudron
@Laudron
Feb 16 2016 04:12 UTC
@neeraj-lad Alright, we have your code ... what is your question? :P
Neeraj Lad
@neeraj-lad
Feb 16 2016 04:13 UTC
My code only works for the first element in contacts.. it returns "No contact found" for others
:smile:
anthonygallina1
@anthonygallina1
Feb 16 2016 04:18 UTC
Only works for first name?
Laudron
@Laudron
Feb 16 2016 04:18 UTC

@neeraj-lad Your current code reads as:
(1) if this contact contacts[i] has the same first name as the firstName parameter then check for the wanted property
(2) Otherwise return "No such contact";

The issue is that as soon as contacts[i].firstName does not equal firstName your code returns, effectively stopping execution.

Neeraj Lad
@neeraj-lad
Feb 16 2016 04:19 UTC
@anthonygallina1 yes.. only for contacts0
@Laudron why?
anthonygallina1
@anthonygallina1
Feb 16 2016 04:19 UTC
Follow @Laudron he is leading you in the right direction
Neeraj Lad
@neeraj-lad
Feb 16 2016 04:20 UTC
@Laudron that should be the corrrect logic, right?
Laudron
@Laudron
Feb 16 2016 04:20 UTC
@neeraj-lad You should return No such contact when all contacts have been checked.
Currently you return No such contact as soon as if (contacts[i].firstName == firstName) is false

Basically your

return "No such contact";

Is in the wrong spot :P

Neeraj Lad
@neeraj-lad
Feb 16 2016 04:21 UTC
@Laudron .. aah.. yes.. got the bug :D Thanks! Will check it now!
CamperBot
@camperbot
Feb 16 2016 04:21 UTC
neeraj-lad sends brownie points to @laudron :sparkles: :thumbsup: :sparkles:
:star: 320 | @laudron | http://www.freecodecamp.com/laudron
Neeraj Lad
@neeraj-lad
Feb 16 2016 04:24 UTC
@Laudron Passed the challenge.. Thanks! (y)
CamperBot
@camperbot
Feb 16 2016 04:24 UTC
neeraj-lad sends brownie points to @laudron :sparkles: :thumbsup: :sparkles:
:warning: neeraj-lad already gave laudron points
Laudron
@Laudron
Feb 16 2016 04:25 UTC
@neeraj-lad Not a problem, you were on the right track to begin with :P
kiel barry
@kielbarry
Feb 16 2016 04:34 UTC
function where(arr, num) {
  // Find my place in this sorted array.
  arr.sort().map(
    function(val){
      if(val>num){
          return arr.indexOf(val-1);
      }                            
  });
}

where([40, 60], 50);
halp
Laudron
@Laudron
Feb 16 2016 04:35 UTC
@declanPaz What happens if val <= num? :P And what specifically do you want help with on that?
kiel barry
@kielbarry
Feb 16 2016 04:36 UTC
what i want to return is the index of the place where num is less than the next number, but higher than the place of the previous number (when passed an array of numbers)
"For example, where([1,2,3,4], 1.5) should return 1 because it is greater than 1 (index 0), but less than 2 (index 1)."
so if val <=num, do nothing and move to next value
Laudron
@Laudron
Feb 16 2016 04:38 UTC
@declanPaz Alright, first things first:
That return arr.indexOf(val-1); will only return a value if val - 1 exists in arr
Furthermore, return arr.indexOf(val-1); is inside of a .map(function(val) { }); which means that currently your function where(arr, num) does not return anything
kiel barry
@kielbarry
Feb 16 2016 04:39 UTC
thanks for response .... will take a min to think thrpugh it
i don't understand your second sentence
changed that line to "return arr.indexOf(val)-1;"
George Armstrong
@george-of-croton
Feb 16 2016 04:44 UTC
@wearenotgroot forgot to thank you last night.! i have now finished the javascript basics course! feels good :)
CamperBot
@camperbot
Feb 16 2016 04:44 UTC
george-of-croton sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 857 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
kiel barry
@kielbarry
Feb 16 2016 04:44 UTC
so, you're saying that the map function returns the result to the where function, but then the where doesn't know what to do with it?
n9exorcist
@n9exorcist
Feb 16 2016 04:44 UTC
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
{
"artist": "Billy",
"title": "Piano",
"release_year": 1972,
"formats": [
"C",
"8",
"L" ],
}
];
Whats wrong with the code? I am getting error in 12 and 13th line, saying missing semi colon.
kiel barry
@kielbarry
Feb 16 2016 04:44 UTC
@Laudron
n9exorcist
@n9exorcist
Feb 16 2016 04:44 UTC
challenge: "Introducing JavaScript Object Notation JSON"
rphares
@rphares
Feb 16 2016 04:45 UTC
you need a comma in between the two albums, @n9exorcist
kiel barry
@kielbarry
Feb 16 2016 04:45 UTC
@n9exorcist your two main objects aren't separated by comma
rphares
@rphares
Feb 16 2016 04:45 UTC
in between the two sets of {}
greg
@wearenotgroot
Feb 16 2016 04:45 UTC
@george-of-croton YW :smile:
@george-of-croton keep at it!
kiel barry
@kielbarry
Feb 16 2016 04:45 UTC
@Laudron so, you're saying that the map function returns the result to the where function, but then the where doesn't know what to do with it?
n9exorcist
@n9exorcist
Feb 16 2016 04:45 UTC
@rphares Thank you
CamperBot
@camperbot
Feb 16 2016 04:45 UTC
n9exorcist sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2799 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 16 2016 04:46 UTC
anytime~
Laudron
@Laudron
Feb 16 2016 04:46 UTC

@declanPaz About that:
The method .map( ) for arrays uses a "callback" function to create a new array that is modified by that function ...
For example:

var firstArr = [1, 4, 9];
var secondArr = firstArr.map(function(val) {
    return Math.sqrt(val);
});
// Now the secondArr = [1, 2, 3] and firstArr still = [1, 4, 9]

All this to say, the return statement inside of your map function is creating a new array, not returning a value from the function where(arr, num)

kiel barry
@kielbarry
Feb 16 2016 04:47 UTC
whats the name of that array?
Laudron
@Laudron
Feb 16 2016 04:48 UTC
@declanPaz Doesn't have one, it is temporary, you would have to assign it to a variable in order to access it by name:
var secondArr = firstArr.map(function(val) {
    return Math.sqrt(val);
});
kiel barry
@kielbarry
Feb 16 2016 04:48 UTC
ohhh so i need to save the result of map, i can't just call it
George Armstrong
@george-of-croton
Feb 16 2016 04:48 UTC

@Yuvraj1989 i think you should do it more like this

case 1 :
case 2:
case 3:
case 4:
case 5:
case 6:
 count++;
break;

then do that for the rest of the cards then use an if statement to determine if count is > 0 or =- 0 to return the current count and whether to bet or not

kiel barry
@kielbarry
Feb 16 2016 04:48 UTC
thanks @laudron ! very helpful
CamperBot
@camperbot
Feb 16 2016 04:48 UTC
declanpaz sends brownie points to @laudron :sparkles: :thumbsup: :sparkles:
:star: 321 | @laudron | http://www.freecodecamp.com/laudron
Laudron
@Laudron
Feb 16 2016 04:48 UTC
@declanPaz You can just call it, but you would need to use variables outside of the .map( ) method in order to obtain any results IF you do not "save" the results :D
Nahum T
@nahomtefera
Feb 16 2016 05:10 UTC
Hey!
I need some help trying to find the longest word
greg
@wearenotgroot
Feb 16 2016 05:11 UTC
@declanPaz tip! always read the return value of methods
Nahum T
@nahomtefera
Feb 16 2016 05:11 UTC


 function findLongestWord(str) {

  var strSep = str.split(" ");

  var lenWords = [];

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

       lenWords.push(strSep[i].length); 

       console.log(Math.max(lenWords));
   }
}

findLongestWord("The quick brown fox jumped over the lazy dog");
kiel barry
@kielbarry
Feb 16 2016 05:11 UTC
@wearenotgroot can you explain that a little?
Nahum T
@nahomtefera
Feb 16 2016 05:12 UTC
My function always gives me the length of the first word
greg
@wearenotgroot
Feb 16 2016 05:12 UTC
@declanPaz if you look at the docs it will say what the method returns
kiel barry
@kielbarry
Feb 16 2016 05:13 UTC
@nahomtefera i'm not the best, but i'd suggest assigning the length of the word to a max variable, and checking that variable to see if the next word length is bigger and should replace the variables value
greg
@wearenotgroot
Feb 16 2016 05:13 UTC
@declanPaz an exmple, array.push(item)------> will return the new length of the array
Nahum T
@nahomtefera
Feb 16 2016 05:14 UTC
@declanPaz hmmmmmm
i'm going to think about it :)
greg
@wearenotgroot
Feb 16 2016 05:14 UTC
@declanPaz or str.split() will return an array and so on
Andrea Nelson
@aerd
Feb 16 2016 05:14 UTC
function lookUp(firstName, prop){
// Only change code below this line
if (contacts.firstName === firstName && contacts.hasOwnProperty(prop) === true) {
return contacts[prop];
} else if (contacts.firstName != firstName) {
return "No such contact";
} else {
return "No such property";
}
greg
@wearenotgroot
Feb 16 2016 05:15 UTC
@declanPaz in your case the .map() returns an array of the results from the function you feed it
Andrea Nelson
@aerd
Feb 16 2016 05:15 UTC
Could someone point me in the right direction of where my code is wrong?
greg
@wearenotgroot
Feb 16 2016 05:15 UTC
@declanPaz so you need to capture that or else the result will just not what you are expecting
uriznik
@uriznik
Feb 16 2016 05:16 UTC
@aerd what does contacts.firstname refer to?
kiel barry
@kielbarry
Feb 16 2016 05:16 UTC
how to create a private convo with someone on here?
Andrea Nelson
@aerd
Feb 16 2016 05:16 UTC
which instance?
greg
@wearenotgroot
Feb 16 2016 05:17 UTC
@aerd remember .hasOwnProperty will return a boolean value so no need for comparison === true
rphares
@rphares
Feb 16 2016 05:17 UTC
you can either hover over their avatar, and click 'chat privately'
yoni chanowitz
@yonichanowitz
Feb 16 2016 05:17 UTC
thanks @SaintPeter
CamperBot
@camperbot
Feb 16 2016 05:17 UTC
yonichanowitz sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2497 | @saintpeter | http://www.freecodecamp.com/saintpeter
rphares
@rphares
Feb 16 2016 05:17 UTC
or type /query@username @declanPaz
Rex Schrader
@SaintPeter
Feb 16 2016 05:17 UTC
aobut @rphares
kiel barry
@kielbarry
Feb 16 2016 05:17 UTC
@rphares thanks
CamperBot
@camperbot
Feb 16 2016 05:17 UTC
declanpaz sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2800 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 16 2016 05:17 UTC
Anytime!
Rex Schrader
@SaintPeter
Feb 16 2016 05:17 UTC
@rphares Daaaaang
@rphares Nice amount of points there.
greg
@wearenotgroot
Feb 16 2016 05:18 UTC
@aerd hint! contacts is an array
rphares
@rphares
Feb 16 2016 05:18 UTC
lol, @SaintPeter
i could do the same to you, and just refer to the boards ;)
Nahum T
@nahomtefera
Feb 16 2016 05:19 UTC
After so many week I got the solution to finding the longest word!!!!
I'm so happy :D :D :D :D :D :D :D
kiel barry
@kielbarry
Feb 16 2016 05:19 UTC
post the code?
rphares
@rphares
Feb 16 2016 05:19 UTC
(but thanks, @SaintPeter ~)
CamperBot
@camperbot
Feb 16 2016 05:19 UTC
rphares sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2498 | @saintpeter | http://www.freecodecamp.com/saintpeter
Nahum T
@nahomtefera
Feb 16 2016 05:19 UTC
 function findLongestWord(str) {

  var strSep = str.split(" ");

  var lenWords = [];

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

       lenWords.push(strSep[i].length); 


   }

   return Math.max.apply(Math, lenWords);

}

findLongestWord("The quick brown fox jumped over the lazy dog");
:D
kiel barry
@kielbarry
Feb 16 2016 05:20 UTC
and now i have learned something new! gonna look up apply()
Nahum T
@nahomtefera
Feb 16 2016 05:20 UTC
I have to say the truth, I don't know very well why I had to use apply
But I definetelly want to know it now that it solved my issue :D

The apply function is used to call another function, with a given context and arguments, provided as an array. The min and max functions can take an arbitrary number of input arguments: Math.max(val1, val2, ..., valN)
greg
@wearenotgroot
Feb 16 2016 05:24 UTC
@nahomtefera you know you could just have had a variable that hold the current longest length of the items in the strSep
@nahomtefera those extra function calls are just not necessary, because you already loop through the strSep. But that just me, oh well :smile:
greg
@wearenotgroot
Feb 16 2016 05:30 UTC
@nahomtefera glad you learned .apply, anyways here is a simplier approach
 function findLongestWord(str) {

  var strSep = str.split(" ");

  var lenWords = 0;

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

       if(strSep[i].length > lenWords) //<------------test the current value of lenWords againts the current item's length, updates if the currents item's lenght is greater 
       {
             lenWords = strSep[i].length;
       }


   }

   return lenWords;

}
Andrea Nelson
@aerd
Feb 16 2016 05:33 UTC
still having issues.
function lookUp(firstName, prop){
// Only change code below this line
for (var x = 0; x < contacts.length; x++){
if (contacts[x].firstName === firstName && contacts.hasOwnProperty(prop)) {
for (var y = 0; y < contacts[x].length; y++) {
return contacts[x][y]; }
} else if (contacts[x].firstName != firstName) {
return "No such contact";
} else {
return "No such property";
}
}
greg
@wearenotgroot
Feb 16 2016 05:34 UTC
@aerd that second for loop is not necessay btw
Andrea Nelson
@aerd
Feb 16 2016 05:34 UTC
I cant get it to work with just one either.
greg
@wearenotgroot
Feb 16 2016 05:34 UTC
@aerd the first for loop helps you access the items/objects at a certain index
@aerd while the prop will help you access the property values inside the array item
Andrea Nelson
@aerd
Feb 16 2016 05:36 UTC
yep, not understanding.
greg
@wearenotgroot
Feb 16 2016 05:36 UTC
@aerd
for (var x = 0; x < contacts.length; x++){
if (contacts[x].firstName === firstName && contacts.hasOwnProperty(prop)) {
for (var y = 0; y < contacts[x].length; y++) { //<----------------------remove me
return contacts[x][y]; }
} else if (contacts[x].firstName != firstName) {   //<-----------reconsider this else if
return "No such contact";
} else {
return "No such property";
}
}
Nahum T
@nahomtefera
Feb 16 2016 05:37 UTC
@wearenotgroot thanks! :D :D that gives me a better perspective
CamperBot
@camperbot
Feb 16 2016 05:37 UTC
nahomtefera sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 858 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 16 2016 05:38 UTC
@nahomtefera :+1:
Andrea Nelson
@aerd
Feb 16 2016 05:38 UTC
I already removes that one. "no such contact" and "no such propery" are coming back fine, but I am not getting this portion: if (contacts[x].firstName === firstName && contacts.hasOwnProperty(prop)) {
return contacts[prop];
*removed
greg
@wearenotgroot
Feb 16 2016 05:39 UTC
@aerd it fine you are just not accessing it properly
@aerd should be contacts[x][prop]
@aerd remember the target value you are after is dependent on the property name which is store in prop parameter
Andrea Nelson
@aerd
Feb 16 2016 05:41 UTC
could you explain that? The instructions say return "value", but property is a level up?
(prop)
greg
@wearenotgroot
Feb 16 2016 05:41 UTC
@aerd ^
Andrea Nelson
@aerd
Feb 16 2016 05:42 UTC
Maybe I am not understanding the levels properly. Thanks for your help @wearenotgroot.
CamperBot
@camperbot
Feb 16 2016 05:42 UTC
aerd sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 859 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 16 2016 05:42 UTC
@aerd ok lets look at contacts
Andrea Nelson
@aerd
Feb 16 2016 05:43 UTC
This message was deleted
greg
@wearenotgroot
Feb 16 2016 05:43 UTC
@aerd here is contacts
contacts is an array that contains objects. to access the items on the array we use index(a for loop with index)
var contacts = [
    {
        "firstName": "Akira",               //<-------------------------will be access at index 0,  contacts[0], now to access the values of a given property let's say prop="likes", you just do contacts[0][prop]-------------> will give you  ["Pizza", "Coding", "Brownie Points"]
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    },
];
Andrea Nelson
@aerd
Feb 16 2016 05:43 UTC
This message was deleted
This message was deleted
for (var x = 0; x < contacts.length; x++) which this does?
greg
@wearenotgroot
Feb 16 2016 05:46 UTC
@aerd remember contacts[x].hasOwnProperty(prop) not contacts.hasOwnProperty(prop)
@aerd remember contacts is an array and not an object
Andrea Nelson
@aerd
Feb 16 2016 05:47 UTC
that just returns the first likes array
greg
@wearenotgroot
Feb 16 2016 05:47 UTC
@aerd you need to be testing the item inside it if a certain property exist
@aerd if you try ----------> contacts[0][prop] where prop = 'lastName' you will get Laine
Andrea Nelson
@aerd
Feb 16 2016 05:48 UTC
I am lost.
greg
@wearenotgroot
Feb 16 2016 05:50 UTC

@aerd what you did wrong was

contacts.hasOwnProperty(prop) //<--------tested the array itself for property prop instead of items in it

should do

contacts[x].hasOwnProperty(prop) //<----------------testing the item on index x for property prop

just like

contacts[x].firstName //<----this is equal to contacts[x]['firstName']
Andrea Nelson
@aerd
Feb 16 2016 05:52 UTC
I tried that already, it doesn't work.
greg
@wearenotgroot
Feb 16 2016 05:53 UTC
@aerd well this is the correct test
@aerd however
@aerd you are getting the wrong result because of the else if right after the if (contacts[x].firstName === firstName && contacts[x].hasOwnProperty(prop))
@aerd this guy
} else if (contacts[x].firstName != firstName) {   //<-----------reconsider this else if
return "No such contact"; //<------rememeber what return does to the function!!!!!!
@aerd think about what happens if the first if statement is false(meaning the firstName of contact at index x is not equal to fristName)?
Andrea Nelson
@aerd
Feb 16 2016 05:59 UTC
Then why are these coming back correct?
"Bob", "number" should return "No such contact"
"Akira", "address" should return "No such property"
greg
@wearenotgroot
Feb 16 2016 06:00 UTC
@aerd post you updated code
@aerd also try with "Harry"
@aerd and see what happens
Andrea Nelson
@aerd
Feb 16 2016 06:01 UTC
for (var x = 0; x < contacts.length; x++){
if (contacts[x].firstName === firstName && contacts[x].hasOwnProperty(prop)) {
return contacts[x][prop];
} else if (contacts[x].firstName != firstName) {
return "No such contact";
} else {
return "No such property";
}
}
greg
@wearenotgroot
Feb 16 2016 06:03 UTC
@aerd try the firstName "Harry" or "Sherlock"
if you try with ->lookUp("Akira", "likes");--->you get ------>["Pizza", "Coding", "Brownie Points"]
@aerd if you try a property that doesnt exist then it will return "No such property"

@aerd what is happening is the else if

} else if (contacts[x].firstName != firstName) {   //<-----------reconsider this else if
return "No such contact"; //<------rememeber what return does to the function!!!!!!

is returning "No such contact" too early!!!!!

@aerd it nevers goes through the entire contact list after comparing the firstName of the contact at index 0
@aerd so if you tried with "Harry" as firstName(we know that Harry exist) the test never gets to examine the next contact on the list
Andrea Nelson
@aerd
Feb 16 2016 06:09 UTC
I understand it's not going through the list. That doesn't help me.
greg
@wearenotgroot
Feb 16 2016 06:09 UTC
@aerd it will, because now you can fixed the problem
@aerd first step is always to identify what the problem is
@aerd then find the solution
Michael Aubrey
@mca62511
Feb 16 2016 06:12 UTC

function lookUp(firstName, prop){
// Only change code below this line
for (var i = 0; contacts[i]; i++) {
if (contacts[i].firstName === firstName && contacts[i][prop]) {
  return contacts[i][prop];
} else if (contacts[i].firstName === firstName && !contacts[i][prop]) {
  return "No such property";
}
}
return "No such contact";
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
This is my solution to the Profile Lookup lesson... and it works... but I'm not super confident, and I just want to check to make sure I did this in the best way possible.
greg
@wearenotgroot
Feb 16 2016 06:12 UTC
@mca62511 looks good
@mca62511 can be improve by restructuring the if statement to be more human readable and avoid redundant tests
Andrea Nelson
@aerd
Feb 16 2016 06:16 UTC
This guy's doesn't make sense to me either.
greg
@wearenotgroot
Feb 16 2016 06:16 UTC
@aerd how long have you been stuck on this one? if you been stuck on this for a while, maybe it's time to take a break and have a fresh look at the problem
uriznik
@uriznik
Feb 16 2016 06:16 UTC
@mca62511 it could fail if a contact had a boolean property set to false and it would think there is no property
greg
@wearenotgroot
Feb 16 2016 06:17 UTC
@mca62511 oh yeah always use .hasOwnPropety to test if a given property exist or not
Michael Aubrey
@mca62511
Feb 16 2016 06:18 UTC
Thanks @wearenotgroot and @uriznik -- I don't think I've been taught .hasOwnProperty yet. or I just don't remember it, but that is useful. I think the lesson wants me to do i < contacts.length for the loop and I thought I'd just be clever by doing contacts[i][prop]
CamperBot
@camperbot
Feb 16 2016 06:18 UTC
mca62511 sends brownie points to @wearenotgroot and @uriznik :sparkles: :thumbsup: :sparkles:
:star: 285 | @uriznik | http://www.freecodecamp.com/uriznik
greg
@wearenotgroot
Feb 16 2016 06:19 UTC
@mca62511 you have used .hasOwnProperty on the previous lessons
CamperBot
@camperbot
Feb 16 2016 06:19 UTC
api offline
Michael Aubrey
@mca62511
Feb 16 2016 06:20 UTC
I don't think what I said makes sense :P
okay, then I just don't remember it, thank you
so I'd use contacts[i].hasOwnProperty(prop) ?
greg
@wearenotgroot
Feb 16 2016 06:21 UTC
@mca62511 yes
Michael Aubrey
@mca62511
Feb 16 2016 06:21 UTC
would !contacts[i].hasOwnProperty(prop) also work for "not" basically?
uriznik
@uriznik
Feb 16 2016 06:23 UTC
yes
greg
@wearenotgroot
Feb 16 2016 06:23 UTC
@mca62511 here is the challenge title where you used .hasOwnProperty : Testing Objects for Properties
Michael Aubrey
@mca62511
Feb 16 2016 06:24 UTC
Oh, thanks! I wasn't doubting you though, just doubting my memory.
I appreciate you hunting that down.
greg
@wearenotgroot
Feb 16 2016 06:24 UTC
@mca62511 np just linking relevant items
Michael Aubrey
@mca62511
Feb 16 2016 06:31 UTC
Oh boy, Regular Expressions incoming. I'm scared. :worried:
I don't have any experience with regular expressions, I've just hear people talk about them like they're the boogie man.
Michael Aubrey
@mca62511
Feb 16 2016 06:37 UTC
Actually the concept itself doesn't seem hard to grasp or anything. I guess it just much be difficult to memorize different selectors and the like?
uriznik
@uriznik
Feb 16 2016 06:38 UTC
they can get complex and get overused when the base language doesn't have other means of parsing complicated text
Michael Aubrey
@mca62511
Feb 16 2016 06:39 UTC
Ah
rootbox
@rootbox
Feb 16 2016 06:42 UTC
hi guys
simonmcho
@simonmcho
Feb 16 2016 06:44 UTC
hello
i have a quick code question
function mutation(arr) {
  var firstEntry = arr[0].toLowerCase().split("");
  var secondEntry = arr[1].toLowerCase().split("");
  var searchResult = 0;

  for (var i in secondEntry) {
    if (firstEntry.indexOf(secondEntry[i]) > -1) {
        searchResult += 0;
        }
        else {
        searchResult += 1;
        }
    if (searchResult === 0) {
      return true;
    }
    else {
      return false;
    }
  }
}

mutation(["hello", "hey"]);
Michael Aubrey
@mca62511
Feb 16 2016 06:46 UTC
@uriznik Okay, thanks. They're scary again :P
CamperBot
@camperbot
Feb 16 2016 06:46 UTC
mca62511 sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles:
:warning: mca62511 already gave uriznik points
rootbox
@rootbox
Feb 16 2016 06:47 UTC
what's the brownie point?
sugarchuck
@sugarchuck
Feb 16 2016 06:51 UTC
function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes<=1) {
    return "Hole-in-one!"
  } else if (strokes<=par-2) {
    return "Eagle"
  } else if (strokes = par-1) {
    return "Birdie"
  } else if (strokes = par) {
    return "Par"
  } else if (strokes = par+1) {
    return "Bogey"
  } else if (strokes = par+2) {
    return "Double Bogey"
  } else if (strokes >= par+3) {
    return "Go Home!"
  }

  return "Change Me";
  // Only change code above this line
}

// Change these values to test
golfScore(4, 4);
what am i doing wrong?
uriznik
@uriznik
Feb 16 2016 06:53 UTC
@sugarchuck do you know any other programmins languages? testing for equality may be different than you're used to
sugarchuck
@sugarchuck
Feb 16 2016 06:53 UTC
no i dont
uriznik
@uriznik
Feb 16 2016 06:54 UTC
@sugarchuck does it mostly return 'birdie'?
kirbyedy
@kirbyedy
Feb 16 2016 06:55 UTC
= means assign, == means equal
sugarchuck
@sugarchuck
Feb 16 2016 06:55 UTC
yes
kirbyedy
@kirbyedy
Feb 16 2016 06:55 UTC
so whenever you used = you were asigning the value
which is not what you want... I think :)
sugarchuck
@sugarchuck
Feb 16 2016 06:56 UTC
@kirbyedy thanks!!! i used == and it passed
CamperBot
@camperbot
Feb 16 2016 06:56 UTC
sugarchuck sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 476 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
kirbyedy
@kirbyedy
Feb 16 2016 06:57 UTC
also this is a bit dodgy (strokes<=1)
because you cant really hit the hole in 0 can you ? :)
sugarchuck
@sugarchuck
Feb 16 2016 06:57 UTC
yeah. youre right
kirbyedy
@kirbyedy
Feb 16 2016 06:58 UTC
test your code, write 1 in the golfscore at the bottom, see what happens
uriznik
@uriznik
Feb 16 2016 07:00 UTC
there's also a difference between == and === (strict equality), so 4 == '4' is true but 4 === '4' is false
Andrea Nelson
@aerd
Feb 16 2016 07:01 UTC
can someone tell me if I am on the right track with my else if statement? I'm not going to be able to sleep till I get this. for (var x = 0; x < contacts.length; x++){
if (contacts[x].firstName === firstName && contacts[x].hasOwnProperty(prop)) {
return contacts[x][prop];
} else if (contacts[x].hasOwnProperty(prop) && contacts[x].firstName != firstName) {
return "No such contact";
} else {
return "No such property";
}
}
rphares
@rphares
Feb 16 2016 07:02 UTC
@rootbox
explain brownie
CamperBot
@camperbot
Feb 16 2016 07:03 UTC

:point_right: brownie points [wiki]

The number beside your picture on Free Code Camp tells you how many Brownie Points you have.

A user profile picture next to a with Brownie Points score

There are three ways you can get Brownie Points:

  1. Complete challenges - you get one point per challenge you complete
  2. Post relevant links on Camper News - you get 1 point for posting a link, and another point for each upvote your link gets
  3. Help other campers in chat - each time you help another camper and they thank you (by typing "thanks @yourname"), you will get a point

Brownie Points help you look like the kind of person who codes a lot, shares relevant links, and helps people.

They also add to your Streak.
:pencil: read more about brownie points on the FCC Wiki

rootbox
@rootbox
Feb 16 2016 07:04 UTC
@rphares thanks for helping me
CamperBot
@camperbot
Feb 16 2016 07:04 UTC
rootbox sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2802 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 16 2016 07:04 UTC
anytime! Happy coding~
uriznik
@uriznik
Feb 16 2016 07:05 UTC
@aerd first if statement looks correct but the others aren't
SuhasHosamani
@SuhasHosamani
Feb 16 2016 07:05 UTC

Hi All

```
function end(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
last = str.length - 1;
lastChar = str.substr(last, 1);
if(lastChar === target){
return true;
}else{
return false;
}

}

end("He has to give me a new name", "name");

kirbyedy
@kirbyedy
Feb 16 2016 07:06 UTC
:penguin: in the house, :wave:
bitgrower
@bitgrower
Feb 16 2016 07:06 UTC
hello @kirbyedy
SuhasHosamani
@SuhasHosamani
Feb 16 2016 07:06 UTC

Hi All

function end(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
 last = str.length - 1;
 lastChar = str.substr(last, 1);
  if(lastChar === target){
    return true;
  }else{
    return false;
  }

}

end("He has to give me a new name", "name");

how to check for word?? i did for character its working

kirbyedy
@kirbyedy
Feb 16 2016 07:06 UTC
hey, hi, did not see you there @bitgrower
rphares
@rphares
Feb 16 2016 07:07 UTC
Aw, thanks @kirbyedy ~
CamperBot
@camperbot
Feb 16 2016 07:07 UTC
rphares sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 477 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
rphares
@rphares
Feb 16 2016 07:07 UTC
I'm actually heading out now, but appreciate the greeting! :)
bitgrower
@bitgrower
Feb 16 2016 07:07 UTC
lurking ... pulling my hair out a bit on Exact Change & also, unaccountably, the tribute ...
Andrea Nelson
@aerd
Feb 16 2016 07:07 UTC
i know my else if is wrong. but, i don't know the right direction.
rphares
@rphares
Feb 16 2016 07:07 UTC
(hi and ttyl, @bitgrower ! :blush: )
Vinícius
@vinicius978
Feb 16 2016 07:07 UTC
How to Iterate over Arrays with map()?
kirbyedy
@kirbyedy
Feb 16 2016 07:08 UTC
oh crap, I saw those challenges at the end, they are scary :worried:
bitgrower
@bitgrower
Feb 16 2016 07:08 UTC

2 quarters of web design (over 10 years ago), does not prepare me for bootstrap ... LOL ...

Even though I used to make all kinds of cool sales pages in html/css ...

rphares
@rphares
Feb 16 2016 07:08 UTC
lol, @kirbyedy
kirbyedy
@kirbyedy
Feb 16 2016 07:08 UTC
lol
rphares
@rphares
Feb 16 2016 07:08 UTC
@vinicius978 , can you paste your code? I'm sure someone may be able to help you :blush:
bitgrower
@bitgrower
Feb 16 2016 07:09 UTC
have a good one, @rphares ... wait, I think I'm the one who should be leaving ... it's 11pm here ...
rphares
@rphares
Feb 16 2016 07:09 UTC
Eek-- rest well!
bitgrower
@bitgrower
Feb 16 2016 07:09 UTC
@vinicius978 -- what @rphares asked ... and...what are you trying to do ...
Vinícius
@vinicius978
Feb 16 2016 07:09 UTC
Sure, I'm going to paste
Kai Schoos
@kschoos
Feb 16 2016 07:09 UTC
o/
bitgrower
@bitgrower
Feb 16 2016 07:10 UTC
well I don't know which overseas you are at, but if you are in Europe, it's surely MUCH later(earlier)
SuhasHosamani
@SuhasHosamani
Feb 16 2016 07:10 UTC
Guys
bitgrower
@bitgrower
Feb 16 2016 07:10 UTC
@vinicius978 -- please follow @camperbot's instructions ...
explain format
CamperBot
@camperbot
Feb 16 2016 07:10 UTC

: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 and then press [shift + enter ⏎] (type js or html or css)

<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

budimanfix
@budimanfix
Feb 16 2016 07:10 UTC

@aerd this is work but still left two task : for (var i = 0; contacts[i]; i++){
if (contacts[i].firstName === firstName && contacts[i][prop]){
return contacts[i][prop];

} else if (contacts[i].firstName === contacts[i][prop]){
  return "no such property";
}
}

return "no such contact";
}

bitgrower
@bitgrower
Feb 16 2016 07:10 UTC
I should give a prize to the first person who follows those instructions EXACTLY ...
kirbyedy
@kirbyedy
Feb 16 2016 07:11 UTC
lol
exactly
maybe its a riddle
Abhishek Kumar
@abhishekKumar1
Feb 16 2016 07:11 UTC
haha
kirbyedy
@kirbyedy
Feb 16 2016 07:11 UTC
to see if you are a good material for programmer :D
bitgrower
@bitgrower
Feb 16 2016 07:12 UTC
@SuhasHosamani -- I recommend -- HIGHLY recommend -- you use console.log and look at intermediate values ... because I think you can figure this out without a HUGE amount of effort ... when you see the numbers, I think something might occur to you .. :)
Michael Aubrey
@mca62511
Feb 16 2016 07:12 UTC

Okay, so now I'm at Sort Arrays with .sort

I was able to complete the lesson, again, but this time I'm not sure if I really understand why or what is going on. This is what I ended up with to sort the array from largest to smallest.

var array = [1, 12, 21, 2];

// Only change code below this line.

array.sort(function(a, b) {
  return b - a;
});

The original had a - b, which made it go from smallest to largest, I changed it to b - a, and that switched it.

~~But why? I feel like I'm missing something. ~~

edit: figured it out, i think

Vinícius
@vinicius978
Feb 16 2016 07:12 UTC
var oldArray = [1,2,3,4,5];

var timesThree = oldArray.map(
  function()
{

      return oldArray += 3;

});
// Only change code below this line.

var newArray = oldArray;
Brian
@sludge256
Feb 16 2016 07:12 UTC
:dog:
dang I was too slow :(
bitgrower
@bitgrower
Feb 16 2016 07:12 UTC
@kirbyedy -- that thought has definitely occurred to me ...
hahahahahaha ...
Michael Aubrey
@mca62511
Feb 16 2016 07:13 UTC
I'll start reading this, but if anyone has an easy explanation let me know. http://www.w3schools.com/jsref/jsref_sort.asp
Vinícius
@vinicius978
Feb 16 2016 07:13 UTC
<The objective is to add 3 to every value of the oldArray>
budimanfix
@budimanfix
Feb 16 2016 07:13 UTC

@abhishekKumar1 what i miss here, two task left for this challnge : for (var i = 0; contacts[i]; i++){
if (contacts[i].firstName === firstName && contacts[i][prop]){
return contacts[i][prop];

} else if (contacts[i].firstName === contacts[i][prop]){
  return "no such property";
}
}

return "no such contact";
}

Andrea Nelson
@aerd
Feb 16 2016 07:14 UTC
@budimanfix what?
Vinícius
@vinicius978
Feb 16 2016 07:14 UTC
@budimanfix paste your whole code
@budimanfix in the for() your variable i should go from 0 to the length of the array contacts
Michael Aubrey
@mca62511
Feb 16 2016 07:15 UTC
Okay, got it. I understand it now from reading w3schools (I think).
bitgrower
@bitgrower
Feb 16 2016 07:15 UTC
@mca62511 -- basically, if the value is negative it does one thing, if it's positive it does another ...
budimanfix
@budimanfix
Feb 16 2016 07:15 UTC
@aerd only left two task : "Bob", "number" should return "No such contact"
"Akira", "address" should return "No such property"
SuhasHosamani
@SuhasHosamani
Feb 16 2016 07:16 UTC
@bitgrower yeh got the ans
function end(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  if(target.length > 1){
    targetLast = target.length;
     last = (str.length) - targetLast;
     lastChar = str.substr(last, targetLast);
  }else{
     last = str.length - 1;
     lastChar = str.substr(last, 1);
  }

  if(lastChar === target){
    return true;
  }else{
    return false;
  }

}

end("He has to give me a new name", "name");
bitgrower
@bitgrower
Feb 16 2016 07:16 UTC
so ... figure out which one it is ... whether, if it's negative, it swaps the 2 values or positive ... :)
SuhasHosamani
@SuhasHosamani
Feb 16 2016 07:16 UTC
:smile:
@bitgrower but not sure if thats the best way.....
uriznik
@uriznik
Feb 16 2016 07:16 UTC
@aerd you have a test for firstname match and has property is true, then you need one for firstname match and has property is false
bitgrower
@bitgrower
Feb 16 2016 07:16 UTC
EXCELLENT, @SuhasHosamani ... I knew you could get this one without help ... :)
budimanfix
@budimanfix
Feb 16 2016 07:17 UTC
@vinicius978 Example plz?
bitgrower
@bitgrower
Feb 16 2016 07:17 UTC
@SuhasHosamani -- you can almost always do things better ... FIRST get the code to work ... then worry about making better ...
Abhishek Kumar
@abhishekKumar1
Feb 16 2016 07:17 UTC
@budimanfix i can't understand your elseif condition what are you trying to compare?
bitgrower @bitgrower has written some challenges 2 or 3 times as she's learned more ... :)
kirbyedy
@kirbyedy
Feb 16 2016 07:18 UTC
the answer with 38 upvotes
bitgrower
@bitgrower
Feb 16 2016 07:18 UTC
there ARE some very brief solutions ... esp if you use ES6 ... :)
budimanfix
@budimanfix
Feb 16 2016 07:18 UTC
@abhishekKumar1 I just trying and and now only left two point on task : "Bob", "number" should return "No such contact"
"Akira", "address" should return "No such property"
SuhasHosamani
@SuhasHosamani
Feb 16 2016 07:19 UTC
@bitgrower koole :+1:
bitgrower
@bitgrower
Feb 16 2016 07:19 UTC
@vinicius978 -- you need to provide your callback function with a parameter ... that parameter will be used to iterate over the values in the array ...
I think there's an example ?!?
in the challenge description ... ?
Michael Aubrey
@mca62511
Feb 16 2016 07:20 UTC

@kirbyedy @bitgrower Thanks, I appreciate it, but I do think I have it now. The equation is what it uses to decide how to sort things. It passes two values from the array into a and b. It runs the equation, and based on whether or not it returns a negative or positive it sorts it as higher or lower in the array.

I'll take a look at that answer anyway just in case.

CamperBot
@camperbot
Feb 16 2016 07:20 UTC
mca62511 sends brownie points to @kirbyedy and @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 478 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
:star: 537 | @bitgrower | http://www.freecodecamp.com/bitgrower
Andrea Nelson
@aerd
Feb 16 2016 07:20 UTC
for (var x = 0; x < contacts.length; x++){
  if (contacts[x].firstName === firstName && contacts[x].hasOwnProperty(prop)) {
    return contacts[x][prop];
  } else if (contacts[x].firstName === firstName && !contacts[x][prop]) {
    return "No such contact";
  } else {
    return "No such property";
  }
}
?
budimanfix
@budimanfix
Feb 16 2016 07:21 UTC
@aerd that " !" dosn't work bro
bitgrower
@bitgrower
Feb 16 2016 07:23 UTC
awesome @mca62511 !
greg
@wearenotgroot
Feb 16 2016 07:24 UTC
@aerd read your private chat
budimanfix
@budimanfix
Feb 16 2016 07:24 UTC
@aerd erase that " ! "behind contacts and you gor 3 point right
bitgrower
@bitgrower
Feb 16 2016 07:27 UTC
@SuhasHosamani you could probably eliminate a few variables ... if you actually plot out some simple examples, as well, some other solutions may occur to you as well ... :)
Vinícius
@vinicius978
Feb 16 2016 07:42 UTC
@bitgrower @budimanfix the example is var timesFour = oldArray.map(function(val){ return val * 4; });
bitgrower
@bitgrower
Feb 16 2016 07:43 UTC
right, and, instead, you want to add 3 to each value, right ?
change 2 characters & you have the solution ... :)
Bryce Turner
@AbryceT
Feb 16 2016 07:44 UTC
@brainyfarm Unfortunately no. I am still completely stumped on it.
Ashley
@asberrie
Feb 16 2016 07:46 UTC
This message was deleted

ok, so I totally feel like I'm missing something. I'm working on Accessing Nested Arrays in JSON but keep getting the error "ReferenceError: Can't find the variable: type"
This is what I have so far:
```
// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];

// Only change code below this line

var secondTree = myPlants.type1.list1; // Change this line

Bryce Turner
@AbryceT
Feb 16 2016 07:48 UTC
So here we go again.. I have been stuck on this one for four days and getting no closer to a solution. The Record Collection...help?
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) {
  for (collection[id].prop.value;  value !=="";)
        if (collection.prop != "tracks" && collection[prop].hasOwnProperty(value)); 
     collection.id.prop = "";
  }else if (collection.prop = "tracks" && collection[value].hasOwnProperty(value));
     collection.push([value]);
  return collection;
}


// Alter values below to test your code
update(5439, "artist", "ABBA");
Ashley
@asberrie
Feb 16 2016 07:49 UTC

ok, so I totally feel like I'm missing something. I'm working on Accessing Nested Arrays in JSON but keep getting the error "ReferenceError: Can't find the variable: type"
This is what I have so far (the goal is: Retrieve the second tree from the variable myPlants using object dot and array bracket notation.):

// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

var secondTree = myPlants.type[1].list[1]; // Change this line

Any help would be greatly appreciated! Thanks :)

Kai Schoos
@kschoos
Feb 16 2016 07:50 UTC
@asberrie so... what's inside myPlants? Keep close track of the opening parans, brackets and what have yoiu
Ashley
@asberrie
Feb 16 2016 07:52 UTC
@skusku inside myPlants is two types of plants; flowers (at index 0) and trees (at index 1) - which is why I have what I have
or that's at least how I'm understanding it (which at this point may be wrong)
Kai Schoos
@kschoos
Feb 16 2016 07:54 UTC
what is myPlants, programatically speaking ? ( Object, Variable, Array...)
Michael Aubrey
@mca62511
Feb 16 2016 07:54 UTC
If I'm unsure about the appropriateness of my correct answer, is it kosher to post it here and ask as I've been doing? It's been instructive for me to receive feedback, but at the same time I don't know how appropriate it is since I'm basically posting answers.
Ashley
@asberrie
Feb 16 2016 07:54 UTC
i think it's an object (but really want to say an array)
Kai Schoos
@kschoos
Feb 16 2016 07:55 UTC
[ ] <- array {} <- object
theres more to it but thats one way to see it fast
Michael Aubrey
@mca62511
Feb 16 2016 07:56 UTC

For example, I just did Reverse a String.

I came up with this

function reverseString(str) {
  return str.split("").reverse().join("");
}
reverseString("hello");

And it passes. Just wondering if this is the right way to go about it. ...but if I keep asking questions like this then it is basically giving away answers.

Kai Schoos
@kschoos
Feb 16 2016 07:56 UTC
so myPlants is an .... of ... ? @asberrie
Yuvraj Adagale
@Yuvraj1989
Feb 16 2016 07:56 UTC
@asberrie var secondTree = myPlants1.list1;
try this
Ashley
@asberrie
Feb 16 2016 07:57 UTC
@skusku ok, so since it's got the [] after the assignment operator, it's an array
Kai Schoos
@kschoos
Feb 16 2016 07:57 UTC
right
Yuvraj Adagale
@Yuvraj1989
Feb 16 2016 07:57 UTC
@asberrie var secondTree = myPlants1.list1;
cannelflow
@cannelflow
Feb 16 2016 07:58 UTC
@Yuvraj1989 don't just throw answer
here
try to explain it first
Bryce Turner
@AbryceT
Feb 16 2016 07:58 UTC
Any help on the record collection?
Yuvraj Adagale
@Yuvraj1989
Feb 16 2016 07:58 UTC
@cannelflow okies
cannelflow
@cannelflow
Feb 16 2016 07:58 UTC
@Yuvraj1989 :+1:
Ashley
@asberrie
Feb 16 2016 07:58 UTC

ok, so the way to access data in an array is
arrayName[indexPosition], correct?

I don't understand @Yuvraj1989 's answer anyway, so trying to understand why that's different and correct

Kai Schoos
@kschoos
Feb 16 2016 07:59 UTC
@asberrie it's an array of 2 objects [{...},{...}] . An array has no properties, therefor you cant access it over properties but only over the index. So if you want the first object of the array you do myPlants[1]
Ashley
@asberrie
Feb 16 2016 07:59 UTC
BTW, thanks for everyone's help :)
Kai Schoos
@kschoos
Feb 16 2016 07:59 UTC
@asberrie exactly
Spencer Kuzara
@kodaxx
Feb 16 2016 08:00 UTC
@asberrie you are correct
Yuvraj Adagale
@Yuvraj1989
Feb 16 2016 08:00 UTC
@asberrie see inside myPlants there are two objects
Spencer Kuzara
@kodaxx
Feb 16 2016 08:00 UTC
@Yuvraj1989 you gotta let her work through it lol
Ashley
@asberrie
Feb 16 2016 08:01 UTC
I was wondering why there was no square brackets (they weren't showing up correctly at first here)
Kai Schoos
@kschoos
Feb 16 2016 08:01 UTC
yes ^^ gotta use the code thingy
Spencer Kuzara
@kodaxx
Feb 16 2016 08:01 UTC
Technically, coffee should be put inside the format
Thingy
Ashley
@asberrie
Feb 16 2016 08:01 UTC
ok, so it would be myPlants[1][1]?
Spencer Kuzara
@kodaxx
Feb 16 2016 08:01 UTC
Code*
Not coffee, but closely related lol
Kai Schoos
@kschoos
Feb 16 2016 08:02 UTC
@asberrie not quite, you are jumping some steps
cannelflow
@cannelflow
Feb 16 2016 08:02 UTC
@mca62511 yes it is good
uriznik
@uriznik
Feb 16 2016 08:02 UTC
@AbryceT check your private chat
Michael Aubrey
@mca62511
Feb 16 2016 08:02 UTC
@cannelflow thanks
CamperBot
@camperbot
Feb 16 2016 08:02 UTC
mca62511 sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
:star: 807 | @cannelflow | http://www.freecodecamp.com/cannelflow
Yuvraj Adagale
@Yuvraj1989
Feb 16 2016 08:02 UTC
@asberrie these two objects in array are also arrays
Spencer Kuzara
@kodaxx
Feb 16 2016 08:02 UTC
@asberrie why not try to return myPlants1
Kai Schoos
@kschoos
Feb 16 2016 08:02 UTC
nah, objects are objects and arrays are arrays @Yuvraj1989
Spencer Kuzara
@kodaxx
Feb 16 2016 08:03 UTC
And see what you get
Sorry, with the brackets of course
Kai Schoos
@kschoos
Feb 16 2016 08:03 UTC
good thought @kodaxx
Ashley
@asberrie
Feb 16 2016 08:03 UTC
oh! i finally get what @Yuvraj1989 was saying
first, get the item in the first array, then using dot notation, get the item from the nested array inside that
Yuvraj Adagale
@Yuvraj1989
Feb 16 2016 08:03 UTC
@asberrie exactly
Ashley
@asberrie
Feb 16 2016 08:04 UTC
Phew! Thank you again everyone! I appreciate it! :+1: @skusku @Yuvraj1989 @kodaxx
CamperBot
@camperbot
Feb 16 2016 08:04 UTC
asberrie sends brownie points to @skusku and @yuvraj1989 and @kodaxx :sparkles: :thumbsup: :sparkles:
:star: 222 | @yuvraj1989 | http://www.freecodecamp.com/yuvraj1989
:star: 340 | @skusku | http://www.freecodecamp.com/skusku
:star: 273 | @kodaxx | http://www.freecodecamp.com/kodaxx
Spencer Kuzara
@kodaxx
Feb 16 2016 08:04 UTC
@asberrie you can think of it that way, but what you are actually doing is accessing the first object in the array and then accessing that objects nth property
Ashley
@asberrie
Feb 16 2016 08:05 UTC
@kodaxx gotcha
Spencer Kuzara
@kodaxx
Feb 16 2016 08:05 UTC
It's not technically a nested array, but an array of objects. Those objects have properties that can be accessed as well
But whatever helps you understand the concept, I suppose you should use that lol
Kai Schoos
@kschoos
Feb 16 2016 08:06 UTC
@kodaxx not quite. access second entry in the array -> access property called list (which is an array) -> access second entry in list-array
Spencer Kuzara
@kodaxx
Feb 16 2016 08:06 UTC
@skusku ahh yes, thank you for the correction
CamperBot
@camperbot
Feb 16 2016 08:06 UTC
kodaxx sends brownie points to @skusku :sparkles: :thumbsup: :sparkles:
:star: 341 | @skusku | http://www.freecodecamp.com/skusku
Kai Schoos
@kschoos
Feb 16 2016 08:06 UTC
this must be the most friendly place in the entire internet ^
^*
Spencer Kuzara
@kodaxx
Feb 16 2016 08:07 UTC
Because of camperbot? Lol
Kai Schoos
@kschoos
Feb 16 2016 08:08 UTC
jk :)
Spencer Kuzara
@kodaxx
Feb 16 2016 08:08 UTC
Sending brownie points everywhere haha
Kai Schoos
@kschoos
Feb 16 2016 08:08 UTC
haha yeah :D
Spencer Kuzara
@kodaxx
Feb 16 2016 08:10 UTC
Returning things intermediately helped me understand what was happening, so I usually recommend it to others. When a piece of it clicks for them, I have them return it and see what it says. Usually it clicks what to do next without my help lol
Not that I'm a great teacher by any means. Sometimes my English is horrible
Kai Schoos
@kschoos
Feb 16 2016 08:10 UTC
@AbryceT still struggling ? You should maybe rethink what you want to do in that update function and what you are actually doing
@kodaxx your english is awesome :)
Spencer Kuzara
@kodaxx
Feb 16 2016 08:11 UTC
You really think so?
Kai Schoos
@kschoos
Feb 16 2016 08:12 UTC
yep
Spencer Kuzara
@kodaxx
Feb 16 2016 08:13 UTC
Thanks, I try!
I always forget to mention MDN. I think FCC should bring it to focus earlier in the program
I think they bring it about during the basic algorithm scripting, or before the basic front end projects.
But it should be much earlier in my opinion
Kai Schoos
@kschoos
Feb 16 2016 08:15 UTC
using google is a big thing :P so much good information out in the webs
Spencer Kuzara
@kodaxx
Feb 16 2016 08:15 UTC
Yes! One must be careful not to Google the exact answer, though. Lol
I mean in a very literal sense, "Free Code Camp Record Collection Challenge Answer" lol... That's a no no
Kai Schoos
@kschoos
Feb 16 2016 08:16 UTC
ah yeah haha
Spencer Kuzara
@kodaxx
Feb 16 2016 08:17 UTC
Then you will remember what your teachers have always told you, "You're only cheating yourself."
greg
@wearenotgroot
Feb 16 2016 08:23 UTC
@skusku yes always consult your docs
@skusku both in health and js
:smile:
Kai Schoos
@kschoos
Feb 16 2016 08:24 UTC
haha :D
Michael Aubrey
@mca62511
Feb 16 2016 08:27 UTC
This time I'm sure there's got to be a more elegant solution
function factorialize(num) {
  if (num < 0) { return "You cannot factorialize a negative number."; }
  var factors = [1];
  for (var i = 2; i <= num; i++) {
    factors.push(i);
  }
  num = factors.reduce(function(previousVal, currentVal) {
    return previousVal * currentVal;
  });
  return num;
}

factorialize(5);
kirbyedy
@kirbyedy
Feb 16 2016 08:32 UTC
I think I just initialised the variable to 1, then looped until num and each time multiplied it
greg
@wearenotgroot
Feb 16 2016 08:33 UTC
@mca62511 so sorry to bust your bubble again
@mca62511 but no need for that reduces :smile:
@mca62511 you can directly get the result on the for loop :+1:
JackeL
@jackel27
Feb 16 2016 08:34 UTC
Hi world!
CamperBot
@camperbot
Feb 16 2016 08:34 UTC

welcome to FreeCodeCamp @jackel27!

kirbyedy
@kirbyedy
Feb 16 2016 08:34 UTC
hi @jackel27
greg
@wearenotgroot
Feb 16 2016 08:34 UTC
@jackel27 Welcome!
JackeL
@jackel27
Feb 16 2016 08:34 UTC
Hi @kirbyedy
Question
what is the difference between a class and a constructor?
for example...
function Person(name,age) {
  this.name = name;
  this.age = age;
}
class... or constructor?
uriznik
@uriznik
Feb 16 2016 08:37 UTC
@mca62511 you're already doing a loop so might as well just compute it in their
greg
@wearenotgroot
Feb 16 2016 08:38 UTC
@jackel27 there really isnt a class in js per say
@jackel27 on other programming language like java and c# for instance
JackeL
@jackel27
Feb 16 2016 08:39 UTC
@wearenotgroot so confused why it even exists.. objects, classes, functions and constructors all seem to blend in...
greg
@wearenotgroot
Feb 16 2016 08:39 UTC
@jackel27 Person is considered a class
JackeL
@jackel27
Feb 16 2016 08:39 UTC
ok,
so between {} is the constructor @wearenotgroot ?
greg
@wearenotgroot
Feb 16 2016 08:39 UTC
@jackel27 and a class have a constructor inside
JackeL
@jackel27
Feb 16 2016 08:40 UTC
@wearenotgroot so with no constructor, its just a function/method?
greg
@wearenotgroot
Feb 16 2016 08:40 UTC
@jackel27 well in js there is no such thing as a class
@jackel27 so everything is just an object
greg
@wearenotgroot
Feb 16 2016 08:41 UTC
@jackel27 but in newer version of js the class keyword is introduce
JackeL
@jackel27
Feb 16 2016 08:41 UTC
@wearenotgroot okay, I'll keep that mind to get my brain mapped around this right...
@wearenotgroot ahhh.. explains mozilla then..
greg
@wearenotgroot
Feb 16 2016 08:41 UTC
@jackel27 to ease the creation of object that reresent class
@jackel27 and for the constructor it just a way to intiante/initialise variables
JackeL
@jackel27
Feb 16 2016 08:42 UTC
@wearenotgroot makes sense.. I'll just skip the new class declaration for now...
greg
@wearenotgroot
Feb 16 2016 08:42 UTC
@jackel27 :smile:
JackeL
@jackel27
Feb 16 2016 08:43 UTC
@wearenotgroot thanks. Trying to finish up codeacademy..
CamperBot
@camperbot
Feb 16 2016 08:43 UTC
jackel27 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 862 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
JackeL
@jackel27
Feb 16 2016 08:43 UTC
will be back here hopefully soon to finish up the rest. :)
greg
@wearenotgroot
Feb 16 2016 08:43 UTC
@jackel27 GL then
JackeL
@jackel27
Feb 16 2016 08:43 UTC
@wearenotgroot CodeAcademy is super buggy... I'll need the luck.
kirbyedy
@kirbyedy
Feb 16 2016 08:44 UTC
@jackel27 what exactly on codecademy ?
JackeL
@jackel27
Feb 16 2016 08:45 UTC
@kirbyedy well, finished html, jquery, about 95% on JS, then need to finish AngularJS, Ruby, Ruby on Rails, Rails Authentication
JackeL
@jackel27
Feb 16 2016 08:56 UTC
@kirbyedy buggy between browsers, chrome and IE switching every so often to pass some challenges
DanishKalim
@DanishKalim
Feb 16 2016 08:56 UTC
oldArray

var oldArray = [1,2,3,4,5];

// Only change code below this line.
var timesThree = oldArray.map(function(oldArray){
return oldArray + 3;
});
var newArray = oldArray;

You should add three to each value in the array.
plz help
JackeL
@jackel27
Feb 16 2016 09:01 UTC
@DanishKalim I do not think you are adding 3 to each array property
Vinícius
@vinicius978
Feb 16 2016 09:03 UTC
@DanishKalim I'm stuck on the same problem
JackeL
@jackel27
Feb 16 2016 09:03 UTC
@DanishKalim return oldArray + 3 I do not think is correct.
Vinícius
@vinicius978
Feb 16 2016 09:03 UTC
What is wrong here?
uriznik
@uriznik
Feb 16 2016 09:04 UTC
@DanishKalim map doesn't modify the original array
Vinícius
@vinicius978
Feb 16 2016 09:04 UTC
var oldArray = [1,2,3,4,5];

var addThree = oldArray.map(
  function(oldArray)
{

        return oldArray + 3;

});


var newArray = oldArray;
lol nevermind
JackeL
@jackel27
Feb 16 2016 09:05 UTC
for each iteration of the array, you return oldArray +3.
try to have a seperate line outside your function/map and output return(oldArray +3); What do you get?
Vinícius
@vinicius978
Feb 16 2016 09:05 UTC
the problem was the var newArray = addThree; and not var newArray = oldArray;
JackeL
@jackel27
Feb 16 2016 09:05 UTC
hmm
Vinícius
@vinicius978
Feb 16 2016 09:06 UTC
because map() doesn't change the original array
JackeL
@jackel27
Feb 16 2016 09:06 UTC
right
uriznik
@uriznik
Feb 16 2016 09:06 UTC
using oldArray as the function variable name will work but is confusing
Vinícius
@vinicius978
Feb 16 2016 09:06 UTC
he only change a new array
thanks anyway guys ;)
Des Dulianto
@desdulianto
Feb 16 2016 09:08 UTC
i am kind of confused trying to solve ceaser rot 13
-7 mod 26 suppose to be 17 or -9?
uriznik
@uriznik
Feb 16 2016 09:10 UTC
you could add 13 instead of subtract 13 to avoid negative numbers?
DanishKalim
@DanishKalim
Feb 16 2016 09:11 UTC
thanks @jackel27 and @vinicius978
CamperBot
@camperbot
Feb 16 2016 09:11 UTC
danishkalim sends brownie points to @jackel27 and @vinicius978 :sparkles: :thumbsup: :sparkles:
:star: 315 | @jackel27 | http://www.freecodecamp.com/jackel27
:star: 241 | @vinicius978 | http://www.freecodecamp.com/vinicius978
Des Dulianto
@desdulianto
Feb 16 2016 09:11 UTC
my logic is that for each char convert to ascii code then substract 65, so the number would be 0-25, the subtact that with 13 and then modulo 26 to get the alfabet position (A = 0, B = 1 and so on) and then add to 65
JackeL
@jackel27
Feb 16 2016 09:12 UTC
@desdulianto
Plain:   ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher:  XYZABCDEFGHIJKLMNOPQRSTUVW
Des Dulianto
@desdulianto
Feb 16 2016 09:12 UTC
var c = str.charCodeAt(i);
if (c >= 65 && c <= 90) {
  c = c - 65;
  c = 65 + ((c-13) % 26);
} 
that code run perfectly on python ^^"
i check if c is 69 then 69-65 is 4 then substract 13 is -9
uriznik
@uriznik
Feb 16 2016 09:13 UTC
% isn't the same as mod
Des Dulianto
@desdulianto
Feb 16 2016 09:13 UTC
oh
uriznik
@uriznik
Feb 16 2016 09:14 UTC
so you get different behaviour with negative numbers (can't remember exact algo), but if you keep it positive it should behave as expected
Des Dulianto
@desdulianto
Feb 16 2016 09:15 UTC
yup
haha thanks @uriznik
CamperBot
@camperbot
Feb 16 2016 09:15 UTC
desdulianto sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles:
:star: 288 | @uriznik | http://www.freecodecamp.com/uriznik
DanishKalim
@DanishKalim
Feb 16 2016 09:17 UTC

var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.
var singleVal = array.reduce(function(previousVal, currentVal){

  return previousVal+currentVal;

});
singleVal = array;

plz bhelp

singleVal should be equal to the sum of all items in the array variable.
Abhishek Kumar
@abhishekKumar1
Feb 16 2016 09:18 UTC
remove singleVal=array;
and return singleVal
by the way help format
help format
CamperBot
@camperbot
Feb 16 2016 09:19 UTC

: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 and then press [shift + enter ⏎] (type js or html or css)

<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

DanishKalim
@DanishKalim
Feb 16 2016 09:19 UTC
@abhishekKumar1 thanks
CamperBot
@camperbot
Feb 16 2016 09:19 UTC
danishkalim sends brownie points to @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
:star: 334 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
Aharon Hyman
@nachamuami
Feb 16 2016 09:20 UTC
hi people can somebody please help me with
Testing Objects for Properties
I am not sure how what it is asking me to do
kirbyedy
@kirbyedy
Feb 16 2016 09:24 UTC
@nachamuami you should check if the property inside your object exist and return it, otherwise you have to return not found
DanishKalim
@DanishKalim
Feb 16 2016 09:25 UTC

var array = [1,2,3,4,5,6,7,8,9,10];
// Only change code below this line.
array = array.filter(function(val) {
return val >= 5;
});

plz help

You should have filtered out all values from the array that are greater than 5.
Robert Uivarosi
@URobert
Feb 16 2016 09:26 UTC
@DanishKalim try <= 5 or < 6:)
Yuvraj Adagale
@Yuvraj1989
Feb 16 2016 09:26 UTC
@DanishKalim you have written val>=6
Robert Uivarosi
@URobert
Feb 16 2016 09:27 UTC
@DanishKalim you filterd out the wrong numbers
Yuvraj Adagale
@Yuvraj1989
Feb 16 2016 09:27 UTC
sorry val>=5
it should be val>5
@DanishKalim
DanishKalim
@DanishKalim
Feb 16 2016 09:28 UTC

var array = [1,2,3,4,5,6,7,8,9,10];
// Only change code below this line.
array = array.filter(function(val) {
return val >5;
});

not working

Robert Uivarosi
@URobert
Feb 16 2016 09:29 UTC
@DanishKalim see my answer from above
DanishKalim
@DanishKalim
Feb 16 2016 09:30 UTC

var array = [1,2,3,4,5,6,7,8,9,10];
// Only change code below this line.
array = array.filter(function(val) {
return val <=5;
});

not working @URobert

Marko Nikic
@MarkoN95
Feb 16 2016 09:31 UTC
Symmetric Difference
Bonfire: Symetric Difference
CamperBot
@camperbot
Feb 16 2016 09:31 UTC
Sorry, can't find a bonfire called symetric difference. [ Check the map? ]
Robert Uivarosi
@URobert
Feb 16 2016 09:31 UTC
@DanishKalim wasn't this: var array = [1,2,3,4,5,6,7,8,9,10]; called oldArray ?
Marko Nikic
@MarkoN95
Feb 16 2016 09:31 UTC
Bonfire: Symmetric Difference
CamperBot
@camperbot
Feb 16 2016 09:31 UTC

:fire:Bonfire: Symmetric Difference :link:

function sym(args) {
  return arguments;
}

sym([1, 2, 3], [5, 2, 1, 4]);

Create a function that takes two or more arrays and returns an array of the symmetric difference of the provided arrays.

more info:  bf details | bf links | hint

Marko Nikic
@MarkoN95
Feb 16 2016 09:32 UTC
hint
CamperBot
@camperbot
Feb 16 2016 09:32 UTC
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Robert Uivarosi
@URobert
Feb 16 2016 09:32 UTC
@DanishKalim looks like you've changed some parts of the code that you shouldn't
@DanishKalim link me your code
DanishKalim
@DanishKalim
Feb 16 2016 09:36 UTC

var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.
array = oldarray.filter(function(val) {
return val <= 5;
});
var newArray = oldArray;

Abhishek Kumar
@abhishekKumar1
Feb 16 2016 09:38 UTC
@DanishKalim try newarray = oldarray.filter(function(val) {
return val <= 5;
});
and then return newArray not equate it to oldArray
DanishKalim
@DanishKalim
Feb 16 2016 09:40 UTC

var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.
newarray = oldarray.filter(function(val) {
return val <= 5;
});
return newArray ;

not working
Abhishek Kumar
@abhishekKumar1
Feb 16 2016 09:41 UTC
your variable are changing names it should be newArray and oldArray in the filter line\
DanishKalim
@DanishKalim
Feb 16 2016 09:43 UTC
not working @abhishekKumar1
Codemzy
@codemzy
Feb 16 2016 09:44 UTC
@DanishKalim try
var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.
var newArray = oldArray.filter(function(val) {
  return val <= 5;
});
return newArray ;
lion
@lihe6666
Feb 16 2016 09:44 UTC
good
Codemzy
@codemzy
Feb 16 2016 09:47 UTC
@DanishKalim your trying to filter out any values over 5 yeah?
DanishKalim
@DanishKalim
Feb 16 2016 09:47 UTC
yup
Codemzy
@codemzy
Feb 16 2016 09:48 UTC
@DanishKalim yeah the above code I pasted will work
@DanishKalim I just tested it in the console
DanishKalim
@DanishKalim
Feb 16 2016 09:51 UTC

var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.
var newArray = oldArray.filter(function(val) {
return val <= 5;
});
return newArray ;

You should have filtered out all values from the array that are greater than 5.
You should be using the filter method to remove the values from the array.

@codemzy not working
Codemzy
@codemzy
Feb 16 2016 09:52 UTC
@DanishKalim what is the challenge called?
DanishKalim
@DanishKalim
Feb 16 2016 09:53 UTC
filter array with filter
Codemzy
@codemzy
Feb 16 2016 09:54 UTC
@DanishKalim maybe it wants you to do it a certain way? try...
var oldArray = [1,2,3,4,5,6,7,8,9,10];
// Only change code below this line.
oldArray.filter(function(val) {
  return val <= 5;
});
return oldArray;
@DanishKalim its because you have changed the code above the line where it says only change code below this line... it should be ...
var array = [1,2,3,4,5,6,7,8,9,10];
  // Only change code below this line.

array = array.filter(function(val){
  return val <= 5;
});

  // Only change code above this line.
(function() {return array;})();
Goh Hong Yi
@hong-yi
Feb 16 2016 09:56 UTC
function toDestroy(value) {
  return value == arguments[1] || value == arguments[2];
}

function destroyer(arr) {
  // Remove all the values
  var filtered = arguments[0].filter(toDestroy);
  return filtered;
}


destroyer([1, 2, 3, 1, 2, 3], 2, 3);
can I know why this doesn't work?
Codemzy
@codemzy
Feb 16 2016 09:58 UTC
@hong-yi I think because your only allowing for there to be three arguments, but there may be more. So you would be better to loop through the arguments starting at [1] and loop through to the end of arguments.length for your 'toDestroy' function
Goh Hong Yi
@hong-yi
Feb 16 2016 09:59 UTC
doesn't it loop through each element itself?
Nicky
@nickyjt16
Feb 16 2016 09:59 UTC
how do i copy and paste my code into here? I've sone the normal way, but it doesnt show the formatting. Might as well ask the stupid questions first
Codemzy
@codemzy
Feb 16 2016 09:59 UTC
wiki format
CamperBot
@camperbot
Feb 16 2016 09:59 UTC

: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 and then press [shift + enter ⏎] (type js or html or css)

<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

Codemzy
@codemzy
Feb 16 2016 09:59 UTC
@nickyjt16 see above
Goh Hong Yi
@hong-yi
Feb 16 2016 10:00 UTC
function isBigEnough(value) {
  return value >= 10;
}
var filtered = [12, 5, 8, 130, 44].filter(isBigEnough);
// filtered is [12, 130, 44]
at least i looked at this example and thought it would loop through each element
Nicky
@nickyjt16
Feb 16 2016 10:00 UTC
@codemzy thanks
CamperBot
@camperbot
Feb 16 2016 10:00 UTC
nickyjt16 sends brownie points to @codemzy :sparkles: :thumbsup: :sparkles:
:star: 607 | @codemzy | http://www.freecodecamp.com/codemzy
Codemzy
@codemzy
Feb 16 2016 10:00 UTC
@hong-yi your filter loops through all the elements of the fist array arguments[0], but your toDestroy function your only looking at arguments[1] and arguments[2]
@hong-yi what if there are 4 or 5 numbers passed in to be destroyed?
DanishKalim
@DanishKalim
Feb 16 2016 10:01 UTC
@codemzy not working
Goh Hong Yi
@hong-yi
Feb 16 2016 10:01 UTC
ah i get it. but i'm getting back empty arrays though
DanishKalim
@DanishKalim
Feb 16 2016 10:02 UTC
@codemzy plz help
Codemzy
@codemzy
Feb 16 2016 10:02 UTC
@DanishKalim paste the entire code you have
AdityaMulyap
@AdityaMulyap
Feb 16 2016 10:02 UTC
var Bike = function() {

  // Only change code below this line.
  var gear = 0;


  this.setGear=function(change) {
  gear += 4;
  };
   this.getGear=function(change) {
 gear = change ;
}; 
};
var myBike = new Bike();
I got stuck on this waypoint :S can anybody help?
Thanks before :D
Norman Dela Cruz
@dcnr
Feb 16 2016 10:03 UTC
@hong-yi the arguments object is different for every function. arguments in destroyer is different from toDestroy
/* destroyer arguments */
arguments[0] = [1, 2, 3, 1, 2, 3];
arguments[1] = 2;
arguments[2] = 3;

/* toDestroy arguments */
arguments[0] = value;
arguments[1] = indexof value
arguments[2] = the array worked on, in this case arguments[0]
Hemedi
@Hemedi
Feb 16 2016 10:03 UTC
help Symmetric Difference
CamperBot
@camperbot
Feb 16 2016 10:03 UTC

:point_right: algorithm symmetric difference [wiki]

Problem Explanation:

Symmetric Difference is the difference between two sets.

So in the Symmetric Difference Algorithm you would work through the arrays of numbers something like this -

sym(A, B, C) Translates to sym(sym(A,B),C)

Or in plain English - First find the Symmetric Difference of Set A and Set B. Then find the Symmetric Difference of this new set and Set C.

So -

sym([1, 2, 5], [2, 3, 5], [3, 4, 5])

would equal

[1,4,5]

Here's a nice video tutorial (with an awful fake British accent!) -

YouTube - Symmetric Difference
:pencil: read more about algorithm symmetric difference on the FCC Wiki

Goh Hong Yi
@hong-yi
Feb 16 2016 10:04 UTC
@Hemedi was that for me to read?
Hemedi
@Hemedi
Feb 16 2016 10:04 UTC
No, I'm stuck on that
Sorry
DanishKalim
@DanishKalim
Feb 16 2016 10:05 UTC

<var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.
newArray = oldArray.filter(function(val) {
return val <= 5;
});
var newArray = oldArray;>

var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.
newArray = oldArray.filter(function(val) {
return val <= 5;
});
var newArray = oldArray;

AdityaMulyap
@AdityaMulyap
Feb 16 2016 10:05 UTC
The waypoint isMake Object Properties Private one
Goh Hong Yi
@hong-yi
Feb 16 2016 10:05 UTC
@dcnr ah okok i'll read up on it a bit more. thanks @codemzy too.
CamperBot
@camperbot
Feb 16 2016 10:05 UTC
hong-yi sends brownie points to @dcnr and @codemzy :sparkles: :thumbsup: :sparkles:
:star: 608 | @codemzy | http://www.freecodecamp.com/codemzy
:star: 631 | @dcnr | http://www.freecodecamp.com/dcnr
DanishKalim
@DanishKalim
Feb 16 2016 10:06 UTC

var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.
newArray = oldArray.filter(function(val) {
return val <= 5;
});
var newArray = oldArray;

You should have filtered out all values from the array that are greater than 5.

@codemzy
Codemzy
@codemzy
Feb 16 2016 10:06 UTC
@DanishKalim its because you have changed the code above the line where it says only change code below this line... it should be ...
var array = [1,2,3,4,5,6,7,8,9,10];
  // Only change code below this line.

array = array.filter(function(val){
  return val <= 5;
});

  // Only change code above this line.
(function() {return array;})();
@DanishKalim oh wait maybe they have changed the challenge.. let me reset it
Norman Dela Cruz
@dcnr
Feb 16 2016 10:07 UTC
I wrote something about arguments object. If you already know all of these, then I'm sorry for the spam @hong-yi
DanishKalim
@DanishKalim
Feb 16 2016 10:07 UTC
ok
Codemzy
@codemzy
Feb 16 2016 10:08 UTC
@DanishKalim
var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.

var newArray = oldArray.filter(function(val) {
  return val <= 5;
});
@DanishKalim that is all you need, it just wants you to assign newArray to the filtered array.
dagandrew
@dagandrew
Feb 16 2016 10:10 UTC
please, help me
AdityaMulyap
@AdityaMulyap
Feb 16 2016 10:10 UTC
anybody have any idea with my problem?
dagandrew
@dagandrew
Feb 16 2016 10:10 UTC
ex. Testing Objects for Properties in Basic JavaScript
DanishKalim
@DanishKalim
Feb 16 2016 10:11 UTC
@codemzy thanks alot it was geeting on my nerves
CamperBot
@camperbot
Feb 16 2016 10:11 UTC
danishkalim sends brownie points to @codemzy :sparkles: :thumbsup: :sparkles:
:star: 609 | @codemzy | http://www.freecodecamp.com/codemzy
please
Codemzy
@codemzy
Feb 16 2016 10:11 UTC
@DanishKalim :thumbsup:
dagandrew
@dagandrew
Feb 16 2016 10:11 UTC
pleas
please
please
Codemzy
@codemzy
Feb 16 2016 10:11 UTC
@dagandrew paste your code

var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty(checkProp)) return myObj.checkProp;
else return "Not Found";
}

// Test your code by modifying these values
checkObj("gift");

Codemzy
@codemzy
Feb 16 2016 10:13 UTC
@dagandrew try
function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp)) { 
  return myObj[checkProp];
} else { 
  return "Not Found";
}
};
AdityaMulyap
@AdityaMulyap
Feb 16 2016 10:13 UTC
'''js
CamperBot
@camperbot
Feb 16 2016 10:13 UTC
:bulb: to format code use backticks! ``` more info
Codemzy
@codemzy
Feb 16 2016 10:14 UTC
@dagandrew sorry pressed enter too soon... just updated it
AdityaMulyap
@AdityaMulyap
Feb 16 2016 10:14 UTC
'''js
function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp)){
return myObj[checkProp];
}else{
return "Not Found";
}
}
'''
mine is this, try change the checkProp into [checkProp]
CamperBot
@camperbot
Feb 16 2016 10:14 UTC
:bulb: to format code use backticks! ``` more info
dagandrew
@dagandrew
Feb 16 2016 10:14 UTC
wow -- yes it is working
yes
yes
thank you
Codemzy
@codemzy
Feb 16 2016 10:15 UTC
@dagandrew :thumbsup:
dagandrew
@dagandrew
Feb 16 2016 10:15 UTC
@AdityaMulyap thank you
CamperBot
@camperbot
Feb 16 2016 10:15 UTC
dagandrew sends brownie points to @adityamulyap :sparkles: :thumbsup: :sparkles:
:star: 240 | @adityamulyap | http://www.freecodecamp.com/adityamulyap
AdityaMulyap
@AdityaMulyap
Feb 16 2016 10:15 UTC
@codemzy could you help mine?
Codemzy
@codemzy
Feb 16 2016 10:15 UTC
@AdityaMulyap yeah paste your code
Norman Dela Cruz
@dcnr
Feb 16 2016 10:15 UTC

@dagandrew As an alternative, you can just do

if (myObj[checkProp]) { 
  return myObj[checkProp];
} else { 
  return "Not Found";
}

or
return myObj[checkProp] || "Not Found";

AdityaMulyap
@AdityaMulyap
Feb 16 2016 10:16 UTC
var Bike = function() {

  // Only change code below this line.
  var gear = 0;


  this.setGear=function(change) {
  gear += 4;
  };
   this.getGear=function(change) {
 gear = change ;
}; 
};
var myBike = new Bike();
this one
dagandrew
@dagandrew
Feb 16 2016 10:16 UTC
ok
Norman Dela Cruz
@dcnr
Feb 16 2016 10:16 UTC
@AdityaMulyap in setGear you should set the gear not add to it, meaning gear = something
Codemzy
@codemzy
Feb 16 2016 10:16 UTC
@AdityaMulyap what is the challenge asking you to do?
Norman Dela Cruz
@dcnr
Feb 16 2016 10:17 UTC
@AdityaMulyap and in getGear, the concept of get is to return the property. so in getGear you should return gear
DanishKalim
@DanishKalim
Feb 16 2016 10:17 UTC

var array = [1, 12, 21, 2];

// Only change code below this line.
array = array.sort();

You should have sorted the array from largest to smallest.

AdityaMulyap
@AdityaMulyap
Feb 16 2016 10:17 UTC
myBike.getGear() should return 4 after calling myBike.setGear(4).
myBike.getGear() should return 3 after calling myBike.setGear(3).
myBike.getGear() should return 1 after calling myBike.setGear(1).
it asked me to do this
Abhishek Kumar
@abhishekKumar1
Feb 16 2016 10:17 UTC
@DanishKalim .sort doesn't work that way
AdityaMulyap
@AdityaMulyap
Feb 16 2016 10:17 UTC
wait I'll try it @dcnr
Abhishek Kumar
@abhishekKumar1
Feb 16 2016 10:17 UTC
help .sort
CamperBot
@camperbot
Feb 16 2016 10:17 UTC

:point_right: algorithm sorted union [wiki]

Problem Explanation:

  • The program has to return a new array of unique values from two original arrays in the order they show up. So there is not sorting required, and no duplicates.
:pencil: read more about algorithm sorted union on the FCC Wiki
Abhishek Kumar
@abhishekKumar1
Feb 16 2016 10:19 UTC
it takes every element as strings so in this case u will get [1,12,2,21] which is not correct
Codemzy
@codemzy
Feb 16 2016 10:19 UTC
@AdityaMulyap so set gear should set the gear...
  this.setGear=function(change) {
  gear = change;
  };
DanishKalim
@DanishKalim
Feb 16 2016 10:19 UTC
@abhishekKumar1 help plz what to do
Abhishek Kumar
@abhishekKumar1
Feb 16 2016 10:19 UTC
try reading how to use in the left side instruction
AdityaMulyap
@AdityaMulyap
Feb 16 2016 10:20 UTC
whoaaaa it works.... thanks @codemzy thanks @dcnr
CamperBot
@camperbot
Feb 16 2016 10:20 UTC
adityamulyap sends brownie points to @codemzy and @dcnr :sparkles: :thumbsup: :sparkles:
:star: 610 | @codemzy | http://www.freecodecamp.com/codemzy
:star: 632 | @dcnr | http://www.freecodecamp.com/dcnr
Codemzy
@codemzy
Feb 16 2016 10:20 UTC
@AdityaMulyap :thumbsup:
Olawale Akinseye
@brainyfarm
Feb 16 2016 10:21 UTC

@brainyfarm Unfortunately no. I am still completely stumped on it.

Maybe we can try again @AbryceT :D

DanishKalim
@DanishKalim
Feb 16 2016 10:34 UTC

var oldArray = [1,2,3];
var newArray = [];

var concatMe = [4,5,6];

// Only change code below this line.
newarray = oldArray.concat(concatMe);
newArray = oldArray;

You should concatenate the two arrays together.

plz help
hellp
@codemzy
@abhishekKumar1
Abhishek Kumar
@abhishekKumar1
Feb 16 2016 10:39 UTC
why newArray = oldArray; that line will change it back delete that line
DanishKalim
@DanishKalim
Feb 16 2016 10:40 UTC
@abhishekKumar1 thanks
CamperBot
@camperbot
Feb 16 2016 10:40 UTC
danishkalim sends brownie points to @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
:star: 335 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
Rosien
@RosienVT
Feb 16 2016 10:43 UTC
Hi everyone! Another day, another problem (it never ends! :D)...this time with the "Testing Objects for Properties" challenge. The instructions are: 'Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".'
So far this is all the code I have
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here

myObj.hasOwnProperty("gift"); 
myObj.hasOwnProperty("pet");
myObj.hasOwnProperty("bed");
return "Not Found";
}

// Test your code by modifying these values
checkObj("gift");
I don't know how I can make it return the property value?
Abhishek Kumar
@abhishekKumar1
Feb 16 2016 10:44 UTC
@NomadRose think about what you want to do
first think why there is an input string checkProp if you are not gonna use it
Rosien
@RosienVT
Feb 16 2016 10:46 UTC
No clue :D
Abhishek Kumar
@abhishekKumar1
Feb 16 2016 10:46 UTC
and think if myObj can be changed and have different elements in that case what your program should do
try reading about loops it will help
help loop
CamperBot
@camperbot
Feb 16 2016 10:47 UTC

:point_right: challenge count backwards with a for loop [wiki]

Count Backwards With a For Loop

A for loop can also count backwards, so long as we can define the right conditions.

In order to count backwards by twos, we'll need to change our initialization, condition, and final-expression.

We'll start at i = 10 and loop while i > 0. We'll decrement i by 2 each loop with i -= 2.

var ourArray = [];

for(var i = 10; i > 0; i -= 2) {

  ourArray.push(i);

}

ourArray will now contain [10,8,6,4,2]

:pencil: read more about challenge count backwards with a for loop on the FCC Wiki

Rosien
@RosienVT
Feb 16 2016 10:50 UTC
Thanks @abishekKumar1 but I haven't learned anything about loops yet ( AFAIK?) so it's hard to place in context
CamperBot
@camperbot
Feb 16 2016 10:50 UTC
nomadrose sends brownie points to @abishekkumar1 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for abishekkumar1
Rosien
@RosienVT
Feb 16 2016 10:50 UTC
And sorry for spelling your name wrong :D Thanks @abhishekKumar1
CamperBot
@camperbot
Feb 16 2016 10:50 UTC
nomadrose sends brownie points to @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
:star: 336 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
Rosien
@RosienVT
Feb 16 2016 10:55 UTC
Still stuck though
Abhishek Kumar
@abhishekKumar1
Feb 16 2016 10:58 UTC
@NomadRose you should learn about loops its essential for programming just type how to use for loop in js in GOOGLE
Yuvraj Adagale
@Yuvraj1989
Feb 16 2016 11:02 UTC
@NomadRose see the way you have asked the doubt, itself solves half of the loop problem
read it n see you are using loop there also
Ankush Kalia
@ak274
Feb 16 2016 11:28 UTC

I 'm tring to solve this excercise :-- Testing Objects for Properties.

My soltuion:--

// Setup
var myObj = {
"gift": "pony",
"pet": "kitten",
"bed": "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty(checkProp))
{
return myObj[checkProp];
}
else{return "Not Found";}
}
// Test your code by modifying these values
checkObj("gift");

But when i'm trying to access object using dot operator it doesn't return any value. But when i'm using squre brackets it runs successfully...

maryod
@maryod
Feb 16 2016 11:31 UTC
Sift through Text with Regular Expressions: please what would be the correct answer: var expression=/and/gi; ?
Rosien
@RosienVT
Feb 16 2016 11:34 UTC
Hey thanks @ak274 I was stuck on that challenge too :D
CamperBot
@camperbot
Feb 16 2016 11:34 UTC
nomadrose sends brownie points to @ak274 :sparkles: :thumbsup: :sparkles:
:star: 218 | @ak274 | http://www.freecodecamp.com/ak274
Ankush Kalia
@ak274
Feb 16 2016 11:36 UTC
@NomadRose Do you know why it happens ?
Rosien
@RosienVT
Feb 16 2016 11:41 UTC
No idea...I was stuck on another issue (see just above where you joined) and was apparently approaching it from the wrong angle. No idea why the dot notation doesn't work though?
J Player
@Heyjp
Feb 16 2016 11:46 UTC
@ak274 when accessing objects, if the property has any special characters like " " you can only access it with square brackets.
Ankush Kalia
@ak274
Feb 16 2016 11:47 UTC

Hi @abhishekKumar, Can you wxplain why dot notation is returning undefned and squre brackets work fine .

I 'm tring to solve this excercise :-- Testing Objects for Properties.

My soltuion:--
'code'
// Setup
var myObj = {
"gift": "pony",
"pet": "kitten",
"bed": "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty(checkProp))
{
return myObj[checkProp];
}
else{return "Not Found";}
}
// Test your code by modifying these values
checkObj("gift");

But when i'm trying to access object using dot operator it doesn't return any value. But when i'm using squre brackets it runs successfully...

@Heyjp if that is the issue how i could access it in the previous exercise:--
// Setup
var testObj = {
"hat": "ballcap",
"shirt": "jersey",
"shoes": "cleats"
};

// Only change code below this line

var hatValue = testObj.hat; // Change this line
var shirtValue = testObj.shirt; // Change this line

J Player
@Heyjp
Feb 16 2016 11:52 UTC
wiki format
CamperBot
@camperbot
Feb 16 2016 11:52 UTC

: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 and then press [shift + enter ⏎] (type js or html or css)

<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

J Player
@Heyjp
Feb 16 2016 11:54 UTC
that's new, i'll see if i can get you an answer
Ankush Kalia
@ak274
Feb 16 2016 11:56 UTC

@Heyjp if that is the issue how i could access it in the previous exercise:--
`
// Setup
var testObj = {
"hat": "ballcap",
"shirt": "jersey",
"shoes": "cleats"
};

// Only change code below this line

var hatValue = testObj.hat; // Change this line
var shirtValue = testObj.shirt; // Change this line`

@camperbot Thanks for the wiki