These are chat archives for FreeCodeCamp/HelpJavaScript

4th
Mar 2016
uCtrlr
@uCtrlr
Mar 04 2016 00:00 UTC
@johnlovespi Well first of all you're going to need to go through each contact so you'll need a loop to go through each number.
aleksamarkoni
@aleksamarkoni
Mar 04 2016 00:01 UTC
Does anybody else thinks that this code is a bit sexist :)
Pedro Abel Díaz Sánchez
@coderHook
Mar 04 2016 00:01 UTC
@dcnr thats right, I missed the .length,
uCtrlr
@uCtrlr
Mar 04 2016 00:01 UTC
This message was deleted
aleksamarkoni
@aleksamarkoni
Mar 04 2016 00:01 UTC
No that's not the right word
Finesse Rucker
@Finesse315
Mar 04 2016 00:01 UTC
still not getting anywhere
Pete Considine
@pjconsidine
Mar 04 2016 00:02 UTC
@Finesse315 What the error message?
Pedro Abel Díaz Sánchez
@coderHook
Mar 04 2016 00:02 UTC
@dcnr but I still having a problem, because it is not getting the second argument. (I also set sum without the () but it does not make sense to me because I need a second parameter.
Finesse Rucker
@Finesse315
Mar 04 2016 00:02 UTC
unsuspected token else
Pete Considine
@pjconsidine
Mar 04 2016 00:02 UTC
so something is wrong with the else statement
Pete Considine
@pjconsidine
Mar 04 2016 00:03 UTC
those don't usually take parentheses
so it's if (something) { } else { }
you've also still got an extra semicolon
right at the start
that usually messes all kinds of things up
Pedro Abel Díaz Sánchez
@coderHook
Mar 04 2016 00:06 UTC
@dcnr btw I think we broke smt, cause now I am not able to run it when setting sum without ()
Finesse Rucker
@Finesse315
Mar 04 2016 00:12 UTC
ok i see where i went wrong, gonna keep practicing the if else/if statements thx
Pedro Abel Díaz Sánchez
@coderHook
Mar 04 2016 00:15 UTC

I think is enough for me today, I let the current code in case someone can give me a hint on what I am doing wrong.

function add() {
  var sum = 0;

 function sumfirstand(x){

    return function(y){

      if(typeof y === "number"){
        return x + y;

      } else {return undefined;}
    };
  }

 if(arguments.length == 1 && typeof arguments[0] == "number"){

   sum = sumfirstand(arguments[0]);

   return sum;

 }else{

   for(var i = 0; i < arguments.length; i++){
      var type = typeof arguments[i];

       if(type !== "number"){ return undefined;

       } else {   sum += arguments[i];      }
 }

   return sum;
}
}


add(2)(3);

Tomorrow more, nn!

Norman Dela Cruz
@dcnr
Mar 04 2016 00:16 UTC
@Abel1987 that should be correct I think
@Abel1987
function add() {
  var sum = 0;

  function sumfirstand(x) {

    return function (y) {
      if (typeof y === "number") {
        return x + y;
      }
    };
  }

  if (arguments.length === 1 && typeof arguments[0] == "number") {
    sum = sumfirstand(arguments[0]);
    return sum;
  }
  else {
    for (var i = 0; i < arguments.length; i++) {
      var type = typeof arguments[i];

      if (type !== "number") {
        return undefined;
      }
      else {
        sum += arguments[i];
      }
    }

    return sum;
  }
}
@Abel1987 at least it's passing for me
Darryl Parks
@punchymango
Mar 04 2016 00:23 UTC
Hey everyone
David Young
@dayvidwhy
Mar 04 2016 00:25 UTC
yowassup
Sam Reeves
@smreeves
Mar 04 2016 00:27 UTC
Gah! Having trouble with instanceof for javascript. I read through the Details of the Object Model. I'm pretty familiar with Java and setting up the class with its constructors but for some reason on this Make a Person challenge I can't seem to get instanceof to return true. I left the structure of the function as is, simply split the string into an array and set up a multiple return statement to make my getter and setter functions. I'm not sure how to get it so the object type is of Person.
Norman Dela Cruz
@dcnr
Mar 04 2016 00:32 UTC
@sreeves89 hi will you post your current code?
Sam Reeves
@smreeves
Mar 04 2016 00:32 UTC
function Person(firstAndLast) {
  var nameArr = firstAndLast.split(" ");

  return {
    getFirstName : function() {
      return nameArr[0];
    },
    getLastName : function() {
      return nameArr[1];
    },
    getFullName : function() {
      return nameArr[0] + " " + nameArr[1];
    },
    setFirstName : function(first) {
      nameArr[0] = first;
    },
    setLastName : function(last) {
      nameArr[1] = last;
    },
    setFullName : function(firstAndLast) {
      nameArr = firstAndLast.split(" ");
    }   
  };
};

var bob = new Person('Bob Ross');
bob.getFullName();
Pete Considine
@pjconsidine
Mar 04 2016 00:34 UTC
@sreeves89 is it necessary that they're all functions? Can't you just assign values?
Norman Dela Cruz
@dcnr
Mar 04 2016 00:34 UTC
@sreeves89 as a constructor function, you shouldn't return an object
adamboyer
@adamboyer
Mar 04 2016 00:35 UTC
hello everyone, do y'all know if you can seat a loop in another loop example:
Pete Considine
@pjconsidine
Mar 04 2016 00:35 UTC
not as explicit values but in terms of the inputs.
Norman Dela Cruz
@dcnr
Mar 04 2016 00:35 UTC
@sreeves89 you'd have to do this.getFirstName = function() { ...
Pete Considine
@pjconsidine
Mar 04 2016 00:35 UTC
like this.name = nameArr[0]
Pavel
@Savrov
Mar 04 2016 00:36 UTC
Hello, can i get a review of my js code here?
Sam Reeves
@smreeves
Mar 04 2016 00:37 UTC
OK. Maybe I'm misunderstanding the instanceof test. That's the only test that fails, the rest pass. I'll try to change it to this. ...
Pete Considine
@pjconsidine
Mar 04 2016 00:37 UTC
what's the error you're getting?
adamboyer
@adamboyer
Mar 04 2016 00:38 UTC
while(blah<blue){
while(cat=green){
var blah = 35;
}
}
Pete Considine
@pjconsidine
Mar 04 2016 00:38 UTC
also, make sure it's not supposed to be instanceOf() instead
Tyler Moeller
@TylerMoeller
Mar 04 2016 00:38 UTC
@savrov Just post it here or in the CodeReview chatroom https://gitter.im/FreeCodeCamp/CodeReview.
Sam Reeves
@smreeves
Mar 04 2016 00:39 UTC
bob instanceof Person should return true. <-- This test fails
Am I supposed to actually write an instanceof? Not certain what I'm really supposed to write in it.
Pavel
@Savrov
Mar 04 2016 00:40 UTC
@TylerMoeller thank you
CamperBot
@camperbot
Mar 04 2016 00:40 UTC
savrov sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star: 399 | @tylermoeller | http://www.freecodecamp.com/tylermoeller
Rami
@RNwebdk
Mar 04 2016 00:41 UTC
OMG
why the ** does this give me false
Norman Dela Cruz
@dcnr
Mar 04 2016 00:41 UTC
@sreeves89 no, you shouldn't return an object but use this.name = function() {} inside your constructor function. Or extend Person's prototype, but you'd fail the property count test
Mark Howard
@iheartkode
Mar 04 2016 00:41 UTC
@0x0936 what did i do
Rami
@RNwebdk
Mar 04 2016 00:41 UTC
var contacts = [
    {
        "firstName": "Akira",
        "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"]
    }
];
console.log(contacts.hasOwnProperty("number"))
Norman Dela Cruz
@dcnr
Mar 04 2016 00:42 UTC
@RNwebdk because contacts is an ARRAY
Sam Reeves
@smreeves
Mar 04 2016 00:42 UTC
OK, by removing my return functions and switching to this.getFullName = function() ... the instanceof passed.
Tyler Moeller
@TylerMoeller
Mar 04 2016 00:42 UTC
@RNwebdk Try this: console.log(contacts[0].hasOwnProperty('number'));
Mark Howard
@iheartkode
Mar 04 2016 00:42 UTC
array of objects
Sam Reeves
@smreeves
Mar 04 2016 00:42 UTC
Guess I'm still a little hazy on how that turns it into a constructor function.
Rami
@RNwebdk
Mar 04 2016 00:42 UTC
OMG thanks @dcnr and @TylerMoeller
CamperBot
@camperbot
Mar 04 2016 00:42 UTC
rnwebdk sends brownie points to @dcnr and @tylermoeller :sparkles: :thumbsup: :sparkles:
:star: 400 | @tylermoeller | http://www.freecodecamp.com/tylermoeller
:star: 754 | @dcnr | http://www.freecodecamp.com/dcnr
Rami
@RNwebdk
Mar 04 2016 00:44 UTC
i hate when you keep looking at your code and try really hard, but still can't find the issue :P
Tyler Moeller
@TylerMoeller
Mar 04 2016 00:44 UTC
@RNwebdk lol, that's why I'm here in chat
Mark Howard
@iheartkode
Mar 04 2016 00:44 UTC
@RNwebdk whats up?
Sam Reeves
@smreeves
Mar 04 2016 00:45 UTC
thanks for the help @dcnr and @pjconsidine
CamperBot
@camperbot
Mar 04 2016 00:45 UTC
sreeves89 sends brownie points to @dcnr and @pjconsidine :sparkles: :thumbsup: :sparkles:
:star: 394 | @pjconsidine | http://www.freecodecamp.com/pjconsidine
:star: 755 | @dcnr | http://www.freecodecamp.com/dcnr
Rami
@RNwebdk
Mar 04 2016 00:45 UTC
@TylerMoeller your awesome, we need more people like you :D
@iheartkode was just a comment on my other post :) thx anyway for asking
CamperBot
@camperbot
Mar 04 2016 00:45 UTC
rnwebdk sends brownie points to @tylermoeller and @iheartkode :sparkles: :thumbsup: :sparkles:
:warning: rnwebdk already gave tylermoeller points
:star: 552 | @iheartkode | http://www.freecodecamp.com/iheartkode
Mark Howard
@iheartkode
Mar 04 2016 00:46 UTC
@RNwebdk haha ok
Rami
@RNwebdk
Mar 04 2016 00:47 UTC
I need some codeing music, anyone with some cool list on youtube, soundcloud, twitch ect ?
Mark Howard
@iheartkode
Mar 04 2016 00:47 UTC
@RNwebdk yes
3 hours
Rami
@RNwebdk
Mar 04 2016 00:49 UTC
@iheartkode thx appreciate that :) 3 hours is more then enough ^^
CamperBot
@camperbot
Mar 04 2016 00:49 UTC
rnwebdk sends brownie points to @iheartkode :sparkles: :thumbsup: :sparkles:
:warning: rnwebdk already gave iheartkode points
Vincent
@vtli94
Mar 04 2016 00:49 UTC

working on loops "Iterate Through an Array with a For Loop” specifically.
can someone explain to how the loop is doing its math?

var myArr = [ 2, 3, 4, 5, 6];
var total = 0;

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

adding the total its 20. If I were to do myArr[4] it equals to 30 myArr[3] = 25, myArr2 = 20, myArr1 = 15, myArr[0] = 10.
I want to know how its processing it.

Mark Howard
@iheartkode
Mar 04 2016 00:49 UTC
@RNwebdk yw
Rami
@RNwebdk
Mar 04 2016 00:50 UTC
@vtli94 remember to increment i++
ow you did
sorry
Mark Howard
@iheartkode
Mar 04 2016 00:50 UTC
@vtli94 each iteration it counts up
Vincent
@vtli94
Mar 04 2016 00:50 UTC
right. what does that mean exactly?
its going 0,1,2,3,4
right?
Mark Howard
@iheartkode
Mar 04 2016 00:51 UTC
it goes through each item in the array until its empty
@vtli94 yep
Rami
@RNwebdk
Mar 04 2016 00:51 UTC
@iheartkode this is so peacefull, OMG i love it
Mark Howard
@iheartkode
Mar 04 2016 00:51 UTC
@RNwebdk nice :)
@RNwebdk also on spotify they have a focus music section
just youtube focus music and you will be set lol
Rami
@RNwebdk
Mar 04 2016 00:52 UTC
nice
Vincent
@vtli94
Mar 04 2016 00:52 UTC
so… if i input myArr[0] how did it get 10?
Mark Howard
@iheartkode
Mar 04 2016 00:53 UTC
@vtli94 do you understand indexes in the array?
Vincent
@vtli94
Mar 04 2016 00:53 UTC
refresh me please
Mark Howard
@iheartkode
Mar 04 2016 00:53 UTC
@vtli94 btw you can do that array look easier ill show
var arr = [1,2,3,4,5,6];
for(var i = 0; i < arr.length; i++) {
     console.log(i);
}
that will output 0 1 2 3 4 5
if we changed it to var i = 1; it will be 12345
Vincent
@vtli94
Mar 04 2016 00:56 UTC
right. i understand that
Mark Howard
@iheartkode
Mar 04 2016 00:56 UTC
indexes start at 0
Tyler Moeller
@TylerMoeller
Mar 04 2016 00:57 UTC

@vtli94 You can always add console.log() to get more detail:

var myArr = [2, 3, 4, 5, 6];
var total = 0;

for (var i = 0; i < myArr.length; i++) {
  console.log('iteration: ' + i + ' = ' + 'total + myArr[i]' + ' = ' + total + ' + ' + myArr[i] + ' = ' + (total + myArr[i]));
  total += myArr[i];
}

Output is:

iteration: 0 = total + myArr[i] = 0 + 2 = 2
iteration: 1 = total + myArr[i] = 2 + 3 = 5
iteration: 2 = total + myArr[i] = 5 + 4 = 9
iteration: 3 = total + myArr[i] = 9 + 5 = 14
iteration: 4 = total + myArr[i] = 14 + 6 = 20
Mark Howard
@iheartkode
Mar 04 2016 00:57 UTC
@TylerMoeller great explanation
@TylerMoeller thanks
CamperBot
@camperbot
Mar 04 2016 00:57 UTC
iheartkode sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star: 402 | @tylermoeller | http://www.freecodecamp.com/tylermoeller
Valeriav521
@Valeriav521
Mar 04 2016 00:58 UTC
hey
Tyler Moeller
@TylerMoeller
Mar 04 2016 00:58 UTC
Happy to help with this :)
Mateo
@KinichAjaw
Mar 04 2016 00:58 UTC
OK, so I'm on "return early pattern" and I've tried the code with abTest. It seems to be working but it won't let me pass.
if (a < 0 || b < 0) {
return "undefined";
}
Vincent
@vtli94
Mar 04 2016 00:59 UTC
thanks @iheartkode @TylerMoeller
CamperBot
@camperbot
Mar 04 2016 00:59 UTC
vtli94 sends brownie points to @iheartkode and @tylermoeller :sparkles: :thumbsup: :sparkles:
Valeriav521
@Valeriav521
Mar 04 2016 00:59 UTC
hello
Khademul Islam Mahin
@Mahin2k
Mar 04 2016 00:59 UTC
hello
CamperBot
@camperbot
Mar 04 2016 00:59 UTC
:star: 553 | @iheartkode | http://www.freecodecamp.com/iheartkode
:star: 403 | @tylermoeller | http://www.freecodecamp.com/tylermoeller
Vincent
@vtli94
Mar 04 2016 00:59 UTC
so how is the ‘total’ calculated?
Valeriav521
@Valeriav521
Mar 04 2016 00:59 UTC
hey @Mahin2k
Vincent
@vtli94
Mar 04 2016 00:59 UTC
oh nevermind i got it
im thinking too hard
Khademul Islam Mahin
@Mahin2k
Mar 04 2016 00:59 UTC
@Valeriav521 hi
can someone help me with this?
Valeriav521
@Valeriav521
Mar 04 2016 01:00 UTC
who wants to chat like about whatever?
Mark Howard
@iheartkode
Mar 04 2016 01:00 UTC
@vtli94 sometimes taking a break and breathing helps lol
Khademul Islam Mahin
@Mahin2k
Mar 04 2016 01:00 UTC
function largestOfFour(arr) {
  // You can do this!
  var result = [];

  for (var i = 0; i < arr.length; i++){
  var largestNumber = 0;
    for(var j=0; j < arr.length; j++){
      if(largestNumber<arr[i][j]){
        result=arr[i][j];
        }
    }
    result.push(largestNumber);
}

  return result;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
can someone help?
t
Vincent
@vtli94
Mar 04 2016 01:00 UTC
😅 😅 😅 😅
Khademul Islam Mahin
@Mahin2k
Mar 04 2016 01:00 UTC
its not recognizing push as a function
Valeriav521
@Valeriav521
Mar 04 2016 01:01 UTC
anyone wanna chat?
Khademul Islam Mahin
@Mahin2k
Mar 04 2016 01:01 UTC
@Valeriav521 about?
Valeriav521
@Valeriav521
Mar 04 2016 01:01 UTC
about whatever
CamperBot
@camperbot
Mar 04 2016 01:01 UTC
you need to ask about @someone!
Valeriav521
@Valeriav521
Mar 04 2016 01:02 UTC
okay @camperbot
gvik02
@gvik02
Mar 04 2016 01:02 UTC
yes need help with falsy bouncer @Valeriav521
Valeriav521
@Valeriav521
Mar 04 2016 01:02 UTC
what @gvik02
gvik02
@gvik02
Mar 04 2016 01:03 UTC
I'm stuck with it ! can you help me with this?
assignment
sorry challange
Valeriav521
@Valeriav521
Mar 04 2016 01:03 UTC
sure if i know i am kinda new at this
gvik02
@gvik02
Mar 04 2016 01:03 UTC
ha ha OK then
Khademul Islam Mahin
@Mahin2k
Mar 04 2016 01:05 UTC
can someone help?
Mateo
@KinichAjaw
Mar 04 2016 01:06 UTC
Oh, I wasn't supposed to literally put return "undefined"; now I feel silly.
Valeriav521
@Valeriav521
Mar 04 2016 01:07 UTC
in what? @Mahin2k java or html?
gvik02
@gvik02
Mar 04 2016 01:10 UTC
Need help with falcy Bouncer can anyone help me !
E
@efhjones
Mar 04 2016 01:10 UTC
@gvik02 what's your question?
Valeriav521
@Valeriav521
Mar 04 2016 01:10 UTC
lol
Khademul Islam Mahin
@Mahin2k
Mar 04 2016 01:11 UTC
@KinichAjaw lol
Mateo
@KinichAjaw
Mar 04 2016 01:12 UTC
Exactly my response! I was being too literal. XD
Rami
@RNwebdk
Mar 04 2016 01:14 UTC
When do i use operater == and === ?
i understand the diffrence , but would it make sence to allways use === ?
gvik02
@gvik02
Mar 04 2016 01:15 UTC
This message was deleted
Rami
@RNwebdk
Mar 04 2016 01:16 UTC
@gvik02 no var test = "test" is assigning
not 2 ==
but when would it make sense to use the double instead of 3
Khademul Islam Mahin
@Mahin2k
Mar 04 2016 01:18 UTC
someone help me

function largestOfFour(arr) {
  // You can do this!
  var result = [];

  for (var i = 0; i < arr.length; i++){
  var largestNumber = 0;
    for(var j=0; j < arr.length; j++){
      if(largestNumber<arr[i][j]){
        result=arr[i][j];
        }
    }
    result.push(largestNumber);
}

  return result;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
.push function is not being recognized
Valeriav521
@Valeriav521
Mar 04 2016 01:19 UTC
hey
Rami
@RNwebdk
Mar 04 2016 01:19 UTC
@Mahin2k not sure, but i think result.push(largestNumber); is the problem here
again not sure
gvik02
@gvik02
Mar 04 2016 01:23 UTC
Math.max.apply() try this @Mahin2k
sethnejame
@sethnejame
Mar 04 2016 01:30 UTC
Hey fellas, a little help here
Stumped right now, trying to use the "lookup" object to find "val" and assign tghe associated string to the "result" variable
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line

  var lookup = {

    "alpha": "Adams",
    "bravo": "Boston",
    "charlie": "Chicago",
    "delta": "Denver",
    "echo": "Easy",
    "foxtrot": "Frank",

  };


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

// Change this value to test
phoneticLookup("charlie");
I already made the table
erm, object rather
E
@efhjones
Mar 04 2016 01:42 UTC
@sethnejame what challenge is this?
sethnejame
@sethnejame
Mar 04 2016 01:43 UTC
@efhjones "Using Objects for Lookups"
gvik02
@gvik02
Mar 04 2016 01:43 UTC
try this lookup[val] @sethnejame
sethnejame
@sethnejame
Mar 04 2016 01:45 UTC
@gvik02 no dice :(
I changed the "alpha" to alpha
I think that helped
golfguy1984
@golfguy1984
Mar 04 2016 01:46 UTC
function myTest(val) {
  // Only change code below this line

  if (val > 10 || val < 20) {
    return "Outside";

  }

  // Only change code above this line
  return "Inside";
}

// Change this value to test
myTest(15);
Why is this not returning inside?
gvik02
@gvik02
Mar 04 2016 01:48 UTC
of-course the val satisfies the if statement so it will return Outside @golfguy1984
use apha itself don't use the "" @sethnejame
sethnejame
@sethnejame
Mar 04 2016 01:50 UTC
right, did that
I need to assign the result to the lookup results somehow
i think
*the result variable
golfguy1984
@golfguy1984
Mar 04 2016 01:50 UTC
@gvik02 but if i change it to 25 it still returns outside
gvik02
@gvik02
Mar 04 2016 01:51 UTC
yes 25 is greater than 10 so
you need to rethink the if statement @golfguy1984
you can directly assign it @sethnejame
sethnejame
@sethnejame
Mar 04 2016 01:52 UTC
@gvik02 i tried this. . .
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line

  var lookup = {  
    alpha: "Adams",
    bravo: "Boston",
    charlie: "Chicago",
    delta: "Denver",
    echo: "Easy",
    foxtrot: "Frank",

  };

  var result = lookup.val;

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

// Change this value to test
phoneticLookup("charlie");
No dice
gvik02
@gvik02
Mar 04 2016 01:52 UTC
change it to lookup[val];
@sethnejame
sethnejame
@sethnejame
Mar 04 2016 01:53 UTC
what's that? the actual object or the result asssignment below
gvik02
@gvik02
Mar 04 2016 01:54 UTC
result assignment @sethnejame
sethnejame
@sethnejame
Mar 04 2016 01:54 UTC
oh wow
that worked
@gvik02 thanks!
CamperBot
@camperbot
Mar 04 2016 01:54 UTC
sethnejame sends brownie points to @gvik02 :sparkles: :thumbsup: :sparkles:
:star: 280 | @gvik02 | http://www.freecodecamp.com/gvik02
gvik02
@gvik02
Mar 04 2016 01:55 UTC
you are welcome
function factorialize(num) {
a = 1;
var val;
while(a <= num){
if (typeof num !== undefined) {
val = a * val;
a++;
return val;
}
else{
return a;
}
}
}
factorialize(5);
This is returning null and i dont see how.
bitgrower
@bitgrower
Mar 04 2016 02:12 UTC
just fyi, you might want to use var a instead of just a
you are also using val before giving it a value
Thank you. Now it doesn't recognize the val = a * val;
a++;
bitgrower
@bitgrower
Mar 04 2016 02:21 UTC
well ... did you give val a value ?
Yes, its set to a default of 1 at the top.
asaki444
@asaki444
Mar 04 2016 02:22 UTC
``` 
Where is the thumbs up button?
bitgrower
@bitgrower
Mar 04 2016 02:23 UTC
no thumbs up ... just say @username thanks ...
CamperBot
@camperbot
Mar 04 2016 02:23 UTC
bitgrower sends brownie points to @username :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for username
asaki444
@asaki444
Mar 04 2016 02:23 UTC
``` 
ar contacts = [
{
    "firstName": "Akira",
    "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"]
}

];

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

return "No such property";
}
// Only change code above this line
}
// Change these values to test your function
lookUp("Akira", "address");

```

bitgrower
@bitgrower
Mar 04 2016 02:23 UTC
@cfj2 -- if both a & val are 1 -- your code isn't going to go thru your while loop
asaki444
@asaki444
Mar 04 2016 02:23 UTC
I am profile lookup
it keeps returning t
that there is no such property on the test one
bitgrower
@bitgrower
Mar 04 2016 02:25 UTC
so follow your code thru ... step thru it, @asaki444 ...
it looks at the first contact ... looks to see if the first contact has name "Akira' AND has the property "address" ... it doesn't ... so what will it do next ?
@bitgrower I dont understand. 1 is less then num. Did I mis enter the paramaters?
bitgrower
@bitgrower
Mar 04 2016 02:28 UTC
you said val is now 1 ... and a is now 1 ...is that correct?
asaki444
@asaki444
Mar 04 2016 02:28 UTC
@bitgrower it did do what it was supposed to do for that. I forgot I changed the test one. I ran lookUp("Sherlock", "likes"), and it said there was no such contact
Yes.
bitgrower
@bitgrower
Mar 04 2016 02:29 UTC
so look at your while loop ...
@asaki444 -- so follow your code ... step thru your code & see what it's doing ... use this site to help you pythontutor.com/javascript.html
This message was deleted
rprusia
@rprusia
Mar 04 2016 02:32 UTC

Why is this failing?

Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr

var myStr = "\b \t \t \r \n"; // Change this line

i see it backslash not backspace
bitgrower
@bitgrower
Mar 04 2016 02:32 UTC
@cfj2 -- you are returning right away ...
I tried switching the if and while paramaters but still no.
bitgrower
@bitgrower
Mar 04 2016 02:36 UTC
post your current code ?
function factorialize(num) {
var a = 1;
var val=1;
while(typeof num !== undefined){
if (a <= num) {
val = a * val;
a++;
return val;
}
else{
return a;
}
}
}
factorialize(5);
bitgrower
@bitgrower
Mar 04 2016 02:37 UTC
btw -- you can get cool syntax coloring & things if you use this ...
explain formatting
CamperBot
@camperbot
Mar 04 2016 02:38 UTC

:point_right: code formatting [wiki]

Multi line Code

```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 ⏎]

Single line Code

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

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

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

bitgrower
@bitgrower
Mar 04 2016 02:39 UTC

so @cfj2

if ( a <= num) <--- 1 < 5 ... yes
val = a val; <--- 11 = 1

a++ <--- a is now 2
then you return val, which is 1 ...
you might want to look around at the various algos for coding factorial -- there are TONS of them around the web ...
...it's also a GREAT problem for getting exposed to using recursion ... because it's very clean & straightforward ... and recursion is something you'll want to at least get exposed to using ...
asaki444
@asaki444
Mar 04 2016 02:41 UTC
@bitgrower I am still not getting it... why doesnt it stop at i = 0 for the matchup?
bitgrower
@bitgrower
Mar 04 2016 02:42 UTC
I don't understand your question @asaki444
@bitgrower Thankyou. I will go ponder this.
Garrett
@grrttmrtn
Mar 04 2016 02:44 UTC

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i < multiplyAll.length; i++)
{
for (var j=0; j < multiplyAll[i].length; j++)
{
console.log(multiplyAll[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]]);

How much did I screw that up?
bitgrower
@bitgrower
Mar 04 2016 02:44 UTC
@cfj2 -- you can use a loop -- but right now you are only going thru your loop one time and returning ... which isn't quite what you want ... so you probably don't want to use return in the loop ... because that takes you right out of your function ...

@grrttmrtn -- are you trying to ? :)

first you might want to use the length of arr instead of the length of multiplyAll (the function)

Garrett
@grrttmrtn
Mar 04 2016 02:47 UTC
Ahh yeah...I started with that and stupidly came back and posted it with the function lol
But anyways, it still doesn't work
bitgrower @bitgrower re-programs @camperbot to recognize thank you
CamperBot
@camperbot
Mar 04 2016 02:47 UTC
bitgrower sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star: 1307 | @camperbot | http://www.freecodecamp.com/camperbot
bitgrower
@bitgrower
Mar 04 2016 02:47 UTC
er ... that is .. thankyou @camperbot
@grrttmrtn -- I know, that's why I said "first" ...
wanna try posting your revised code with cool syntax coloring ? Just follow the below instructions ...
explain format
CamperBot
@camperbot
Mar 04 2016 02:48 UTC

:point_right: code formatting [wiki]

Multi line Code

```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 ⏎]

Single line Code

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

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

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

Garrett
@grrttmrtn
Mar 04 2016 02:48 UTC

'function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i < product.length; i++)
{
for (var j=0; j < product[i].length; j++)
{
console.log(product[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]]);'

Still messed up the formatting. One sec
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i=0; i < product.length; i++)
    {
      for (var j=0; j < product[i].length; j++)
        {
          console.log(product[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]]);
CamperBot
@camperbot
Mar 04 2016 02:49 UTC
:bulb: to format code use backticks! ``` more info
bitgrower
@bitgrower
Mar 04 2016 02:50 UTC
you can edit the same message rather than re-posting ... and the backticks are the character to the left of the # 1 key on most keyboards
and ... product isn't an array ... so product.length is kinda meaningless ... you mean arr ?
asaki444
@asaki444
Mar 04 2016 02:52 UTC
@bitgrower on the link that you sent it would only compare the parameters against i = 0. Why is that?
Garrett
@grrttmrtn
Mar 04 2016 02:52 UTC
Okay, I changed lengths to arr and left console.log(product[i][j] still having issues with that
bitgrower
@bitgrower
Mar 04 2016 02:53 UTC
okay ... your loops are still using product.length -- which isn't even valid because numbers do not have length properties, as far as I know ...
@asaki444 -- you'll have to be a whole lot more specific ... I'm sorry ...
@asaki444 -- are you referring to pythontutor.com/javascript.html ?
:point_up: March 3, 2016 6:53 PM @grrttmrtn
asaki444
@asaki444
Mar 04 2016 02:55 UTC
@bitgrower yes that shite
site*
bitgrower
@bitgrower
Mar 04 2016 02:57 UTC
you can edit your messages, @asaki444 -- just mouse over to the right, and just to the right of the time 3 dots will show up when you hover over them ... right click, you'll get a context menu, from which you can choose "edit" :)
Garrett
@grrttmrtn
Mar 04 2016 02:57 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].length; j++)
        {
          console.log(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]]);
asaki444
@asaki444
Mar 04 2016 02:57 UTC
@bitgrower thanks for the tip
CamperBot
@camperbot
Mar 04 2016 02:57 UTC
asaki444 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 706 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 04 2016 02:58 UTC
@asaki -- it doesn't go past i= 0 because your code returns before it iterates to the next number ...
@grrttmrtn -- alright ... now we're starting to cook on all burners ... :)
asaki444
@asaki444
Mar 04 2016 02:59 UTC
@bitgrower oh! so i should use console.log instead?
bitgrower
@bitgrower
Mar 04 2016 02:59 UTC
LOL ... @asaki444 -- depends on what you're trying to do ...
Garrett
@grrttmrtn
Mar 04 2016 02:59 UTC
Typically I've been doing alright with JS...this and the profile lookup are my last ones left, but this is way over my head
asaki444
@asaki444
Mar 04 2016 03:00 UTC
@bitgrower trying to run the loop to find the match
bitgrower
@bitgrower
Mar 04 2016 03:00 UTC
nah ... just a little mental adjustment and you'll be thinking ... "that's all that that was??? pfftttt....let me at the next challenge..."
Garrett
@grrttmrtn
Mar 04 2016 03:00 UTC
console log is only going be what it reads out
it isn't going to fix your loop
bitgrower
@bitgrower
Mar 04 2016 03:00 UTC
@asaki444 -- console.log is for debugging ... and what @grrttmrtn said ... it's not going to fix your loop ...
so @grrttmrtn .... you know how to address an element of an array, right ?
Garrett
@grrttmrtn
Mar 04 2016 03:02 UTC
yup, I want to use dot notation
Sorry dot notation would be arr.whatever
but anyways yes arrary[0-X]
bitgrower
@bitgrower
Mar 04 2016 03:03 UTC
@grrttmrtn -- . notation is for objects ... this is for an array ...
so myArray = [1,2,3]; -- how do I address, point to, access, the number 3 ?
Garrett
@grrttmrtn
Mar 04 2016 03:04 UTC
myArray[2]
bitgrower
@bitgrower
Mar 04 2016 03:04 UTC
awesome ...

now ... what if I had

myArray = [ [1,2,3], [2,3,4],[5,6,7]];

what would myArray[2] be equal to ?

Garrett
@grrttmrtn
Mar 04 2016 03:05 UTC
[5,6,7]
bitgrower
@bitgrower
Mar 04 2016 03:05 UTC
excellent !!!!
so, if I wanted to address the number 6, how would I do it ?
Garrett
@grrttmrtn
Mar 04 2016 03:06 UTC
myArray[2][1]?
bitgrower
@bitgrower
Mar 04 2016 03:06 UTC
YUP!!!!!
so ... let's go back a few lessons ...
you remember learning about i++;
?
Garrett
@grrttmrtn
Mar 04 2016 03:07 UTC
Yup that's incrementing i in the for loop
bitgrower
@bitgrower
Mar 04 2016 03:07 UTC
okay, most commonly ... but I could do something like
product++; as well ...
John Espinoza
@johnlovespi
Mar 04 2016 03:07 UTC
@uCtrlr still here
bitgrower
@bitgrower
Mar 04 2016 03:07 UTC

now ... do you remember this syntax:

myNum += 1;

Garrett
@grrttmrtn
Mar 04 2016 03:08 UTC
myNum = myNum +1
bitgrower
@bitgrower
Mar 04 2016 03:08 UTC
yup

so ... if I have a loop like this ...
var num = 3;
j = 0;

for (i = 0; i < num; i++) {
j += 1;
}

what is j going to equal at the end ?

Garrett
@grrttmrtn
Mar 04 2016 03:10 UTC
J = 3
bitgrower
@bitgrower
Mar 04 2016 03:10 UTC
cool ...
Dustin
@glenohumeral13
Mar 04 2016 03:10 UTC
hey guys im stuff on "profile lookup" what am i doing wrong? do i need a for loop? http://www.freecodecamp.com/challenges/profile-lookup#?solution=%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUp(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Aif%20(firstName%20%3D%3D%20contacts.firstName%20%26%26%20prop%20%3D%3D%20contacts%5Bprop%5D)%20%7B%0A%20%20return%20contacts%5Bprop%5D%3B%0A%7D%20else%20if%20(firstName%20!%3D%3D%20contacts.firstName)%20%7B%0A%20%20return%20%22No%20such%20contact%22%3B%0A%7D%20else%20if%20(prop%20!%3D%3D%20contacts.prop)%20%7B%0A%20%20return%20%22No%20such%20property%22%3B%0A%7D%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUp(%22Akira%22%2C%20%22likes%22)%3B%0A
bitgrower
@bitgrower
Mar 04 2016 03:10 UTC

what if I said

j *= i;

instead ?

if you don't have a for loop in profile lookup, you definitely need one
John Espinoza
@johnlovespi
Mar 04 2016 03:11 UTC
help with profile lookup
CamperBot
@camperbot
Mar 04 2016 03:11 UTC
no wiki entry for: with profile lookup
asaki444
@asaki444
Mar 04 2016 03:11 UTC
@bitgrower I am still stuck on this problem
John Espinoza
@johnlovespi
Mar 04 2016 03:11 UTC
anyone!
Sri Keerthi N
@keerthinerella
Mar 04 2016 03:11 UTC
helo frnds.. I'm trying to truncate a string
bitgrower
@bitgrower
Mar 04 2016 03:11 UTC
oops, let me change that around @grrttmrtn start j = 1 instead of 0
Sri Keerthi N
@keerthinerella
Mar 04 2016 03:12 UTC
but not getting it completely
Garrett
@grrttmrtn
Mar 04 2016 03:12 UTC
j would equal 4
Sri Keerthi N
@keerthinerella
Mar 04 2016 03:12 UTC

function truncate(str, num) {
// Clear out that junk in your trunk
var trunk = '';
if (str.length > num) {
trunk = str.slice(0, num - 3) + '...';
return trunk;
}

return str;
}

this is what i have used
can anyone help me?
bitgrower
@bitgrower
Mar 04 2016 03:12 UTC

@grrttmrtn -- what if I changed the inner loop to do this instead, @grrttmrtn ...

j *= i;

John Espinoza
@johnlovespi
Mar 04 2016 03:12 UTC
profile look up
Dustin
@glenohumeral13
Mar 04 2016 03:13 UTC
it didnt do anything
http://www.freecodecamp.com/challenges/profile-lookup#?solution=%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUp(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afor%20(var%20i%20%3D%200%3B%20i%20%3C%20contacts.length%3B%20i%2B%2B)%20%7B%0A%20%20if%20(firstName%20%3D%3D%20contacts.firstName%20%26%26%20prop%20%3D%3D%20contacts%5Bi%5D%5Bprop%5D)%20%7B%0A%20%20return%20contacts%5Bi%5D%5Bprop%5D%3B%0A%7D%20else%20if%20(firstName%20!%3D%3D%20contacts.firstName)%20%7B%0A%20%20return%20%22No%20such%20contact%22%3B%0A%7D%20else%20if%20(prop%20!%3D%3D%20contacts.prop)%20%7B%0A%20%20return%20%22No%20such%20property%22%3B%0A%7D%0A%7D%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUp(%22Akira%22%2C%20%22likes%22)%3B%0A
bitgrower
@bitgrower
Mar 04 2016 03:13 UTC
@keerthinerella ..... look carefully at the instructions ...
gloriousjob
@gloriousjob
Mar 04 2016 03:13 UTC
@keerthinerella There's another rule you're missing
Sri Keerthi N
@keerthinerella
Mar 04 2016 03:14 UTC
is that I'm missing in using slice() function>
?
bitgrower
@bitgrower
Mar 04 2016 03:14 UTC
@glenohumeral13 ... describe the data structure in profile lookup ?
David Weedmark
@DavidWeedmark
Mar 04 2016 03:14 UTC
working on tic tac toe... can anyone give me a clue about how to put removeEventListener on divs after they've been clicked? http://codepen.io/weedmark/pen/JXdPVr?editors=1111
Dustin
@glenohumeral13
Mar 04 2016 03:14 UTC
@bitgrower its a nested object. but idk how to access anything.
gloriousjob
@gloriousjob
Mar 04 2016 03:15 UTC
@keerthinerella You've solved the main part of the problem. There's a special case to handle though
bitgrower
@bitgrower
Mar 04 2016 03:15 UTC
@glenohumeral13 -- what is the first character after the equal sign in the data structure definition
Dustin
@glenohumeral13
Mar 04 2016 03:15 UTC
@bitgrower like are the curly bracket pieces accessed by array bracket notation or what
@bitgrower what
Garrett
@grrttmrtn
Mar 04 2016 03:16 UTC
@bitgrower if j=1 adding that to the loop j = 2 if inner loop j *= i
bitgrower
@bitgrower
Mar 04 2016 03:16 UTC
look carefully at the data structure definition ... what is the first character after the equal sign on the 2nd line
bitgrower
@bitgrower
Mar 04 2016 03:17 UTC
so ... if I have a loop like this ...
var num = 3;
j = 2;
for (i = 0; i < num; i++) {
j *= 1;
}
David Weedmark
@DavidWeedmark
Mar 04 2016 03:17 UTC
@grrttmrtn yeah I've got that page practically memorized thanks
CamperBot
@camperbot
Mar 04 2016 03:17 UTC
davidweedmark sends brownie points to @grrttmrtn :sparkles: :thumbsup: :sparkles:
:star: 258 | @grrttmrtn | http://www.freecodecamp.com/grrttmrtn
John Espinoza
@johnlovespi
Mar 04 2016 03:17 UTC
@glenohumeral13 thanx, question tho in like 33 -- && contacts[i][prop]
why is prop in []
Dustin
@glenohumeral13
Mar 04 2016 03:18 UTC
@bitgrower but is the one thing one big array? or can i access the individual curly brackets with contacts[prop]?
David Weedmark
@DavidWeedmark
Mar 04 2016 03:18 UTC
I'm hoping not to repeat the same code for each of eight instances I'll need it.
Dustin
@glenohumeral13
Mar 04 2016 03:18 UTC
@johnlovespi wouldnt that be how i access a property's value?
bitgrower
@bitgrower
Mar 04 2016 03:18 UTC
@glenohumeral13 -- YES ... it is ... a big (well, not too many element) array -- of ... OBJECTS ...
@glenohumeral13 -- so the first thing you must do is address WHICH element of the array ... :)
John Espinoza
@johnlovespi
Mar 04 2016 03:19 UTC
@glenohumeral13 i mean i guess im confused on that as well
all look it to it
Dustin
@glenohumeral13
Mar 04 2016 03:19 UTC
@bitgrower but isnt there only one element? because everything is in contacts[0] ?
bitgrower
@bitgrower
Mar 04 2016 03:19 UTC
@glenohumeral13 -- no ... there are 4 or 5 elements in the array ... (I forget which, think it's 4)
Sri Keerthi N
@keerthinerella
Mar 04 2016 03:19 UTC
yeah..got it :smile:
bitgrower
@bitgrower
Mar 04 2016 03:19 UTC
each element in the array is an object, though ...
remember ... an array can contain ANYTHING ... objects, subarrays, numbers, booleans ... etc
this one contains objects .
the elements of the array, the different objects, are separated by commas ...
so you have [ {...}, {...}, {...}, {...}]
David Weedmark
@DavidWeedmark
Mar 04 2016 03:23 UTC
for anyone looking at my page, I would have thought something like this would work
this.removeEventListener("click");
bitgrower
@bitgrower
Mar 04 2016 03:23 UTC
above my paygrade, @DavidWeedmark
@grrttmrtn
David Weedmark
@DavidWeedmark
Mar 04 2016 03:24 UTC
@bitgrower while that blows my mind, I appreciate you taking a look. thanks! I'll figure it out I'm sure
CamperBot
@camperbot
Mar 04 2016 03:24 UTC
davidweedmark sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 707 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 04 2016 03:24 UTC

so ... if I have a loop like this ...
var num = 3;
j = 2;
for (i = 0; i < num; i++) {
j *= 1;
}

now what would j be equal do ...

and the easiest way to do this is to list out each loop iteration and what j equals at the end of that iteration ...
@DavidWeedmark -- just haven't gotten to that corner of js ...
Mike Sakata
@mgsakata
Mar 04 2016 03:25 UTC
j would be equal to 2
Garrett
@grrttmrtn
Mar 04 2016 03:25 UTC
@DavidWeedmark from the doc it looks like you need to call your function after "click", "function name"
bitgrower
@bitgrower
Mar 04 2016 03:26 UTC
good one ... @mgsakata ... and once again I messed up my example !!! LOL ... let me try again ...
var num = 3;
j = 2;
for (i = 0; i < num; i++) {
j *= i;
}
Garrett
@grrttmrtn
Mar 04 2016 03:26 UTC
@bitgrower totally understanding your examples then looking at this with an empty mind :facepalm
John Espinoza
@johnlovespi
Mar 04 2016 03:26 UTC
@glenohumeral13 hey does your code word
work
Dustin
@glenohumeral13
Mar 04 2016 03:27 UTC
@johnlovespi no sorry
Garrett
@grrttmrtn
Mar 04 2016 03:27 UTC
@bitgrower j = 4
John Espinoza
@johnlovespi
Mar 04 2016 03:27 UTC
ok
Mike Sakata
@mgsakata
Mar 04 2016 03:27 UTC
@bitgrower lol. That new sample makes it a much more interesting question :)
bitgrower
@bitgrower
Mar 04 2016 03:27 UTC

@grrttmrtn -- you have a couple of different pieces I'm building up, @grrttmrtn ...

oh nuts let me try that again ...actually, it would be zero

David Weedmark
@DavidWeedmark
Mar 04 2016 03:28 UTC
@grrttmrtn I actually had that at the bottom and moved it after the last unsuccessful test to see if it would help. guess what... it didn't! lol
bitgrower
@bitgrower
Mar 04 2016 03:28 UTC
var num = 3;
j = 2;
for (i = 1; i < num; i++) {
j *= i;
}
Garrett
@grrttmrtn
Mar 04 2016 03:28 UTC
@bitgrower wouldn't it equal 4 because i counts up until 2 because it's looking to be less than 3 in that last example?
bitgrower
@bitgrower
Mar 04 2016 03:29 UTC
`so ... first time thru the loop it will be j = j * 1
so j will be 2
next time thru the loop it will be j = j * 2
Garrett
@grrttmrtn
Mar 04 2016 03:30 UTC
oh damn
I skipped the first couple of loops lol
and jumped right to two ha
bitgrower
@bitgrower
Mar 04 2016 03:31 UTC
that's alright ... it's a very human tendency ... we want to jump ahead ... and the computer just plods along ... we have to slow down and think like the computer ... 4
Garrett
@grrttmrtn
Mar 04 2016 03:31 UTC
but in your second one j = 4
bitgrower
@bitgrower
Mar 04 2016 03:31 UTC
yes !!! excellent ...
now ... you have to multiply all the elements of your 2-D array ... you know how to address each element, you know how to accumulate a product ... "just" put them together to solve the challenge .. :)
see if you can take the pieces we've built up and plug them into the nesting for loops challenge ...
@glenohumeral13 ... (you've got me all kinds of curious about your nickname, reminds me of my A&P classes) ... how ya doin' ?
Dustin
@glenohumeral13
Mar 04 2016 03:35 UTC
@bitgrower lol it was my favorite joint in the skeletal unit of A&P. still confused
@bitgrower and the 13 is my fav #
bitgrower
@bitgrower
Mar 04 2016 03:36 UTC
LOL I never had a favorite joint ... are you an orthopod or something ? exercise physio guy ?
bitgrower @bitgrower thinks @glenohumeral13 should open a beer "joint" ...
Dustin
@glenohumeral13
Mar 04 2016 03:37 UTC
@bitgrower no just nerd
bitgrower
@bitgrower
Mar 04 2016 03:37 UTC
so ... have you played around with addressing the objects in your array ?
Garrett
@grrttmrtn
Mar 04 2016 03:39 UTC
@bitgrower thank you!
CamperBot
@camperbot
Mar 04 2016 03:39 UTC
grrttmrtn sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 708 | @bitgrower | http://www.freecodecamp.com/bitgrower
Garrett
@grrttmrtn
Mar 04 2016 03:40 UTC
@bitgrower do you work for fcc, or do you just do this for fun?
bitgrower
@bitgrower
Mar 04 2016 03:40 UTC
you figure it out, @grrttmrtn ?!?
fun ...
Garrett
@grrttmrtn
Mar 04 2016 03:40 UTC
Finally ha
Dustin
@glenohumeral13
Mar 04 2016 03:40 UTC
@bitgrower ive been trying to but im not fully getting it
bitgrower
@bitgrower
Mar 04 2016 03:40 UTC
I think FCC is all volunteer ...
@grrttmrtn -- you did really good -- I've seen people struggle much, much more with that ... which is why I built it up the way I did ... I was pretty sure you had the knowledge from previous challenges ... so, I was just reminding you of it ... so you could access it and put the right puzzle pieces together ...
@glenohumeral13 ... gonna call you joint nerd ... LOL ... can you post your code again ?
Abhisek Pattnaik
@abhisekp
Mar 04 2016 03:42 UTC
knock knock :door:
bitgrower
@bitgrower
Mar 04 2016 03:42 UTC
hey there @abhisekp -- ain't seen you in a while ... where ya been ?
Abhisek Pattnaik
@abhisekp
Mar 04 2016 03:42 UTC
@bitgrower FCC main channel :P
bitgrower
@bitgrower
Mar 04 2016 03:42 UTC
hmmm oh yeah, guess I don't have that one open ...
Abhisek Pattnaik
@abhisekp
Mar 04 2016 03:43 UTC
better
bitgrower
@bitgrower
Mar 04 2016 03:43 UTC
better ?
Abhisek Pattnaik
@abhisekp
Mar 04 2016 03:43 UTC
@bitgrower Helping people is better here
Coding vs Chatting bla bla bla
bitgrower
@bitgrower
Mar 04 2016 03:44 UTC
yeah ... sometimes ...
John Espinoza
@johnlovespi
Mar 04 2016 03:45 UTC
@glenohumeral13
hey
got the answea
it makes snence
bitgrower
@bitgrower
Mar 04 2016 03:46 UTC
so ... @glenohumeral13 you've got to use contacts[i]<something>
so you index into your array ... (of objects)
Dustin
@glenohumeral13
Mar 04 2016 03:46 UTC
@bitgrower like with a for loop?
help format
CamperBot
@camperbot
Mar 04 2016 03:46 UTC

:point_right: code formatting [wiki]

Multi line Code

```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 ⏎]

Single line Code

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

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

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

bitgrower
@bitgrower
Mar 04 2016 03:46 UTC
yup
Dustin
@glenohumeral13
Mar 04 2016 03:47 UTC
@bitgrower like with contacts[i][prop] ?
bitgrower
@bitgrower
Mar 04 2016 03:47 UTC
you're already using a for loop I see ...
Dustin
@glenohumeral13
Mar 04 2016 03:47 UTC
bc it didnt work last time
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "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"]
    }
];


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

// Change these values to test your function
lookUp("Akira", "likes");
bitgrower
@bitgrower
Mar 04 2016 03:47 UTC

@glenohumeral13 ... well ... I think the first thing you need to do is look for a firstname, no ?

And how did you use contacts[i][prop] ?

Dustin
@glenohumeral13
Mar 04 2016 03:48 UTC
@bitgrower i did before and it didnt work. like this:
gloriousjob
@gloriousjob
Mar 04 2016 03:48 UTC
@bitgrower I don't know about you but I feel like I see this almost every time I get on here :)
bitgrower
@bitgrower
Mar 04 2016 03:48 UTC
so ... you're iterating thru the loop in your loop statement, but you are not using the indexing available to you ...
Dustin
@glenohumeral13
Mar 04 2016 03:48 UTC
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "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"]
    }
];


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

// Change these values to test your function
lookUp("Akira", "likes");
bitgrower
@bitgrower
Mar 04 2016 03:49 UTC
lol @gloriousjob -- there are some challenges that come up a lot ...
@glenohumeral13 -- where are you using contacts[i] please ?
Dustin
@glenohumeral13
Mar 04 2016 03:49 UTC
@bitgrower yeah idk what im "indexing" (is that just running through a for loop?). is contacts[0] the bit about akira laine? or all the four objects?
bitgrower
@bitgrower
Mar 04 2016 03:49 UTC
ahh ... just once .. you have to use it everywhere within the loop ...
Dustin
@glenohumeral13
Mar 04 2016 03:50 UTC
@bitgrower why?
bitgrower
@bitgrower
Mar 04 2016 03:50 UTC
contacts[0] is this ...
   {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    }
gloriousjob
@gloriousjob
Mar 04 2016 03:51 UTC
@glenohumeral13 Think of it like this: var arr = [3, 5, 7, 9]. To get 5, you'd do arr1.
bitgrower
@bitgrower
Mar 04 2016 03:51 UTC
because you have to use it to point to the right element in the array ...
Dustin
@glenohumeral13
Mar 04 2016 03:51 UTC
@gloriousjob ahh i see
gloriousjob
@gloriousjob
Mar 04 2016 03:51 UTC
But you'd have to do that every time arr[1]
Dustin
@glenohumeral13
Mar 04 2016 03:52 UTC

ok so i have this which isnt working ```
//Setup
var contacts = [
{
"firstName": "Akira",
"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"]
}
];

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

// Change these values to test your function
lookUp("Akira", "likes");
```

bitgrower
@bitgrower
Mar 04 2016 03:52 UTC
think of each element (each object) as a room ... the index opens the door to THAT room ...
Dustin
@glenohumeral13
Mar 04 2016 03:52 UTC
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "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"]
    }
];


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

// Change these values to test your function
lookUp("Akira", "likes");
bitgrower
@bitgrower
Mar 04 2016 03:52 UTC
@glenohumeral13 -- you can edit your message ... you need to put the backticks on lines of their own
oops ... you did it ...
change this if (firstName == contacts.firstName && prop == contacts[i].prop) {
to this ` if (firstName == contacts[i].firstName && prop == contacts[i].prop) {
and so on ... wherever you are using contacts within the loop (below the loop iteration definition .. you need to use contacts[i]
Dustin
@glenohumeral13
Mar 04 2016 03:54 UTC
@bitgrower but that doesnt work either
gloriousjob
@gloriousjob
Mar 04 2016 03:54 UTC
@glenohumeral13 Well, it should get you closer
@glenohumeral13 There's another thing but make sure you understand how this works first. It's key to understanding loops
Dustin
@glenohumeral13
Mar 04 2016 03:57 UTC
@gloriousjob idk. my current understanding is that i am using a for loop to run through each object in the array. contacts[i].firstName is the value of the firstName property of each object in the array, where "i" is a number being incremented by the for loop. contacts[i].prop SHOULD be any property that the "prop" variable stands for
bitgrower
@bitgrower
Mar 04 2016 03:57 UTC

if I have

retArr = [];
myArr = [1,2,3];
for (var i = 0; i < myArr.length; i++) {
   retArr.push(myArr[i]);
}

do you know what this does?

do you know what retArr will contain after the loop finishes running ...
Dustin
@glenohumeral13
Mar 04 2016 03:58 UTC
@bitgrower yeah youre running through the myArr array with i and pushing the indexed array value into retArr. at the end retArr will be [1, 2, 3]
Sidharth Kriplani
@sidkrip
Mar 04 2016 03:59 UTC
wiki Sum All Primes
CamperBot
@camperbot
Mar 04 2016 03:59 UTC

:point_right: algorithm sum all primes [wiki]

Explanation:

The explanation for this problem is very simple. You will generate a list of prime numbers up to the number you are given as a parameter. Then you need to add them all up and return that value. The tricky part is on generating the list of prime numbers. I suggest you find a code or a good math algorithm that you can turn into code.

:pencil: read more about algorithm sum all primes on the FCC Wiki

bitgrower
@bitgrower
Mar 04 2016 03:59 UTC
excellent!!!!
This message was deleted
Dustin
@glenohumeral13
Mar 04 2016 03:59 UTC
This message was deleted
demipixel
@demipixel
Mar 04 2016 04:00 UTC
should i golf it
bitgrower
@bitgrower
Mar 04 2016 04:00 UTC
This message was deleted
demipixel
@demipixel
Mar 04 2016 04:00 UTC
??
John Martens
@martensclass
Mar 04 2016 04:00 UTC
Help needed With Exact Change Challenge - It's late, I'm tired, maybe I am overlooking something obvious.
I am getting the right answers for the change but not as 2 decimal places. (ie - ["DIME", 0.2], ["QUARTER", 0.5], ["ONE", 1], etc - instead of ["DIME", 0.20], ["QUARTER", 0.50], ["ONE", 1.00]). I can use toFixed(2) to force 2 decimals but then it converts to a string and that is not accepted as the right answer either. Converting back to a number loses the decimal places again. I am stumped. How do I force a number to be 2 decimal places without converting it to a string?
CamperBot
@camperbot
Mar 04 2016 04:00 UTC
no wiki entry for: needed with exact change challenge - its late im tired maybe i am overlooking something obviousi am getting the right answers for the change but not as 2 decimal places ie - dime 02 quarter 05 one 1 etc - instead of dime 020 quarter 050 one 100 i can use tofixed2 to force 2 decimals but then it converts to a string and that is not accepted as the right answer either converting back to a number loses the decimal places again i am stumped how do i force a number to be 2 decimal places without converting it to a string
Dustin
@glenohumeral13
Mar 04 2016 04:01 UTC
@bitgrower what was gonna be your next example?
demipixel
@demipixel
Mar 04 2016 04:01 UTC
@martensclass That doesn't matter
Don't use toFixed(2) as that will convert it to a string
0.5 === 0.50 so no worries
bitgrower
@bitgrower
Mar 04 2016 04:03 UTC

@glenohumeral13 -- if you have an array ... assume each element of the array is a room ... the room can contain anything ... but in order to get to anything within the room, you still have to access it by the array index ...

...so, if the element is an object ... then you need to use the array indexing followed by your object addressing ...

your object address can be either dot or bracket ...

if you know the name, and the name is appropriate ... you can use the dot notation ...

contacts[i].firstname

Eric Meling
@Gnilemcire
Mar 04 2016 04:04 UTC
help Record Collection
CamperBot
@camperbot
Mar 04 2016 04:04 UTC

:point_right: checkpoint record collection [wiki]

Checkpoint: Record Collection

Instructions

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

If value is non-blank (value !== ""), then update or set the value for the prop.

If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.

If value is blank, delete that prop.

Always return the entire collection object.

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about checkpoint record collection on the FCC Wiki

bitgrower
@bitgrower
Mar 04 2016 04:04 UTC

or if it's a property named in a variable, then you will use bracket notation

contacts[i][prop]

Sidharth Kriplani
@sidkrip
Mar 04 2016 04:05 UTC
wiki Sum All Odd Fibonacci Numbers
CamperBot
@camperbot
Mar 04 2016 04:05 UTC

:point_right: algorithm sum all odd fibonacci numbers [wiki]

Explanation:

You will need to gather all the Fibonacci numbers and then check for the odd ones. Once you get the odd ones then you will add them all. The last number should be the number given as a parameter if it actually happens to be an off Fibonacci number.

:pencil: read more about algorithm sum all odd fibonacci numbers on the FCC Wiki

Dustin
@glenohumeral13
Mar 04 2016 04:05 UTC
@bitgrower i have this but it isnt working
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "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"]
    }
];


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

// Change these values to test your function
lookUp("Akira", "likes");
bitgrower
@bitgrower
Mar 04 2016 04:06 UTC
just fyi, it's generally a good idea to use the triple equals ==> === sign instead of the double == sign
Dustin
@glenohumeral13
Mar 04 2016 04:07 UTC
@bitgrower yeah i had that originally but i scrapped it in case it was causing the problems
Sidharth Kriplani
@sidkrip
Mar 04 2016 04:07 UTC
wiki Steamroller
CamperBot
@camperbot
Mar 04 2016 04:07 UTC

:point_right: algorithm steamroller [wiki]

Explanation:

This problem seems simple but you need to make sure to flatten any array, regardless of the level which is what adds a bit of difficulty to the problem.

:pencil: read more about algorithm steamroller on the FCC Wiki

bitgrower
@bitgrower
Mar 04 2016 04:10 UTC

anyway .. let's take a look ...

firstName is "Akira" ... so you look at contacts[i].firstName ... and yes, it's Akira ... but then we have to see if this particular object has a property "likes" ... it doesn't ... so it goes to your ELSE statement ...
well ... we already know that firstName === contacts[i].firstName, so it skips that ...

however ... it looks to see if prop !== contacts[i][prop] (which we already determined before, btw)

...and it doesn't ... so it returns "No such property"

since you are returning from the function, you don't look at any of the other objects in your array ...
if you want to do so, you shouldn't return from the loop
Sidharth Kriplani
@sidkrip
Mar 04 2016 04:11 UTC
wiki smallest common multiple
CamperBot
@camperbot
Mar 04 2016 04:11 UTC

:point_right: algorithm smallest common multiple [wiki]

Explanation:

The smallest common multiple between two numbers is the smallest number that
both numbers can divide into. This concept can be extended to more than two
numbers as well.

We can first start with just finding the smallest common multiple between two
numbers. Naively, you can start writing out multiple of each number until you
write a multiple that exists from both numbers.

An example would be the numbers 3 and 4. The multiples of 3 are 3, 6, 9, 12, 15, 18, ... and the multiples of 4 are 4, 8, 12, 16, 20, .... The
first smallest number we run into in both lists is 12 so this is the smallest
common multiple between 3 and 4.

This problem can be confusing because most people look for the smallest common
multiple of just the two numbers but forget the keyword range. However, this
means that if you are given [1,5], then you have to check for the smallest
common multiple for all the numbers [1,2,3,4,5] that is evenly divisible by
all of them.

:pencil: read more about algorithm smallest common multiple on the FCC Wiki

bitgrower
@bitgrower
Mar 04 2016 04:13 UTC

it's important ... what @gloriousjob said ... you need to understand what the code is doing ...

you can put your code in here: pythontutor.com/javascript.html ... and see a cool visualization of what is happening in your code ...

(although I had someone vociferously complain that pythontutor.com was wrong on one of his pieces of code...unfortunately, he was wrong ... )
Evgeny
@PoisonHawk
Mar 04 2016 04:14 UTC
Hi all! I just finished Title Case a Sentence. This is my solusion
This message was deleted
bitgrower
@bitgrower
Mar 04 2016 04:14 UTC
Hey @PoisonHawk -- generally not a good idea to post solutions in here .. use the codereview room ... but it looks like an interesting solution !!!
help rooms
CamperBot
@camperbot
Mar 04 2016 04:15 UTC

:point_right: help rooms [wiki]

Help Rooms

Choose the right room for your question!
:pencil: read more about help rooms on the FCC Wiki
Rex
@RexChip
Mar 04 2016 04:16 UTC

function queue(arr, item) {
// Your code here

return arr; // Change this line
}

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

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

what shoud i do?
Evgeny
@PoisonHawk
Mar 04 2016 04:17 UTC
i just want ask how make better this solution, but i cannot normally show code)
bitgrower
@bitgrower
Mar 04 2016 04:17 UTC
@rexChip -- you need to use 2 array functions ... here are some you can choose from ... shift, unshift, pop, push ... 2 of them will be used in solving the problem ... BUT you will need to know how to use them correctly ... when you do, it's a simple solution ...
yeah, I understand, @PoisonHawk -- that's why there's a CodeReview room :)
Evgeny
@PoisonHawk
Mar 04 2016 04:18 UTC
@bitgrower ok)
Rex
@RexChip
Mar 04 2016 04:22 UTC
@bitgrower thanks , but i don't know why to use ... where i can use 2 array function
CamperBot
@camperbot
Mar 04 2016 04:22 UTC
rexchip sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 709 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 04 2016 04:23 UTC
you have an array, you want to add an item to the array, and then you want to remove (and return) an item from the array (different item) ...
Sumeet Batheja
@bathejasumeet
Mar 04 2016 04:30 UTC
Probably enqueue with pop or dequeue with push
Or you can use filter
Eric Meling
@Gnilemcire
Mar 04 2016 04:30 UTC
help Record Collection
CamperBot
@camperbot
Mar 04 2016 04:31 UTC

:point_right: checkpoint record collection [wiki]

Checkpoint: Record Collection

Instructions

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

If value is non-blank (value !== ""), then update or set the value for the prop.

If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.

If value is blank, delete that prop.

Always return the entire collection object.

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about checkpoint record collection on the FCC Wiki

mukhtar2t
@mukhtar2t
Mar 04 2016 04:41 UTC
hi, How I can format a code in a black square
demipixel
@demipixel
Mar 04 2016 04:41 UTC
help format
CamperBot
@camperbot
Mar 04 2016 04:41 UTC

:point_right: code formatting [wiki]

Multi line Code

```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 ⏎]

Single line Code

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

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

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

Richard Corbett
@reacorbett
Mar 04 2016 04:42 UTC
hello everyone!!! :)
MD Alsaffar
@Cyberistic
Mar 04 2016 04:42 UTC
Heyyy
mukhtar2t
@mukhtar2t
Mar 04 2016 04:42 UTC
hello
demipixel
@demipixel
Mar 04 2016 04:42 UTC
Hello
mukhtar2t
@mukhtar2t
Mar 04 2016 04:43 UTC

I am wondering why the two codes below giving different result:

First code:

function convert(num) {
  var str = "";
  var tmp;

  tmp = Math.floor(num/1000);
  for(i=0;i<tmp;i++)
    str += "M";

  tmp = Math.floor((num%1000)/100);
  if(tmp === 9) 
    str += "CM";

  else if(tmp >= 5) {
    str += "D";
    for(i=0;i<tmp-5;i++)
      str += "C";
  }
  else if(tmp === 4) 
    str += "CD";
  else if(tmp < 4) {
    for(i=0;i<tmp;i++)
      str += "C";
  }

  tmp = Math.floor((num%100)/10);
  if(tmp === 9)
    str += "XC";
  else if(tmp >= 5) {
    str += "L";
    for(i=0;i<tmp-5;i++)
      str += "X";
  }
  else if(tmp === 4) 
    str += "XL";
  else if(tmp < 4) {
    for(i=0;i<tmp;i++)
      str += "X";
  }

  tmp = num%10;
  if(tmp === 9)
    str += "IX";
  else if(tmp >= 5) {
    str += "V";
    for(i=0;i<tmp-5;i++)
      str += "I";
  }
  else if(tmp === 4) 
    str += "IV";
  else if(tmp < 4) {
    for(i=0;i<tmp;i++)
      str += "I";
  }
  return str;
}

convert(3999);
Richard Corbett
@reacorbett
Mar 04 2016 04:43 UTC
after not messing with java script for a few day, i have become slightly rusty.
mukhtar2t
@mukhtar2t
Mar 04 2016 04:44 UTC
Second code:
function convert(num) {
  var str = "";
  var tmp;

  tmp = Math.floor(num/1000);
  for(i=0;i<tmp;i++)
    str += "M";

  tmp = Math.floor((num%1000)/100);
  if(tmp === 9) 
    str += "CM";

  else if(tmp >= 5) {
    str += "D";
    for(i=0;i<tmp-5;i++)
      str += "C";
  }
  else if(tmp === 4) 
    str += "CD";
  else if(tmp < 4) 
    for(i=0;i<tmp;i++)
      str += "C";


  tmp = Math.floor((num%100)/10);
  if(tmp === 9)
    str += "XC";
  else if(tmp >= 5) {
    str += "L";
    for(i=0;i<tmp-5;i++)
      str += "X";
  }
  else if(tmp === 4) 
    str += "XL";
  else if(tmp < 4) {
    for(i=0;i<tmp;i++)
      str += "X";
  }

  tmp = num%10;
  if(tmp === 9)
    str += "IX";
  else if(tmp >= 5) {
    str += "V";
    for(i=0;i<tmp-5;i++)
      str += "I";
  }
  else if(tmp === 4) 
    str += "IV";
  else if(tmp < 4) {
    for(i=0;i<tmp;i++)
      str += "I";
  }
  return str;
}

convert(3999);
notice that the only diffrence that I have removed the brackets from the below:
else if(tmp < 4) 
    for(i=0;i<tmp;i++)
      str += "C";
Abhisek Pattnaik
@abhisekp
Mar 04 2016 04:52 UTC
@mukhtar2t :point_right: FreeCodeCamp/CodeReview for Code Review after completion
David Weedmark
@DavidWeedmark
Mar 04 2016 04:58 UTC
@mukhtar2t my guess would be that by removing the brackets, Javascript is inferring there is a ; at the line break, which it sometimes does when a needed ; is missing
MD Alsaffar
@Cyberistic
Mar 04 2016 04:58 UTC
help Return Early Pattern for Functions
CamperBot
@camperbot
Mar 04 2016 04:58 UTC

:point_right: challenge return early pattern for functions [wiki]

Challenge: Return Early Pattern for Functions

When a return statement is reached, the execution of the current function stops and control returns to the calling location.

Example

function myFun() {
  console.log("Hello");
  return "World";
  console.log("byebye")
}
myFun();

The above outputs "Hello" to the console, returns "World", but "byebye" is never output, because the function exits at the return statement.
:pencil: read more about challenge return early pattern for functions on the FCC Wiki

MD Alsaffar
@Cyberistic
Mar 04 2016 05:07 UTC
Could anyone help me with that challenge? can't seem to understand it
David Weedmark
@DavidWeedmark
Mar 04 2016 05:09 UTC
@Cyberistic which part exactly?
MD Alsaffar
@Cyberistic
Mar 04 2016 05:11 UTC
@DavidWeedmark I don't really know what to do.
mukhtar2t
@mukhtar2t
Mar 04 2016 05:11 UTC
@DavidWeedmark thanks for your point
CamperBot
@camperbot
Mar 04 2016 05:11 UTC
mukhtar2t sends brownie points to @davidweedmark :sparkles: :thumbsup: :sparkles:
:star: 372 | @davidweedmark | http://www.freecodecamp.com/davidweedmark
mukhtar2t
@mukhtar2t
Mar 04 2016 05:12 UTC
thanks @abhisekp
CamperBot
@camperbot
Mar 04 2016 05:12 UTC
mukhtar2t sends brownie points to @abhisekp :sparkles: :thumbsup: :sparkles:
:star: 2244 | @abhisekp | http://www.freecodecamp.com/abhisekp
David Weedmark
@DavidWeedmark
Mar 04 2016 05:12 UTC
@Cyberistic okay well you want to specify if a is less than zero or b is less than zero that the console replies with undefined, right?
MD Alsaffar
@Cyberistic
Mar 04 2016 05:13 UTC
@DavidWeedmark Yes
David Weedmark
@DavidWeedmark
Mar 04 2016 05:13 UTC
so those are the three things to focus on
MD Alsaffar
@Cyberistic
Mar 04 2016 05:13 UTC
return a < 0 || b < 0;
is what I did
David Weedmark
@DavidWeedmark
Mar 04 2016 05:13 UTC
close
MD Alsaffar
@Cyberistic
Mar 04 2016 05:14 UTC
To be honest, I don't understand the whole undefined thing
David Weedmark
@DavidWeedmark
Mar 04 2016 05:14 UTC
you just tell it "return undefined"
MD Alsaffar
@Cyberistic
Mar 04 2016 05:15 UTC
mhm..?
David Weedmark
@DavidWeedmark
Mar 04 2016 05:15 UTC
if a < 0 || b < 0, then "return undefined"
MD Alsaffar
@Cyberistic
Mar 04 2016 05:16 UTC
Am I allowed to use if statements?
David Weedmark
@DavidWeedmark
Mar 04 2016 05:16 UTC
if you type nothing but "return undefined" the console will respond with "undefined"
oh yeah, you need that for this
MD Alsaffar
@Cyberistic
Mar 04 2016 05:16 UTC
Ahh okay
David Weedmark
@DavidWeedmark
Mar 04 2016 05:17 UTC
return is like saying "console.log"
let me know if you get it. I'll be around for another 20 mins or so
MD Alsaffar
@Cyberistic
Mar 04 2016 05:18 UTC
I completed the challenge
kevharvell
@kevharvell
Mar 04 2016 05:18 UTC
could use some help on filtering out on my array. Basically it is only filtering out my first i value argument when I want it to go through my for loop and filter all of the arguments. I believe it has something to do with the return value !== args[i];
function destroyer(arr) {
  // Remove all the values
  var args = Array.prototype.slice.call(arguments);

  var filtered;

  filtered = arr.filter(function destroy(value) {
    for (var i = 1; i < args.length; i++) {
      return value !== args[i];
    }
  });

  return filtered;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
MD Alsaffar
@Cyberistic
Mar 04 2016 05:18 UTC
but I still don't get it
David Weedmark
@DavidWeedmark
Mar 04 2016 05:19 UTC
@Cyberistic ah, great!
in this case "undefined" is just a word. you could say "return pickles" or "return abc" and it would give you back those instead
MD Alsaffar
@Cyberistic
Mar 04 2016 05:20 UTC
Erhhh
David Weedmark
@DavidWeedmark
Mar 04 2016 05:20 UTC
I think the focus of this one is to get you used to "return" which you will be using a lot now
MD Alsaffar
@Cyberistic
Mar 04 2016 05:21 UTC
What does return exactly do
David Weedmark
@DavidWeedmark
Mar 04 2016 05:22 UTC
here, it just tells the browser to return something back to you in the console, much like console.log does
MD Alsaffar
@Cyberistic
Mar 04 2016 05:22 UTC
@DavidWeedmark I will do some research later, Thanks for the help though.
CamperBot
@camperbot
Mar 04 2016 05:22 UTC
cyberistic sends brownie points to @davidweedmark :sparkles: :thumbsup: :sparkles:
:star: 373 | @davidweedmark | http://www.freecodecamp.com/davidweedmark
John Irle
@JohnIrle
Mar 04 2016 05:23 UTC
Could someone help me with the Drop it challenge? I pass all but one test.
function drop(arr, func) {
  // Drop them elements.

  for (var i = 0; i <= arr.length; i++) {
    if (func(arr[0])) {
      break;
    } else {
      arr.shift();
    }
  }

  return arr;
}

drop([1, 2, 3, 4], function(n) {return n > 5; });
Andrew Charlebois
@andrewchar
Mar 04 2016 05:27 UTC
i have a peice of code thats acting really weird. in my second if statement i have it calling data.stream.preview.small.. that part is doing its job correct but its making any of the offline stream be removed from the list. cannot figure out why. http://codepen.io/andrewchar/pen/bpdLGv?editors=1011
if i console.log before the if statement, everything comes back as normal. if i console.log after the if statement. it only shows the streams that are online
David Weedmark
@DavidWeedmark
Mar 04 2016 05:28 UTC
@doudeman I think you want to return arr instead of the break
Andrew Charlebois
@andrewchar
Mar 04 2016 05:28 UTC
but i cant see any errors with the code
gloriousjob
@gloriousjob
Mar 04 2016 05:28 UTC
@doudeman Are you supposed to use 0 instead of the index?
John Irle
@JohnIrle
Mar 04 2016 05:29 UTC
@gloriousjob The idea is that the array gets smaller with each shift so I keep checking the first element
gloriousjob
@gloriousjob
Mar 04 2016 05:29 UTC
@doudeman You should probably use a while instead of a for because that's a bit confusing but anyway...
@doudeman which case fails?
John Irle
@JohnIrle
Mar 04 2016 05:30 UTC
@DavidWeedmark That gives me the same answer
@gloriousjob drop([1, 2, 3, 4], function(n) {return n > 5;}) should return []. I'm getting an array with [4]
gloriousjob
@gloriousjob
Mar 04 2016 05:31 UTC
@doudeman Funny, I was going to ask what happens when the whole array is dropped
David Weedmark
@DavidWeedmark
Mar 04 2016 05:32 UTC
@doudeman its giving you 3,4 instead of []?
gloriousjob
@gloriousjob
Mar 04 2016 05:32 UTC
@doudeman You might want to consider your exit conditional
@doudeman in the for loop
Rex
@RexChip
Mar 04 2016 05:32 UTC
help stand
CamperBot
@camperbot
Mar 04 2016 05:32 UTC

:point_right: challenge understand boolean values [wiki]

Understand Boolean Values

Booleans can only hold the value of either true or false. They are basically little on-off switches.

:pencil: read more about challenge understand boolean values on the FCC Wiki

Rex
@RexChip
Mar 04 2016 05:32 UTC
help stand in line
CamperBot
@camperbot
Mar 04 2016 05:32 UTC

:point_right: checkpoint stand in line [wiki]

Checkpoint: Stand In Line

About queues

In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.

Instructions

Write a function queue which takes an "array" and an "item" as arguments.

Add the item onto the end of the array, then remove the first element of the array.

The queue function should return the element that was removed.

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about checkpoint stand in line on the FCC Wiki

John Irle
@JohnIrle
Mar 04 2016 05:33 UTC
@gloriousjob the break?
gloriousjob
@gloriousjob
Mar 04 2016 05:33 UTC
@doudeman Yes, and also what your exit criteria is before the break
@doudeman exit of the for loop, that is
@doudeman Consider what your for loop does if I give it arr = []
John Irle
@JohnIrle
Mar 04 2016 05:35 UTC
@gloriousjob Ah! That makes sense. Hmmm
Zach
@Moose1551
Mar 04 2016 05:39 UTC
Can someone explain to me why this is wrong?:
function golfScore(par, strokes) {
  // Only change code below this line
 if (1) {
    return "Hole-in-one!";
  } else if (2) {
    return "Eagle";
  } else if (3) {
    return "Birdie";
  } else if (4) {
    return "Par";
  } else if (5) {
    return "Bogey";
  } else if (6) {
    return "Double Bogey";
  } else if (strokes >= 7) {
    return "Go Home!";
  }

  // Only change code above this line
}

// Change these values to test
golfScore(4, 2);
John Irle
@JohnIrle
Mar 04 2016 05:40 UTC
@gloriousjob The interesting thing is that my code is basically the same solution that is in the wiki
gloriousjob
@gloriousjob
Mar 04 2016 05:41 UTC
@doudeman wiki?
David Weedmark
@DavidWeedmark
Mar 04 2016 05:41 UTC
@Moose1551 you need to compare the strokes to the par
John Irle
@JohnIrle
Mar 04 2016 05:42 UTC
wiki drop it
CamperBot
@camperbot
Mar 04 2016 05:42 UTC

:point_right: algorithm drop it [wiki]

Explanation:

Basically while the second argument is not true, you will have to remove the first element from the left of the array that was passed as the first argument.

:pencil: read more about algorithm drop it on the FCC Wiki

David Weedmark
@DavidWeedmark
Mar 04 2016 05:42 UTC
@doudeman interesting. yours was just a bit off from what mine was too
gloriousjob
@gloriousjob
Mar 04 2016 05:43 UTC
@doudeman Oh, I didn't realize there were spoilers
@doudeman Your exit criteria for the for loop is different
John Irle
@JohnIrle
Mar 04 2016 05:43 UTC
It is?
MD Alsaffar
@Cyberistic
Mar 04 2016 05:44 UTC
@Moose1551 It should be like this
 if (strokes == 1) {
    return "Hole-in-one!"; 
  }
gloriousjob
@gloriousjob
Mar 04 2016 05:44 UTC
@doudeman look closely
@doudeman I'd tell you straight up but this is how you learn :)
John Irle
@JohnIrle
Mar 04 2016 05:46 UTC
@gloriousjob the "<="? because making it just less than returns [3, 4]
gloriousjob
@gloriousjob
Mar 04 2016 05:46 UTC
@doudeman Try changing it :)
Roy Liu
@pololkk2000
Mar 04 2016 05:46 UTC

challenge:Word Blanks
code:
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result ="dog" + "big" + "ran" + "quickly";

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

so i don't know how to solve it.

gloriousjob
@gloriousjob
Mar 04 2016 05:47 UTC
@doudeman oh, I see it now
@doudeman yeah, that's why you should use a while loop instead of a for
@doudeman because think about what i is and what your array length is when you do the iterations
John Irle
@JohnIrle
Mar 04 2016 05:48 UTC
@gloriousjob I tried a while loop and it only solved the test case I can't pass
gloriousjob
@gloriousjob
Mar 04 2016 05:48 UTC
first iteration: i = 0, array = [1, 2, 3, 4]
@doudeman What's the next iteration?
@doudeman also, first iteration, arr.length = 4
@doudeman I know this is basic but can you give the three values for the next iteration? It'll help you see the problem
@doudeman using your for loop
John Irle
@JohnIrle
Mar 04 2016 05:51 UTC
okay so all I had to do was declare a variable before the for loop and set it equal to arr.length
gloriousjob
@gloriousjob
Mar 04 2016 05:51 UTC
@doudeman Can you see why?
John Irle
@JohnIrle
Mar 04 2016 05:51 UTC
that way I had a number that didn't change
gloriousjob
@gloriousjob
Mar 04 2016 05:51 UTC
@doudeman There you go :)
John Irle
@JohnIrle
Mar 04 2016 05:52 UTC
@gloriousjob thanks
CamperBot
@camperbot
Mar 04 2016 05:52 UTC
doudeman sends brownie points to @gloriousjob :sparkles: :thumbsup: :sparkles:
:star: 306 | @gloriousjob | http://www.freecodecamp.com/gloriousjob
Zach
@Moose1551
Mar 04 2016 06:00 UTC
@Cyberistic , @DavidWeedmark , thank you. I'm getting there, but I'm stuck again. I don't understand why "Bogey, Double Bogey, and Go Home!" aren't working...
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 (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!";
  }

  // Only change code above this line
}

// Change these values to test
golfScore(4, 2);
CamperBot
@camperbot
Mar 04 2016 06:00 UTC
moose1551 sends brownie points to @cyberistic and @davidweedmark :sparkles: :thumbsup: :sparkles:
:star: 374 | @davidweedmark | http://www.freecodecamp.com/davidweedmark
:star: 240 | @cyberistic | http://www.freecodecamp.com/cyberistic
MD Alsaffar
@Cyberistic
Mar 04 2016 06:10 UTC
@Moose1551 Whats the error?
Zach
@Moose1551
Mar 04 2016 06:11 UTC
@Cyberistic , no error. It's just not passing all the tests. Earlier, I was failing 4 tests, but now it's just the one "Par" Here's the revised code:
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 == 4 && par == 4) {
    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!";
  }

  // Only change code above this line
}

// Change these values to test
golfScore(4, 2);
MD Alsaffar
@Cyberistic
Mar 04 2016 06:13 UTC
@Moose1551 This is where you are wrong
else if (strokes == 4 && par == 4) {
    return "Par";
Rita Alfonso
@alfonsotech
Mar 04 2016 06:13 UTC
else if (strokes == 4 && par == 4) { return "Par";
You want your strokes to equal your par, no && needed
MD Alsaffar
@Cyberistic
Mar 04 2016 06:14 UTC
^ That
Zach
@Moose1551
Mar 04 2016 06:15 UTC
Ah! So "else if (strokes == 4 par == 4) { return "Par"; }"
Rita Alfonso
@alfonsotech
Mar 04 2016 06:18 UTC
not quite
you only need one condition statement, not two
Did you get it @Moose1551 ?
Zach
@Moose1551
Mar 04 2016 06:24 UTC
Not quite. I think I'm alomost there, though.
Ryan Park
@rpark4
Mar 04 2016 06:24 UTC
Hi, I'm having trouble with the record collection problem. How do you access object properties with variable more than one variable deep?
function update(id, prop, value) {
if (value !== "" && prop !== "tracks"){
collection[id][prop].push(value);
}
Abhishek Kumar
@abhishekKumar1
Mar 04 2016 06:24 UTC
@Moose1551 You are comparing storks and par everywhere else why not in par
Markus Kiili
@Masd925
Mar 04 2016 06:26 UTC
@rpark4 When the prop is not tracks, you wan't to just assign the value, not push. Use assignment operator.
Zach
@Moose1551
Mar 04 2016 06:26 UTC
Like this?
} else if (par == 4) {
return "Par";
MD Alsaffar
@Cyberistic
Mar 04 2016 06:27 UTC
Yes
Zach
@Moose1551
Mar 04 2016 06:29 UTC
When I changed it to that, I ended up not being able to return 4 tests instead of 1.
Ryan Park
@rpark4
Mar 04 2016 06:30 UTC
@Moose1551 if strokes = 4 and par =4 then strokes = par
@Masd925 Thanks. I'm still struggling though
CamperBot
@camperbot
Mar 04 2016 06:31 UTC
rpark4 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1129 | @masd925 | http://www.freecodecamp.com/masd925
Abhishek Kumar
@abhishekKumar1
Mar 04 2016 06:31 UTC
@Moose1551 dude not like that compare stokes and par why are you sending 4 it's not in your input function
MD Alsaffar
@Cyberistic
Mar 04 2016 06:33 UTC
Okay I need help with the counting cards challenge
Here is my code
var count = 0;

function cc(card) {
  // Only change code below this line
  switch (card) {
    case 2: 
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      break; 
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count--;
      break;
  }
    if (card <= 6 && card >= 2){
      return count + " Bet";

    }else if (card >= 7 && card <= 9 ){
      return count + " Hold";

    }else if (card == 10 || card === 'J' || card === 'Q' || card === 'K' || card === 'A'){
      return count + " Hold";
    }




  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc(2);
Zach
@Moose1551
Mar 04 2016 06:33 UTC
@abhishekKumar1 , is this what you mean?
function golfScore(par, strokes) {
  // Only change code below this line
 if (strokes == 1 && par == 4) {
    return "Hole-in-one!";
  } else if (strokes <=par-2) {
    return "Eagle";
  } else if (strokes == par-1) {
    return "Birdie";
  } else if (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!";
  }

  // Only change code above this line
}

// Change these values to test
golfScore(4, 2);
MD Alsaffar
@Cyberistic
Mar 04 2016 06:33 UTC
cant get through "Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"" task
Rita Alfonso
@alfonsotech
Mar 04 2016 06:34 UTC
@Moose1551 it's just "else if strokes = par" - try that
Markus Kiili
@Masd925
Mar 04 2016 06:35 UTC
@Cyberistic Bet/hold decision is based on count.
MD Alsaffar
@Cyberistic
Mar 04 2016 06:35 UTC

@Moose1551

else if (strokes == par) {
    return "Par";

Is what you need to do

Ryan Park
@rpark4
Mar 04 2016 06:35 UTC
@Cyberistic your if statements should be focusing on the value of count.
MD Alsaffar
@Cyberistic
Mar 04 2016 06:36 UTC
@rpark4 Which means..?
Ryan Park
@rpark4
Mar 04 2016 06:37 UTC
it means that you want to bet if count is positive, hold if it's 0 and fold if its negative
Zach
@Moose1551
Mar 04 2016 06:37 UTC
I did it right before I read the suggestions! Lightbulb moment, haha. Thanks, @abhishekKumar1 @alfonsotech @Cyberistic @rpark4
CamperBot
@camperbot
Mar 04 2016 06:37 UTC
moose1551 sends brownie points to @abhishekkumar1 and @alfonsotech and @cyberistic and @rpark4 :sparkles: :thumbsup: :sparkles:
:warning: moose1551 already gave cyberistic points
:star: 353 | @alfonsotech | http://www.freecodecamp.com/alfonsotech
:star: 226 | @rpark4 | http://www.freecodecamp.com/rpark4
:star: 370 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
Ryan Park
@rpark4
Mar 04 2016 06:38 UTC
woops. there is no folding
Rita Alfonso
@alfonsotech
Mar 04 2016 06:38 UTC

@Cyberistic

if (card <= 6 && card >= 2){
      return count + " Bet";

    }else if (card >= 7 && card <= 9 ){
      return count + " Hold";

    }else if (card == 10 || card === 'J' || card === 'Q' || card === 'K' || card === 'A'){
      return count + " Hold";
    }

This is the problem. maybe you've never sat at the blackjack table and counted cards, aye?

Ryan Park
@rpark4
Mar 04 2016 06:39 UTC
i did
MD Alsaffar
@Cyberistic
Mar 04 2016 06:39 UTC
@alfonsotech Never lol
Thank you both @rpark4
CamperBot
@camperbot
Mar 04 2016 06:39 UTC
cyberistic sends brownie points to @alfonsotech and @rpark4 :sparkles: :thumbsup: :sparkles:
:star: 354 | @alfonsotech | http://www.freecodecamp.com/alfonsotech
:star: 227 | @rpark4 | http://www.freecodecamp.com/rpark4
Zach
@Moose1551
Mar 04 2016 06:39 UTC
What I'm confused about is how strokes = par if it par was never assigned a value in the first "if"
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!";
  }
Like, how does it know that 4 strokes = par?
Mohammed Shehab
@mshehab93
Mar 04 2016 06:40 UTC
Hi, I need some help with a lesson I've been stuck on for a good number of days
Ryan Park
@rpark4
Mar 04 2016 06:40 UTC
par and strokes are both input
Rita Alfonso
@alfonsotech
Mar 04 2016 06:40 UTC
@Cyberistic lol The way it works is if the total count of the cards coming out is positive, you want to bet; if negative or neutral, you want to hold. The count is the number you've been adding and subtracting in the switch statemnt.
Ryan Park
@rpark4
Mar 04 2016 06:41 UTC
at the beginning of the function
Mohammed Shehab
@mshehab93
Mar 04 2016 06:41 UTC

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

DJ
@qualitymanifest
Mar 04 2016 06:41 UTC
golfScore(5,5); function golfScore(par, strokes) {
Mohammed Shehab
@mshehab93
Mar 04 2016 06:41 UTC
function lookUp(firstName, prop){
// Only change code below this line
  if (firstName === contacts.firstName && prop === contacts.prop) {
    return contacts.prop;
  } else if (firstName !== contacts.firstName) {
    return "No such contact";
  } else if (firstName !== contacts.firstName && prop !== contacts.hasOwnProperty(prop)) {
    return "No such property";
  }
Ryan Park
@rpark4
Mar 04 2016 06:41 UTC
thanks @qualitymanifest
CamperBot
@camperbot
Mar 04 2016 06:41 UTC
rpark4 sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
Mohammed Shehab
@mshehab93
Mar 04 2016 06:42 UTC
:/ all my other lessons in basic js is complete except this one
CamperBot
@camperbot
Mar 04 2016 06:42 UTC
:star: 1053 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Mar 04 2016 06:42 UTC
@rpark4 no, tax you
CamperBot
@camperbot
Mar 04 2016 06:42 UTC
qualitymanifest sends brownie points to @rpark4 :sparkles: :thumbsup: :sparkles:
:star: 228 | @rpark4 | http://www.freecodecamp.com/rpark4
Rita Alfonso
@alfonsotech
Mar 04 2016 06:42 UTC
@mshehab93 Yes, that's a tough one. Profile Look Up, right?
MD Alsaffar
@Cyberistic
Mar 04 2016 06:42 UTC
@alfonsotech Never played that game, so how would I know? lol
Mohammed Shehab
@mshehab93
Mar 04 2016 06:42 UTC
@alfonsotech yes
Zach
@Moose1551
Mar 04 2016 06:43 UTC
@rpark4 , I see! I was paying to much attention to "if (strokes = 1)...
*too
Mohammed Shehab
@mshehab93
Mar 04 2016 06:43 UTC
I can't get to understand the handle on the method .hasOwnProperty
Rita Alfonso
@alfonsotech
Mar 04 2016 06:43 UTC
:thumbsup: @Moose1551
Mohammed Shehab
@mshehab93
Mar 04 2016 06:43 UTC
and accessing the objects
Zach
@Moose1551
Mar 04 2016 06:44 UTC
@alfonsotech , how'd you do that thumbs up?
Mohammed Shehab
@mshehab93
Mar 04 2016 06:44 UTC
@Moose1551 if you hover the mouse over that thumbs up itll give you its code
Rita Alfonso
@alfonsotech
Mar 04 2016 06:44 UTC
type a colon symbol and "thumb" and you get icon options
" :thumbsup: "
@mshehab93 That's the last one I have left as well so I haven't done it, but maybe we can do it together now?
Marina
@chandra90
Mar 04 2016 06:47 UTC
Hello everyone! Please help me with the task :"Golf Code"
Rita Alfonso
@alfonsotech
Mar 04 2016 06:47 UTC
hi chandra go for it
Marina
@chandra90
Mar 04 2016 06:47 UTC
    return "Eagle";
What I did wrong?
if(strokes=1){
    return "Tiny";
  }else if (strokes<=par-2){
    return "Eagle";
  }else if(par-1){
    return "Birdie";
  }else if(par){
    return "Par";
  }else if(Par+1){
   return "Bogey";
  }else if(par+2){
    return "Double Bogey";
  }else if(strokes>=par+3){
    return "Go Home!";
  }else {
  return "Change Me";
  }
Zach
@Moose1551
Mar 04 2016 06:48 UTC
lol
I just banged my head against the wall on that one.
Marina
@chandra90
Mar 04 2016 06:48 UTC
@Moose1551 oops lol
if(strokes=1){
    return "Hole-in-one";
  }else if (strokes<=par-2){
    return "Eagle";
  }else if(par-1){
    return "Birdie";
  }else if(par){
    return "Par";
  }else if(Par+1){
   return "Bogey";
  }else if(par+2){
    return "Double Bogey";
  }else if(strokes>=par+3){
    return "Go Home!";
  }else {
  return "Change Me";
  }
@Moose1551 Zach can you help?
Rahul Jain
@rj-unstoppable
Mar 04 2016 06:50 UTC
'''
CamperBot
@camperbot
Mar 04 2016 06:50 UTC
:bulb: to format code use backticks! ``` more info
Zach
@Moose1551
Mar 04 2016 06:50 UTC
@chandra90 , you should compare strokes and par in each "else if" (conditional) statement.
Rahul Jain
@rj-unstoppable
Mar 04 2016 06:50 UTC

''' function myTest(val) {
var answer = "";
// Only change code below this line
switch (val) {
case 1:
answer = "alpha";
break;
case 2:
answer = "beta";
break;
case 3:
answer = "gamma";
break;
case 4:
answer = "delta";

// Only change code above this line
return answer;
}
}
// Change this value to test
myTest(1);
'''

CamperBot
@camperbot
Mar 04 2016 06:50 UTC
:bulb: to format code use backticks! ``` more info
Rahul Jain
@rj-unstoppable
Mar 04 2016 06:50 UTC
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
  case 1:
    answer = "alpha";
    break;
  case 2:
    answer = "beta";
    break;
   case 3:
    answer = "gamma";
    break;
   case 4:
    answer = "delta";

  // Only change code above this line  
  return answer;  
}
}
// Change this value to test
myTest(1);
casse 1 ,2,3 are not workinig
Zach
@Moose1551
Mar 04 2016 06:50 UTC
@chandra90 , I'd show you the code, but the others didn't and I learned a bit from it.
Rahul Jain
@rj-unstoppable
Mar 04 2016 06:50 UTC
can anyone help
Abhishek Kumar
@abhishekKumar1
Mar 04 2016 06:51 UTC
ok @chandra90 if you use else if(par) and pass any number it will pass
you have to compare it with stokes like you did above in if and first else if statement
Ryan Park
@rpark4
Mar 04 2016 06:51 UTC
i'm dying on the record collection challenge. I don't know how to assign value within an object using only variables: function update(id, prop, value) {
if (value !== "" && prop !== "tracks"){
collection[id][prop][value]=value;
}
V Arun Kumar
@arunvkumr
Mar 04 2016 06:51 UTC
just completed portfolio challenge. need some feedback. :smile:
http://codepen.io/arunkumrv/pen/oxvLoN
Zach
@Moose1551
Mar 04 2016 06:51 UTC
@chandra90 , when you first use strokes, use the "==" symbol.
Abhishek Kumar
@abhishekKumar1
Mar 04 2016 06:53 UTC
@rpark4 can you post your whole code and tell the challenge name and use this
help format
CamperBot
@camperbot
Mar 04 2016 06:53 UTC

:point_right: code formatting [wiki]

Multi line Code

```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 ⏎]

Single line Code

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

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

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

Markus Kiili
@Masd925
Mar 04 2016 06:53 UTC
@rpark4 collection[id][prop] accesses the property value, so you assign to it with: collection[id][prop]=value;
Marina
@chandra90
Mar 04 2016 06:53 UTC
@Moose1551 got it.But other one?
Ankit Panwar
@coderNoob
Mar 04 2016 06:54 UTC
@arunkumrv The footer is kind of big making it look empty
Ryan Park
@rpark4
Mar 04 2016 06:55 UTC
thanks again
Rita Alfonso
@alfonsotech
Mar 04 2016 06:55 UTC
@rpark4 I'll take a look, but can you post all your code so it will jog my memory
Ryan Park
@rpark4
Mar 04 2016 06:56 UTC
@Masd925 just hooked me up. thanks though and @alfonsotech @abhishekKumar1
CamperBot
@camperbot
Mar 04 2016 06:56 UTC
rpark4 sends brownie points to @masd925 and @alfonsotech and @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
:warning: rpark4 already gave masd925 points
:star: 356 | @alfonsotech | http://www.freecodecamp.com/alfonsotech
:star: 371 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
V Arun Kumar
@arunvkumr
Mar 04 2016 06:56 UTC
@coderNoob thanks. i'm on it
CamperBot
@camperbot
Mar 04 2016 06:56 UTC
arunkumrv sends brownie points to @codernoob :sparkles: :thumbsup: :sparkles:
:star: 345 | @codernoob | http://www.freecodecamp.com/codernoob
Rita Alfonso
@alfonsotech
Mar 04 2016 07:01 UTC
else if(par){ return "Par"; @chandra90
Matthew Stettner
@mstettner
Mar 04 2016 07:02 UTC
hello everyone. Hows everyone doing tonight?
Rita Alfonso
@alfonsotech
Mar 04 2016 07:02 UTC
Hi @mstettner loverly, you?
Marina
@chandra90
Mar 04 2016 07:02 UTC
@mstettner Hello! do not even ask lol
Ryan Park
@rpark4
Mar 04 2016 07:03 UTC
fabulously @mstettner. And yourself?
Ivan Driuk
@IDriuk
Mar 04 2016 07:04 UTC
Hello! What is the shortest regEx for resolving http://www.freecodecamp.com/challenges/validate-us-telephone-numbers?
Matthew Stettner
@mstettner
Mar 04 2016 07:06 UTC
doing well. About to start some more JS learning. hopefully not to fustrating
@chandra90 tough night?
Marina
@chandra90
Mar 04 2016 07:07 UTC
@mstettner just one challenge is *
Ankit Panwar
@coderNoob
Mar 04 2016 07:08 UTC
@IDriuk This is a tough one. I would suggest you figure it out yourself. Its a great feeling when you get it done all by yourself.
@IDriuk You can test your cases on some useful sites like RegEx
Marina
@chandra90
Mar 04 2016 07:09 UTC
@Moose1551 thanks
CamperBot
@camperbot
Mar 04 2016 07:09 UTC
chandra90 sends brownie points to @moose1551 :sparkles: :thumbsup: :sparkles:
:star: 201 | @moose1551 | http://www.freecodecamp.com/moose1551
Ivan Driuk
@IDriuk
Mar 04 2016 07:11 UTC
@coderNoob I use read-search-ask, and found /^(?:(?:+?1\s(?:[.-]\s)?)?(?:(\s([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s(?:[.-]\s)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s(?:[.-]\s)?([0-9]{4})(?:\s(?:#|x.?|ext.?|extension)\s(\d+))?$/ This is working, but somebody must know better solution.
Ryan Park
@rpark4
Mar 04 2016 07:11 UTC
// 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][prop].push(value); } else if (value === "")
well that worked miserably
can't say i didn't try to format that correctly
Matthew Stettner
@mstettner
Mar 04 2016 07:12 UTC
anyone know how to comlete the Convert Celsius to Fahrenheitlesson?
Ryan Park
@rpark4
Mar 04 2016 07:13 UTC
anyways, I'm supposed to delete prop?
@mstettner yes, what are you struggling with?
Matthew Stettner
@mstettner
Mar 04 2016 07:14 UTC
@rpark4 I'm not sure how to write it in to javascript.
i understand the formula
  • 9 / 5 + 32
Ryan Park
@rpark4
Mar 04 2016 07:14 UTC
ok
Matthew Stettner
@mstettner
Mar 04 2016 07:14 UTC
I just dont know how to appply that formaula into JS
Ryan Park
@rpark4
Mar 04 2016 07:17 UTC
so you have a function with an input for celsius
are you following so far?
Matthew Stettner
@mstettner
Mar 04 2016 07:18 UTC
Celcius = * 9 / 5 + 32; @rpark4
Ankit Panwar
@coderNoob
Mar 04 2016 07:18 UTC
@IDriuk There may be many solutions. A better one? I'm not sure.
Matthew Stettner
@mstettner
Mar 04 2016 07:18 UTC
yeah this is my function * 9 / 5 + 32. correct?
@rpark4
Ryan Park
@rpark4
Mar 04 2016 07:18 UTC
yeah, so when they give you a function with an input for celsius. you need to define fahrenheit
Ankit Panwar
@coderNoob
Mar 04 2016 07:18 UTC
@IDriuk I'm not sure if this is a good solution or bad but here is my solution
function telephoneCheck(str) {
  // Good luck!
  if(str.match(/(\({1})\d{3}(\){1})/g)){
    if(str.match(/^1?[\s-]?\(?(\d{3})\)?[\s-]?(\d{3})[\s-]?\d{4}$/g)){
       return true;
    }
    else
      return false;
  }
  else if(str.match(/^1?[\s-]?\d{3}[\s-]?\d{3}[\s-]?\d{4}$/g))
    return true;
  else
    return false;

}
Matthew Stettner
@mstettner
Mar 04 2016 07:19 UTC
okay how do I define fahrenheit?
Ankit Panwar
@coderNoob
Mar 04 2016 07:19 UTC
google it
Ryan Park
@rpark4
Mar 04 2016 07:19 UTC
fahrenheit = celsius * 9 / 5 + 32
Ankit Panwar
@coderNoob
Mar 04 2016 07:19 UTC
and use brackets
Matthew Stettner
@mstettner
Mar 04 2016 07:19 UTC
yeah bc right now it is saying that fahrenheit is not defined
@rpark4 makes sense
Ryan Park
@rpark4
Mar 04 2016 07:20 UTC
you'll probably need ()
celsius * (9/5) + 32
anyone know how to delete prop at the end of the record collection challenge?
Matthew Stettner
@mstettner
Mar 04 2016 07:22 UTC
its giving me a little warning triangle saying "Invalid type of value 'celcius*(9/5) + 32"
Ryan Park
@rpark4
Mar 04 2016 07:22 UTC
spelling
Matthew Stettner
@mstettner
Mar 04 2016 07:22 UTC
@rpark4 i think i got it
I had '' around it
Ryan Park
@rpark4
Mar 04 2016 07:23 UTC
ahh
there you have it
Matthew Stettner
@mstettner
Mar 04 2016 07:23 UTC
I need to define fahrenheit also??
which is fahrenheit = celsius?
Ryan Park
@rpark4
Mar 04 2016 07:24 UTC
no, you only need to define fahrenheit, celsius is arleady defined.
Matthew Stettner
@mstettner
Mar 04 2016 07:25 UTC
how do I define fahrenheit?
'fahrenheit not defined'
that what it is saying
Ryan Park
@rpark4
Mar 04 2016 07:25 UTC
you just type fahrenheit = celsius * (9/5) +32
;
that should be the only thing you have to do for that challenge
Matthew Stettner
@mstettner
Mar 04 2016 07:27 UTC
it says, "did you mean to return a conditional instead of an assignment?
function convert(celsius) {
  // Only change code below this line


  // Only change code above this line
  if ( typeof fahrenheit !== celsius * (9/5) + 32 ) {
    return fahrenheit;
  } else {
    return  fahrenheit = celsius * (9/5) +32

;
  }
}

// Change the inputs below to test your code
convert(30);
Ryan Park
@rpark4
Mar 04 2016 07:28 UTC
read the comments
Tim Großmann
@timgrossmann
Mar 04 2016 07:28 UTC
Hello, i'm currently stuck at the "Seek and Destroy" Algorithm challenge...
how can i access the parameters to remove from the array ? there is only 1 parameter in the function signature...
Ankit Panwar
@coderNoob
Mar 04 2016 07:29 UTC
@rpark4 delete object.propertyname;
Like this
T N Surender
@tnsurender
Mar 04 2016 07:29 UTC
Hi guys .. I am working on to make "weather web app" , can anyone tell , how to trigger the events when the page starts loading ?
demipixel
@demipixel
Mar 04 2016 07:29 UTC
bf Seek and Destroy
CamperBot
@camperbot
Mar 04 2016 07:29 UTC

:fire:Bonfire: Seek and Destroy :link:

function destroyer(arr) {
  // Remove all the values
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.

more info:  bf details | bf links | hint

demipixel
@demipixel
Mar 04 2016 07:29 UTC
@timgrossmann You can add more:
function destroyer(arr, num1, num2) {
...
@tnsurender Are you using jquery?
Matthew Stettner
@mstettner
Mar 04 2016 07:29 UTC
there are no comments. it says function convert referenceError: fahrenheit is not defined
T N Surender
@tnsurender
Mar 04 2016 07:29 UTC
yup
Tim Großmann
@timgrossmann
Mar 04 2016 07:29 UTC
this challenge is so odd
T N Surender
@tnsurender
Mar 04 2016 07:30 UTC
@demipixel yup
demipixel
@demipixel
Mar 04 2016 07:30 UTC
@tnsurender
$(document).ready(function() {
   ...
});
Tim Großmann
@timgrossmann
Mar 04 2016 07:30 UTC
if i console.log the art, there is only the array... But there is an undefined number of Parameters i need to take into consideration
demipixel
@demipixel
Mar 04 2016 07:30 UTC
@timgrossmann why?
T N Surender
@tnsurender
Mar 04 2016 07:30 UTC
@demipixel I will try and get back to you :) :)
Ryan Park
@rpark4
Mar 04 2016 07:30 UTC
@mstettner you will want to push the reset button. then read the //only change code below this line // only change code above this line comments
demipixel
@demipixel
Mar 04 2016 07:30 UTC
@tnsurender alright haha
Matthew Stettner
@mstettner
Mar 04 2016 07:31 UTC
@rpark4 okay
Ryan Park
@rpark4
Mar 04 2016 07:31 UTC
between those two comments, you will define fahrenheit like we had talked about
Tim Großmann
@timgrossmann
Mar 04 2016 07:32 UTC
how can i say: this function should take a not yet specified number of parameters ?
demipixel
@demipixel
Mar 04 2016 07:33 UTC
@timgrossmann Doesn't the function always take 3 paramaters though?
Tim Großmann
@timgrossmann
Mar 04 2016 07:33 UTC
no, only the arr
also there is a test case where 3 arguments are passed
demipixel
@demipixel
Mar 04 2016 07:33 UTC
Which?
Matthew Stettner
@mstettner
Mar 04 2016 07:34 UTC
@rpark4 thanks i got it
CamperBot
@camperbot
Mar 04 2016 07:34 UTC
mstettner sends brownie points to @rpark4 :sparkles: :thumbsup: :sparkles:
:star: 229 | @rpark4 | http://www.freecodecamp.com/rpark4
Tim Großmann
@timgrossmann
Mar 04 2016 07:34 UTC
destroyer([3, 5, 1, 2, 2], 2, 3, 5) should return 1.
demipixel
@demipixel
Mar 04 2016 07:34 UTC
Oh hm
DJ
@qualitymanifest
Mar 04 2016 07:34 UTC
@demipixel it varies. you have to use arguments on this one
Matthew Stettner
@mstettner
Mar 04 2016 07:34 UTC
I have no idea how I would know to do that? I mean should i have known what to do? @rpark4
Markus Kiili
@Masd925
Mar 04 2016 07:35 UTC
@timgrossmann You should use arguments object for those extra arguments.
Matthew Stettner
@mstettner
Mar 04 2016 07:35 UTC
also how could anyone even know how to set that entire code? seems insanely tough to understand?? @rpark4
Tim Großmann
@timgrossmann
Mar 04 2016 07:35 UTC
ohh, thanks @Masd925 i'll look up this one
CamperBot
@camperbot
Mar 04 2016 07:35 UTC
timgrossmann sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1130 | @masd925 | http://www.freecodecamp.com/masd925
Ryan Park
@rpark4
Mar 04 2016 07:36 UTC
yeah, to some degree. if you read through the code, you see that they have a function named "convert" with the input "celsius" That means that somewhere the code will tell you what "celsius" is, or it will explain how it will get it.
So you look for "convert()" again in the code
Ryan Park
@rpark4
Mar 04 2016 07:37 UTC
and you see convert(30) at the bottom
that means that the input is 30, so "celsius = 30
then you have the if statement : if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}
so that means that if the variable fahrenheit is a number, return fahrenheit.
otherwise return "fahrenheit is not defined"
Matthew Stettner
@mstettner
Mar 04 2016 07:41 UTC
@rpark4 I hope to one day be able to write that code and understand it. to me right now it is unbelievable that someone could come up with that
Ryan Park
@rpark4
Mar 04 2016 07:41 UTC
just keep at it bro
Matthew Stettner
@mstettner
Mar 04 2016 07:41 UTC
I wouldnt know where to start
@rpark4 im trying but every lesson that goes by I have fifty more questions
Ryan Park
@rpark4
Mar 04 2016 07:42 UTC
keep reading over it, step-by-step. In my experience peeps moves too fast through. if you have a question, even if you got the challenge right, come by the help room and ask.
Pedro Abel Díaz Sánchez
@coderHook
Mar 04 2016 07:42 UTC

@dcnr Yeap! it work.. I had to erase the checking function add(2); jeje

Thanks for all the support, It help me a lot!

CamperBot
@camperbot
Mar 04 2016 07:42 UTC
abel1987 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 756 | @dcnr | http://www.freecodecamp.com/dcnr
Ryan Park
@rpark4
Mar 04 2016 07:43 UTC
you're definitely in the right place to be lost with a lot of this. You're in good company.
thanks @coderNoob I'm not sure how to use it though
CamperBot
@camperbot
Mar 04 2016 07:45 UTC
rpark4 sends brownie points to @codernoob :sparkles: :thumbsup: :sparkles:
:star: 346 | @codernoob | http://www.freecodecamp.com/codernoob
Matthew Stettner
@mstettner
Mar 04 2016 07:45 UTC
@rpark4 true, everyone is super helpful
Ryan Park
@rpark4
Mar 04 2016 07:47 UTC
@coderNoob nevermind Thanks it worked
CamperBot
@camperbot
Mar 04 2016 07:47 UTC
rpark4 sends brownie points to @codernoob :sparkles: :thumbsup: :sparkles:
:warning: rpark4 already gave codernoob points
Ryan Park
@rpark4
Mar 04 2016 07:48 UTC
camperbot is being a points nazi
Ankit Panwar
@coderNoob
Mar 04 2016 07:48 UTC
What if somebody thanks himself/herself?
Ryan Park
@rpark4
Mar 04 2016 07:49 UTC
I am doing a fantastic job
haha
Thanks everyone, I'm out
Matthew Stettner
@mstettner
Mar 04 2016 07:51 UTC
later
thanks @mstettner
CamperBot
@camperbot
Mar 04 2016 07:51 UTC
sorry mstettner, you can't send brownie points to yourself! :sparkles: :sparkles:
Ankit Panwar
@coderNoob
Mar 04 2016 07:52 UTC
Lol
Matthew Stettner
@mstettner
Mar 04 2016 07:52 UTC
camperbot doesnt like that
@camperbot thanks
CamperBot
@camperbot
Mar 04 2016 07:52 UTC
mstettner sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star: 1308 | @camperbot | http://www.freecodecamp.com/camperbot
Matthew Stettner
@mstettner
Mar 04 2016 07:52 UTC
hahahah
Ankit Panwar
@coderNoob
Mar 04 2016 07:52 UTC
He likes brownies
Matthew Stettner
@mstettner
Mar 04 2016 07:52 UTC
weird lil bot
I thought i had this one! what is wrong?
"I am a \"double quoted\" string inside \"double quotes\".";
DJ
@qualitymanifest
Mar 04 2016 07:58 UTC
@mstettner get rid of the period
Ankit Panwar
@coderNoob
Mar 04 2016 07:58 UTC
@mstettner Link to the BF please.
Matthew Stettner
@mstettner
Mar 04 2016 07:59 UTC
BF?
CamperBot
@camperbot
Mar 04 2016 07:59 UTC
we're talking about bonfire :fire: Bonfire: Seek and Destroy
Matthew Stettner
@mstettner
Mar 04 2016 07:59 UTC
bonfire?
CamperBot
@camperbot
Mar 04 2016 07:59 UTC
we're talking about bonfire :fire: Bonfire: Seek and Destroy
Ankit Panwar
@coderNoob
Mar 04 2016 07:59 UTC
If I remember correctly you need to use the same " or ' at the start and at the end of the sentence. And anything in between you have to use the alternate of " or ' that you used at the start of the sentence.
DJ
@qualitymanifest
Mar 04 2016 07:59 UTC
@mstettner if you're assigning that to var myStr you just need to get rid of the period
Ankit Panwar
@coderNoob
Mar 04 2016 07:59 UTC
@mstettner Yes
DJ
@qualitymanifest
Mar 04 2016 08:00 UTC
otherwise, you need to assign it to var myStr and get rid of the period
Matthew Stettner
@mstettner
Mar 04 2016 08:00 UTC
@qualitymanifest i guess I assigned it to var myVar
I am still learning all this lingo
DJ
@qualitymanifest
Mar 04 2016 08:00 UTC
@mstettner copy and paste the whole line
"bonfire" was just the name for what are now referred to as "algorithms". these "challenges" you're doing used to be called "waypoints"
CamperBot
@camperbot
Mar 04 2016 08:01 UTC
Sorry, can't find a bonfire called was just the name for what are now referred to as algorithms these challenges youre doing used to be called waypoints. [ Check the map? ]
DJ
@qualitymanifest
Mar 04 2016 08:01 UTC
the change in naming happened a month or two ago
Matthew Stettner
@mstettner
Mar 04 2016 08:01 UTC
@qualitymanifest I got it. I needed to "assign" it to var myVar by putting the = sign.
kirbyedy
@kirbyedy
Mar 04 2016 08:02 UTC
shhhh camperbot does not know about that :D
Matthew Stettner
@mstettner
Mar 04 2016 08:02 UTC
thanks @qualitymanifest @coderNoob
CamperBot
@camperbot
Mar 04 2016 08:02 UTC
mstettner sends brownie points to @qualitymanifest and @codernoob :sparkles: :thumbsup: :sparkles:
:star: 1054 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
:star: 347 | @codernoob | http://www.freecodecamp.com/codernoob
Matthew Stettner
@mstettner
Mar 04 2016 08:02 UTC
what is BF?
Ankit Panwar
@coderNoob
Mar 04 2016 08:02 UTC
Bonfire
CamperBot
@camperbot
Mar 04 2016 08:02 UTC
we're talking about bonfire :fire: Bonfire: Seek and Destroy
Ankit Panwar
@coderNoob
Mar 04 2016 08:02 UTC
they are the exercises that you are doing.
Matthew Stettner
@mstettner
Mar 04 2016 08:02 UTC
seek and destroy is a bonfire
so the lessons are called BF's?
hence the little fire symbol?
Michael Nazari
@mikenaza
Mar 04 2016 08:03 UTC
I'm actually stuck on the Seek and Destroy challenge
Matthew Stettner
@mstettner
Mar 04 2016 08:04 UTC
you mean bonfire?
Ankit Panwar
@coderNoob
Mar 04 2016 08:04 UTC
@mstettner Yes
Michael Nazari
@mikenaza
Mar 04 2016 08:04 UTC
function destroyer(arr) { 
  arguments[0].filter(function(val){
    return val != arguments[i];
  });
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Ankit Panwar
@coderNoob
Mar 04 2016 08:04 UTC
@mikenaza What is i in there?
It has to be defined first.
Michael Nazari
@mikenaza
Mar 04 2016 08:04 UTC
I can't seem to figure out how to iterate through the given arguments that come after the array
@coderNoob Well I had a for loop in there
But I guess you can't have loops inside of functions
@coderNoob I realized that when I use "arguments" inside the filter method, it's taking the arguments from the callback function, not the destroyer function
Joseph
@revisualize
Mar 04 2016 08:09 UTC
The https://www.codeschool.com/free-weekend just starts in about 13 hours.
Matthew Stettner
@mstettner
Mar 04 2016 08:10 UTC
@revisualize what is that about?
Joseph
@revisualize
Mar 04 2016 08:11 UTC
Read the page?
Matthew Stettner
@mstettner
Mar 04 2016 08:12 UTC
@revisualize just says free from march 4-6th
kirbyedy
@kirbyedy
Mar 04 2016 08:12 UTC
what does that mean ?
Markus Kiili
@Masd925
Mar 04 2016 08:13 UTC
@mikenaza You can have loop inside function.
@mikenaza In order to use destroyers arguments inside the filter callback function, you can store (destroyer function) arguments object on a variable, turn it into an array, or pass it into the filter callback as value of this.
Matthew Stettner
@mstettner
Mar 04 2016 08:14 UTC
@revisualize can I take any course?
kirbyedy
@kirbyedy
Mar 04 2016 08:14 UTC
and you have only 2 days to finish it ?
Matthew Stettner
@mstettner
Mar 04 2016 08:14 UTC
@kirbyedy good question
at the end they ask for your credit card info?
well I signed up. well see what happens
kirbyedy
@kirbyedy
Mar 04 2016 08:16 UTC
I already have an account there from before, but they pretty much dissapointed me with that its free course...
NOT!
and of course give us your credit card number...
so it was ctrl+Q straight away
Matthew Stettner
@mstettner
Mar 04 2016 08:17 UTC
@kirbyedy interesting
hey does anyone know if there are meet ups for FCC in LA?
kirbyedy
@kirbyedy
Mar 04 2016 08:18 UTC
check the facebook page for your city
Michael Nazari
@mikenaza
Mar 04 2016 08:19 UTC
@Masd925 Ahh alright
function destroyer(arr) {
  var theArguments = arguments;
  arguments[0].filter(function(val){
    for(var i = 1; i <= arr.length; i++) {
     return val != theArguments[i];
   }
  });
}
That's what I'm at now, but I think it may be using the arguments of the callback function still
Joseph
@revisualize
Mar 04 2016 08:20 UTC
@mstettner I wouldn't give them any of my money. I haven't and I've completed all of the free options. I'm going to try and power through as much as possible this weekend.
Matthew Stettner
@mstettner
Mar 04 2016 08:20 UTC
@kirbyedy thanks
CamperBot
@camperbot
Mar 04 2016 08:20 UTC
mstettner sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 592 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
Matthew Stettner
@mstettner
Mar 04 2016 08:20 UTC
@revisualize cool
I have a question if a string is surrounded by single quotes i.e. '' then it can have double quotes i.e"" without have to use \\\\\?
if thats the case why not always use double quotes?''
Markus Kiili
@Masd925
Mar 04 2016 08:23 UTC
@mikenaza You should loop theArguments, so change the limit. You can return false if you find a match, but true only after the loop.
@mikenaza Always use strict equality === and !==. Abstract equality only bites you in the butt sometimes.
Matthew Stettner
@mstettner
Mar 04 2016 08:24 UTC
I mean why not always use single quotes
??
cannelflow
@cannelflow
Mar 04 2016 08:27 UTC
@mstettner you can always use single quote
Michael Nazari
@mikenaza
Mar 04 2016 08:28 UTC
function destroyer(arr) {
  var theArguments = arguments;
  arguments[0].filter(function(val){
    for(var i = 1; i <= theArguments.length; i++) {
     if(val === theArguments[i]) {
       return false;
     } 
    } return true;
  });
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Markus Kiili
@Masd925
Mar 04 2016 08:29 UTC
@mikenaza Return statement?
Matthew Stettner
@mstettner
Mar 04 2016 08:29 UTC
so if I use single quotes I wont have to escape my double quotes within the single quotes? ugh whatever that question is probably to difficult to read and understand
Michael Nazari
@mikenaza
Mar 04 2016 08:31 UTC
@Masd925 what do you mean?
oh i need to return arr
Markus Kiili
@Masd925
Mar 04 2016 08:32 UTC
@mikenaza You can just put the return on the start of filter line.
DJ
@qualitymanifest
Mar 04 2016 08:32 UTC
@mstettner nah it makes sense, and you are correct: https://repl.it/BsqY
Matthew Stettner
@mstettner
Mar 04 2016 08:33 UTC
@qualitymanifest thanks
CamperBot
@camperbot
Mar 04 2016 08:33 UTC
mstettner sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:warning: mstettner already gave qualitymanifest points
Matthew Stettner
@mstettner
Mar 04 2016 08:33 UTC
I am trying to encode the following sequence. I am getting close?
var myStr = \ \ \t \t \r \n;
Michael Nazari
@mikenaza
Mar 04 2016 08:34 UTC
@Masd925 Sorry I'm not sure what you mean by that
Robert Uivarosi
@URobert
Mar 04 2016 08:34 UTC
@mstettner sort of, you have too many spaces in there
@mstettner which was the name of that exercise ?
Michael Nazari
@mikenaza
Mar 04 2016 08:35 UTC
I have it after the filter method is completely done
Matthew Stettner
@mstettner
Mar 04 2016 08:35 UTC
Escape Sequences in Strings
@URobert
Markus Kiili
@Masd925
Mar 04 2016 08:35 UTC
@mikenaza I mean this:
function destroyer(arr) {
  var theArguments = arguments;
  return arr.filter(function(val){
    for(var i = 1; i <= theArguments.length; i++) {
     if(val === theArguments[i]) {
       return false;
     } 
    } 
    return true;
  });
}
Matthew Stettner
@mstettner
Mar 04 2016 08:35 UTC
says unexpected early end of program and an unexpected slash
@URobert
Robert Uivarosi
@URobert
Mar 04 2016 08:36 UTC
@mstettner give me a sec
Matthew Stettner
@mstettner
Mar 04 2016 08:36 UTC
yeah np
DJ
@qualitymanifest
Mar 04 2016 08:37 UTC
@mstettner get rid of the space in between \ \
Robert Uivarosi
@URobert
Mar 04 2016 08:38 UTC
@mstettner you got two mistakes
DJ
@qualitymanifest
Mar 04 2016 08:38 UTC
oh yeah. quotation marks
Robert Uivarosi
@URobert
Mar 04 2016 08:38 UTC
@mstettner 1)your variable is a string so make sure you use "".
Michael Nazari
@mikenaza
Mar 04 2016 08:38 UTC
@Masd925 Ahh, how does it work when you are calling the method on arr? It will filter through every argument when we only need to filter through the first.
Is it because we used return so it only went through once?
Robert Uivarosi
@URobert
Mar 04 2016 08:39 UTC
@mstettner 2)your backslash escape is off... @qualitymanifest mentioned that already above
Markus Kiili
@Masd925
Mar 04 2016 08:39 UTC
@mikenaza arr only has the first passed argument which is the array.
@mikenaza arr is the same as arguments[0]
Michael Nazari
@mikenaza
Mar 04 2016 08:41 UTC
@Masd925 Okay understood. Do you know if there's a way to console.log() a method to see the code inside? To see what exactly methods like .filter() or .map() are doing?
Markus Kiili
@Masd925
Mar 04 2016 08:43 UTC
@mikenaza I don't know if that is possible. The functionality of all those methods is specified on ECMAScript standard http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
Matthew Stettner
@mstettner
Mar 04 2016 08:44 UTC
@URobert @qualitymanifest thanks guys I got it. I forgot those quotes
CamperBot
@camperbot
Mar 04 2016 08:44 UTC
mstettner sends brownie points to @urobert and @qualitymanifest :sparkles: :thumbsup: :sparkles:
:warning: mstettner already gave qualitymanifest points
:star: 657 | @urobert | http://www.freecodecamp.com/urobert
Robert Uivarosi
@URobert
Mar 04 2016 08:45 UTC
@mstettner yw. Happy coding !
Matthew Stettner
@mstettner
Mar 04 2016 08:45 UTC
@qualitymanifest sorry coamperbot says no brownie pts for you yet
DJ
@qualitymanifest
Mar 04 2016 08:45 UTC
@mstettner haha. im not worried about it. tax :+1:
CamperBot
@camperbot
Mar 04 2016 08:45 UTC
qualitymanifest sends brownie points to @mstettner :sparkles: :thumbsup: :sparkles:
:star: 157 | @mstettner | http://www.freecodecamp.com/mstettner
Michael Nazari
@mikenaza
Mar 04 2016 08:46 UTC
@Masd925 Okay cool. Thanks for all your help!
CamperBot
@camperbot
Mar 04 2016 08:46 UTC
mikenaza sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1131 | @masd925 | http://www.freecodecamp.com/masd925
Matthew Stettner
@mstettner
Mar 04 2016 08:46 UTC
oh snap! I just got me some b pts. thanks
Robert Uivarosi
@URobert
Mar 04 2016 08:46 UTC
LoL tax works for thank you
Matthew Stettner
@mstettner
Mar 04 2016 08:47 UTC
hey guys you know on your iphone when you hit the space bar twice it makes period"." can I program my computer to do the same thing?
thats the reason I'm going through code camp. thats all i want to learn lol
Rahul Jain
@rj-unstoppable
Mar 04 2016 08:58 UTC
// Setup
function phoneticLookup(val) {
  var result = "undefined";

  // Only change code below this line
  var obj = {
    "alpha": "Adams",
    "bravo": "Boston",
    "charlie": "Chicago",
    "delta": "Denver",
    "echo": "Easy",
    "foxtrot": "Frank";
    }
  result = obj[val];
  // Only change code above this line
  return result;
}

// Change this value to test
phoneticLookup("charlie");
syntax error
Ayorinde
@Ayorinde
Mar 04 2016 09:00 UTC
Remove the ; after frank
@rj-unstoppable Remove the ; after frank
Safbek
@safbek
Mar 04 2016 09:01 UTC
Hello!How can send screen here?with ipad
Rahul Jain
@rj-unstoppable
Mar 04 2016 09:06 UTC
@safbek (shift+enter for line break) var code = "formatted";
@safbek type ``` then enter and then write your code in between
Safbek
@safbek
Mar 04 2016 09:16 UTC
Thanky!but I am mean send screen from ipod, no computer. I haven't shift and so on((
@rj-unstoppable
@rj-unstoppable
Matthew Stettner
@mstettner
Mar 04 2016 09:27 UTC
does this correct?
var myStr = "This is the first sentence. ";
ourStr += "This is the second sentence.";
for:
Concatenating Strings with the Plus Equals Operator
anybody out there?
kirbyedy
@kirbyedy
Mar 04 2016 09:31 UTC
errr where did you declare the ourStr ?
Matthew Stettner
@mstettner
Mar 04 2016 09:33 UTC
var myStr = "This is the first sentence. ";
ourStr += "This is the second sentence.";
Matthew Stettner
@mstettner
Mar 04 2016 09:33 UTC
is this not right?