These are chat archives for FreeCodeCamp/HelpJavaScript

19th
Jan 2017
David Amanze
@GodKingShogun
Jan 19 2017 00:00
@JLuboff lol it shows how great you are SENPAI
Jason Luboff
@JLuboff
Jan 19 2017 00:00
I am far from great
David Amanze
@GodKingShogun
Jan 19 2017 00:00
@JLuboff i am using Microsoft edge
Jason Luboff
@JLuboff
Jan 19 2017 00:01
@GodKingShogun So am I
NourDev
@NourDev
Jan 19 2017 00:01

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < arr[i].length; j++) {
product *= arr[i][j];
}
}
// Only change code above this line
return product;
}

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

Joseph
@revisualize
Jan 19 2017 00:01
I love this.. Someone that can't figure out how to access nested array elements is being shown how to const and .reduce()
NourDev
@NourDev
Jan 19 2017 00:02
it work
Joseph
@revisualize
Jan 19 2017 00:02
Oh, it got deleted.
@NourDev Grats.
@NourDev Do you understand WHY?
David Amanze
@GodKingShogun
Jan 19 2017 00:03
@JLuboff can you post what you put into the program
Jamil Akhtar
@frontender007
Jan 19 2017 00:03
@NourDev great
Jason Luboff
@JLuboff
Jan 19 2017 00:03
@GodKingShogun I literally copied exactly what you posted
NourDev
@NourDev
Jan 19 2017 00:03
that's a friend of mine that give me that code and it didn't work
i don't want to post it because it didn't work and my friend didn't give me the answer
Jamil Akhtar
@frontender007
Jan 19 2017 00:04
@NourDev ok, don't try doing it in a complicated way, try to do it as simple as you can
@NourDev and yes you can use chained reduce to get the same results but you're not quite good with two dimensional arrays as I can see, so try to have a little more reading and practice before moving to intermediate and advance stuff
David Amanze
@GodKingShogun
Jan 19 2017 00:06
@JLuboff lol there was an option above that i had to change to javascript
Jason Luboff
@JLuboff
Jan 19 2017 00:06
Ah...that'll help
David Amanze
@GodKingShogun
Jan 19 2017 00:07
@JLuboff it was in python lol
David Amanze
@GodKingShogun
Jan 19 2017 00:13
@JLuboff that is confusing as crap
Jason Luboff
@JLuboff
Jan 19 2017 00:13
Study it, learn to understand it, become one with the visualization
Jamil Akhtar
@frontender007
Jan 19 2017 00:14
@NourDev
David Amanze
@GodKingShogun
Jan 19 2017 00:14
@JLuboff SENPAIII. what words of inspiration. i shall become one with the visuals
Jamil Akhtar
@frontender007
Jan 19 2017 00:14
function multiplyAll(arr) {
  var product = 0;
  // Only change code below this line
 product = arr.reduce(function(prev, curr){
    return prev.concat(curr);
  }).reduce ( function(sum, next) { return sum *= next },1);
  // Only change code above this line

 return product;
}
here is the solution with reduce();
@NourDev
Joseph
@revisualize
Jan 19 2017 00:16
NINJA!?
Jason Luboff
@JLuboff
Jan 19 2017 00:20
:octocat:
Closest I could find to a ninja :(
Jamil Akhtar
@frontender007
Jan 19 2017 00:21
can anybody tell me how to use recurrsion to produce fibonacci ?
Yonatan Rojas
@MajorTom250993
Jan 19 2017 00:23

Fellow coders!! I need help with the Accessing Objects Properties with Variables with Brackets this is my code ```// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj[16]; // Change this Line
var player = playerNumber; // Change this Line
```

`
// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj[16]; // Change this Line
var player = playerNumber; // Change this Line
`

Jamil Akhtar
@frontender007
Jan 19 2017 00:28
@MajorTom250993 user var playerNumber = testObj["16"];
Colin McAtee
@colinmac17
Jan 19 2017 00:37
Hey FCC team, I'm stuck on the 'using objects for lookups' challenge. I have the following code, but cannot fathom how to use val and result to complete the function

function phoneticLookup(val) {
var result = "";
// Only change code below this line
var lookup = {
val: {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");

Yonatan Rojas
@MajorTom250993
Jan 19 2017 00:39
@frontender007 thank you very much, I solved it
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;       // Change this Line
var player = testObj[playerNumber];   // Change this Line
CamperBot
@camperbot
Jan 19 2017 00:39
majortom250993 sends brownie points to @frontender007 :sparkles: :thumbsup: :sparkles:
:cookie: 286 | @frontender007 |http://www.freecodecamp.com/frontender007
Jamil Akhtar
@frontender007
Jan 19 2017 00:40
@MajorTom250993 great
Joseph
@revisualize
Jan 19 2017 00:41
@colinmac17 Your function has declared and initialized the variable result to "". You are not modifying result and your function is returning result. Ergo, you're returning "". You need to modify result to be the value of the property from the object that you created.
Colin McAtee
@colinmac17
Jan 19 2017 00:43
that makes sense. I don't get why it didn't tell me to change that code haha. Where do I incorporate val? @revisualize
Alvaromesa
@TSIIAM
Jan 19 2017 00:44
I feel dumb but can anyone help me with this exercise?

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
var celcius = ("");
fahrenheit = celcius *(9/5)+ 32;

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

// Change the inputs below to test your code
convertToF(30);

I want to assign celcius to the code in function convertToF(30)
Michael Karpinski
@karpimpski
Jan 19 2017 00:45
@TSIIAM wrap your code in ``` to help us see how you formatted it. in your code you set celcius to "" no matter what and then try to multiply that. you can't multiply a string
Alvaromesa
@TSIIAM
Jan 19 2017 00:45
function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line
  var celcius = ("");
  fahrenheit = celcius *(9/5)+ 32;

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

// Change the inputs below to test your code
convertToF(30);
var celcius = (""); there is the problem that I dont know how to fix
Jamil Akhtar
@frontender007
Jan 19 2017 00:47
@TSIIAM why are using parenthesis around "" to assign celcius?
CamperBot
@camperbot
Jan 19 2017 00:48
:bulb: to format code use backticks! ``` more info
Alvaromesa
@TSIIAM
Jan 19 2017 00:48
I dont really know :( maybe I got messed with python
I want to var celcius = (assign) what I add in convertToF(30);
for example if I say convertToF(20) the function will return a different result
Jamil Akhtar
@frontender007
Jan 19 2017 00:51
function convertToF(c) {
  var fahrenheit;
  // Only change code below this line

  fahrenheit = (c * 9)/5 + 32;

  // Only change code above this line
  return fahrenheit;
}
do this
Johnny
@JohnnyBizzel
Jan 19 2017 00:52
@TSIIAM celcius is spelled celsius
Alvaromesa
@TSIIAM
Jan 19 2017 00:54

```function convertToF(c) {
var fahrenheit;
// Only change code below this line

fahrenheit = c *(9/5)+ 32;

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

// Change the inputs below to test your code
convertToF(20);

Dylan Hsiao
@greedylan
Jan 19 2017 00:54
function sumFibs(num) {
  var prevNum = 0;
  var currNum = 1; 
  var arr = [];

  while(currNum < num){
    arr.push(currNum);
    currNum = currNum + prevNum;
    prevNum = currNum - prevNum;
  }

  return arr.reduce(function(accu, curr){
    if(curr%2 !== 0){
      return accu + curr; 
    }
  }, 0);

}

sumFibs(4);
how do I use reduce method to get the sum of the items in the array without even number? what do I do wrong with the callback function?
Alvaromesa
@TSIIAM
Jan 19 2017 00:55
@frontender007 thanks I had to change the function(celcius) to c? that was weird.
CamperBot
@camperbot
Jan 19 2017 00:55
tsiiam sends brownie points to @frontender007 :sparkles: :thumbsup: :sparkles:
:cookie: 287 | @frontender007 |http://www.freecodecamp.com/frontender007
Joseph
@revisualize
Jan 19 2017 00:58
@TSIIAM Or you could have spelled celsius correctly.
Alvaromesa
@TSIIAM
Jan 19 2017 00:59
That could work hehe.
Johnny
@JohnnyBizzel
Jan 19 2017 00:59
@revisualize :+1: :eyes:
@TSIIAM celcius is spelled celsius (00:52)
Jamil Akhtar
@frontender007
Jan 19 2017 01:00
@TSIIAM lol, that was just for explaining purpose you could name your params and variable whatever you like , but sure celsius is more descriptive and should be used
Alvaromesa
@TSIIAM
Jan 19 2017 01:00
I got it wrong as celcius is celsius in spannish :smile:
Jamil Akhtar
@frontender007
Jan 19 2017 01:00
@TSIIAM bonas noches, lol
@colinmac17 you are not using break statements
Colin McAtee
@colinmac17
Jan 19 2017 01:01

// Setup
function phoneticLookup(val) {
  var result = "alpha";

  // 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");
@frontender007 sorry am supposed to be doing an object lookup
Jamil Akhtar
@frontender007
Jan 19 2017 01:02
@colinmac17 you have no break statements in between
@colinmac17 Oh, ok
Colin McAtee
@colinmac17
Jan 19 2017 01:03
I am having trouble figuring out how to use val @frontender007
Jamil Akhtar
@frontender007
Jan 19 2017 01:04
user var result = val;
which challenge is it ?
and what the instructions say you have to do ?
mnghm
@mnghm
Jan 19 2017 01:06
Hey, how's everyone doing
Jamil Akhtar
@frontender007
Jan 19 2017 01:06
@nghm great man, about yourself
?
Colin McAtee
@colinmac17
Jan 19 2017 01:07
using objects for lookups
mnghm
@mnghm
Jan 19 2017 01:07
I'm really struggling with basic algorithms, just on the palindrome exercise, wondering if anyone has any advice or feedback they can give?
Colin McAtee
@colinmac17
Jan 19 2017 01:08
@colinmac17 @frontender007 Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.
Jamil Akhtar
@frontender007
Jan 19 2017 01:08
@nghm study Regular Expressions for an hour and then come back to the challenge , you will easily pass it
@colinmac17 then you do like result = lookup[val];
mnghm
@mnghm
Jan 19 2017 01:10
function palindrome(str) {
str.replace(/[^\w\s]|_/g, "");
str.replace(/\s+/g, "");
str.toLowerCase();

var newStr = str;


return true;
}

palindrome("eye");
read this and you will be good
mnghm
@mnghm
Jan 19 2017 01:11
need to add a return false in there with another expression but not sure how to write it atm
Colin McAtee
@colinmac17
Jan 19 2017 01:12
@frontender007 gives an error.
Jamil Akhtar
@frontender007
Jan 19 2017 01:12
@nghm basicall your regex should /[^\w ]|_/g
@colinmac17 can you please send the link of your fcc challenge page
?
@nghm add a space after w
Jamil Akhtar
@frontender007
Jan 19 2017 01:17
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookup = {
    "alpha":  "Adams",
    "bravo": "Boston"

  }

  result = lookup[val];

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

phoneticLookup("alpha")
try this
make sure you end lookup assignment statement with a semicolon at the end after the closing curly bracket before result = lookup[val];
mnghm
@mnghm
Jan 19 2017 01:20
@frontender007 Ok will have to look through that tomorrow night, any idea what the next step would be? thanks
CamperBot
@camperbot
Jan 19 2017 01:20
nghm sends brownie points to @frontender007 :sparkles: :thumbsup: :sparkles:
:cookie: 288 | @frontender007 |http://www.freecodecamp.com/frontender007
John Roper
@jroper19
Jan 19 2017 01:20
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case  value1 = 'alpha':
      statement1; 
      break;
  }


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

// Change this value to test
caseInSwitch(1);
Hey, can yall tell me if I'm on the right track with the "Case Value1" line? Having a little trouble making sense of the examples.
Colin McAtee
@colinmac17
Jan 19 2017 01:21
@frontender007 perfect, thanks so much!
CamperBot
@camperbot
Jan 19 2017 01:21
:cookie: 289 | @frontender007 |http://www.freecodecamp.com/frontender007
colinmac17 sends brownie points to @frontender007 :sparkles: :thumbsup: :sparkles:
Jamil Akhtar
@frontender007
Jan 19 2017 01:21
@nghm I suggest you should read the book Beginning JavaScript
John Roper
@jroper19
Jan 19 2017 01:24
@frontender007 And assign "alpha" to the "statement1" line?
Jamil Akhtar
@frontender007
Jan 19 2017 01:24
yes
John Roper
@jroper19
Jan 19 2017 01:24
@frontender007 Trying it now...
Jamil Akhtar
@frontender007
Jan 19 2017 01:25
can you send your challenge page link
lonely dong
@DxinAL
Jan 19 2017 01:27
ao
Jamil Akhtar
@frontender007
Jan 19 2017 01:27
@jroper19 ok, you should do switch ( val ) { case 1: answer = "alpha";break; case 2: etc
Yoel Trujillo
@y0el22
Jan 19 2017 01:28

hi guys i have i problem can you give me a hand?


function titleCase(str) {
  var arrayNew = str.split(" ");
  var stringFinal = "";
  for(var i = 0; i<arrayNew.length; i++){
    var firstLetter = arrayNew[i].charAt(0).toUpperCase();
    var remainingLetters = arrayNew[i].substr(1);
    var capitalizedWord = firstLetter + remainingLetters;
    var finalString += capitalizedWord + ""; 
    return finalString;
  }
}

titleCase("I'm a little tea pot");
`

i got this, but is not working what is the problem? it said unexpected += token

Jamil Akhtar
@frontender007
Jan 19 2017 01:29
function caseInSwitch(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';
      break;
  }


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

// Change this value to test
caseInSwitch(1);
@jroper19
try this
John Roper
@jroper19
Jan 19 2017 01:30
@frontender007 Thanks! It worked but I'm still a bit confused... is the "statement1" line unnecessary?
CamperBot
@camperbot
Jan 19 2017 01:30
jroper19 sends brownie points to @frontender007 :sparkles: :thumbsup: :sparkles:
:cookie: 290 | @frontender007 |http://www.freecodecamp.com/frontender007
Zaluth
@Zaluth
Jan 19 2017 01:30
i want to make arr[0] become arr[1] and remainder become arr[0] after each iteration, but i can't figure this out, help?
while (remainder > 0) {

    arr[1] = arr[0] * quotient + remainder;

    temp = arr[0];
    arr[0] = arr[1];
    arr[1] = temp;

    temp2 = remainder;
    remainder = arr[0];
    arr[0] = temp2;

  }
Vladimir Remeniuk
@Remek1990
Jan 19 2017 01:30

Could anyone please help me out? I can't define my mistake// Setup
function phoneticLookup(val) {
var result = "";

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

lookup = val;

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

// Change this value to test
phoneticLookup("charlie");

John Roper
@jroper19
Jan 19 2017 01:31
@frontender007 Got it. that cleared it up.
Vladimir Remeniuk
@Remek1990
Jan 19 2017 01:31

// Setup
function phoneticLookup(val) {
var result = "";

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

lookup = val;

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

// Change this value to test
phoneticLookup("charlie");

Jamil Akhtar
@frontender007
Jan 19 2017 01:32
str.split(" ").map(function(word){ return word.charAt(0).toUpperCase() + word.slice(1);}.join("");
@y0el22 try this
Chris Wingler
@chriswingler
Jan 19 2017 01:32
why is my rot13 decrypting as "F8EE C5DE CAM6" ??
function rot13(str) { // LBH QVQ VG!
  var newStr = '';
  var finalStr = '';
  for (var i = 0; i < str.length; i++) {
    if (str.charCodeAt(i) >= 48) {
      newStr += str.charCodeAt(i) - 13;
    } else {
      newStr += str.charCodeAt(i);
    }
  }
  for (i = 0; i < newStr.length; i = i + 2) {
    finalStr += String.fromCharCode(newStr[i] + newStr[i + 1]);
  }
  return finalStr;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Deacon Litterick
@DeacoZ
Jan 19 2017 01:33

hi can anyone plz tell me what wrong function isLess(a,b) {
return a === b;
}

isLess(10, 15);
but its not coming through as 10,15 is true but 15,10 is false which that is correct

Yoel Trujillo
@y0el22
Jan 19 2017 01:33
@frontender007 that's the complete answer?
@frontender007 i only need fix my code
Jamil Akhtar
@frontender007
Jan 19 2017 01:34
@jroper19 yes, because a switch statement is to check value of a variable, lookup(1) means your value is 1 and then in switch you're gonna check which value correspond to the which name
@y0el22 yes it is, ok let me see
Deacon Litterick
@DeacoZ
Jan 19 2017 01:35
please help me
John Roper
@jroper19
Jan 19 2017 01:35
@frontender007 Just passed the challenge. Thanks again!
CamperBot
@camperbot
Jan 19 2017 01:35
jroper19 sends brownie points to @frontender007 :sparkles: :thumbsup: :sparkles:
:warning: jroper19 already gave frontender007 points
Jamil Akhtar
@frontender007
Jan 19 2017 01:36
@jroper19 welcome
Joseph
@revisualize
Jan 19 2017 01:36
cbot
CamperBot
@camperbot
Jan 19 2017 01:36
you called?
Greg Duncan
@GregatGit
Jan 19 2017 01:36
@chriswingler those letters are further along in the alaphabet - so you have to minus 26 if they go to far
CamperBot
@camperbot
Jan 19 2017 01:36
:bulb: to format code use backticks! ``` more info
Jamil Akhtar
@frontender007
Jan 19 2017 01:36
@y0el22 keep the loop and remove everything in between first
Chris Wingler
@chriswingler
Jan 19 2017 01:37
@GregatGit doh! thank you so much
CamperBot
@camperbot
Jan 19 2017 01:37
chriswingler sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 829 | @gregatgit |http://www.freecodecamp.com/gregatgit
Greg Duncan
@GregatGit
Jan 19 2017 01:37
@chriswingler :+1:
Zaluth
@Zaluth
Jan 19 2017 01:37
i want to make arr[0] become arr[1] and remainder become arr[0] after each iteration, but i can't figure this out, help?
while (remainder > 0) {

    arr[1] = arr[0] * quotient + remainder;

    temp = arr[0];
    arr[0] = arr[1];
    arr[1] = temp;

    temp2 = remainder;
    remainder = arr[0];
    arr[0] = temp2;

  }
Deacon Litterick
@DeacoZ
Jan 19 2017 01:38
can someone help why is this not working
Joseph
@revisualize
Jan 19 2017 01:38
@Remek1990 Why are you creating an object named lookup then overwriting it with val?
Deacon Litterick
@DeacoZ
Jan 19 2017 01:39
val
Joseph
@revisualize
Jan 19 2017 01:39
@DeacoZ isLess??
@DeacoZ Your function isnt named isEqual
maybe the function name is a hint?
Deacon Litterick
@DeacoZ
Jan 19 2017 01:39
@revisualize is it meant to
ok
Joseph
@revisualize
Jan 19 2017 01:40
Along with the instructions.
Deacon Litterick
@DeacoZ
Jan 19 2017 01:40
i tried changing the isLess to isEqual but still no
Vladimir Remeniuk
@Remek1990
Jan 19 2017 01:40
@revisualise, if I delete this string, still nothing happens
// Setup
function phoneticLookup(val) {
  var result = "";

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

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

// Change this value to test
phoneticLookup("charlie");
Jamil Akhtar
@frontender007
Jan 19 2017 01:40
@DeacoZ return a < b;
Joseph
@revisualize
Jan 19 2017 01:41
@Remek1990 Your function has declared and initialized the variable result to "". You are not modifying result and your function is returning result. Ergo, you're returning "". You need to modify result to be the value of the property from the object that you created.
Jamil Akhtar
@frontender007
Jan 19 2017 01:41
@Remek1990 return result = lookup[val];
Deacon Litterick
@DeacoZ
Jan 19 2017 01:41
yes it worked thanks
Joseph
@revisualize
Jan 19 2017 01:41
Why do you keep just giving away answers?
Damn.
@frontender007 Do you really think that is helping?
Jamil Akhtar
@frontender007
Jan 19 2017 01:42
@revisualize got your point
Joseph
@revisualize
Jan 19 2017 01:42
@frontender007 Do you understand how learning actually works?
I don't gift away answers. Studies have shown that giving people answers to problems instills an illusionary sense of learning. Because, it only puts information into short-term memory. Of which people think they are learning. Only through a little struggle and repetition that the human brain puts things into long-term memory. I don't know what your end goal. I don't know if you want to do this as a personal project, hobby, or if you want to move into industry. Because of this, I strongly feel that working with people to allow them to solve problems on their own is a far better outcome than giving away answers. But, others clearly don't agree with my methods for helping people learn.
Jamil Akhtar
@frontender007
Jan 19 2017 01:43
@revisualize you don't need to be sarcy , I got your point
Joseph
@revisualize
Jan 19 2017 01:44
@frontender007 Sorry. I'm not trying to be an ass. It's just that I'm quite passionate about helping people learn.
eeflores
@eeflores
Jan 19 2017 01:44
now if we can only tell recruiters that we can't come up with answers on the spot
Jamil Akhtar
@frontender007
Jan 19 2017 01:44
@revisualize great , we are on the same boat , learning and helping each other and my way of helping was wrong which realized
Joseph
@revisualize
Jan 19 2017 01:45
@frontender007 It's not wrong. It's just there isn't any follow up. If you give an answer there needs to be a why.
@frontender007 Also with @Remek1990 There was not explanation that objects are key value pairs.
And really shouldn't be doing result = inside of the object.
Jamil Akhtar
@frontender007
Jan 19 2017 01:47
@revisualize a lot of people around here they are not from a coding background or anything about computers making them think all the time discourage them as well
@frontender007 I'm not from a coding background.
My career started with Customer Service.
Jamil Akhtar
@frontender007
Jan 19 2017 01:48
@revisualize but you might have a strong base now, don't you?
Joseph
@revisualize
Jan 19 2017 01:48
Phone support.
@frontender007 1 year.
Actually coding about 1.5 years.
Jamil Akhtar
@frontender007
Jan 19 2017 01:48
@revisualize good enough as compared to who just started
but anyway lets just try to learn and help others if we can
Joseph
@revisualize
Jan 19 2017 01:49
Again, I'm not trying to be an ass. But, I know that I'm coming across that way.
kevinliu6102
@kevinliu6102
Jan 19 2017 01:50
@revisualize i have to agree with you. and i don't think you're being an ass, i think it was an appropriate reaction
Jamil Akhtar
@frontender007
Jan 19 2017 01:50
@revisualize yes indeed it was
Earl
@pokean0n
Jan 19 2017 01:50
Now Hug it out ;p and carry on
Joseph
@revisualize
Jan 19 2017 01:50
Don't touch me there.
Jamil Akhtar
@frontender007
Jan 19 2017 01:50
@pokean0n lol
Earl
@pokean0n
Jan 19 2017 01:51
I was going to say Now Kiss but I thought that might get me a boot haha
Jamil Akhtar
@frontender007
Jan 19 2017 01:51
by the way any of you did sumFib() challenge ?
I'm stuck at that one, haven't got a clue what to do
Joseph
@revisualize
Jan 19 2017 01:51
I did.
Zaluth
@Zaluth
Jan 19 2017 01:52
i want to make arr[0] become arr[1] and remainder become arr[0] after each iteration, but i can't figure this out, help?
while (remainder > 0) {

    arr[1] = arr[0] * quotient + remainder;

    temp = arr[0];
    arr[0] = arr[1];
    arr[1] = temp;

    temp2 = remainder;
    remainder = arr[0];
    arr[0] = temp2;

  }
Joey
@pbandjaysandwich
Jan 19 2017 01:52
how do I write the logical or operator?
haha like I dont know what key to press.
is it two I's or two 1's or what?
Zaluth
@Zaluth
Jan 19 2017 01:52
@pbandjaysandwich it's usually above the enter key
Jamil Akhtar
@frontender007
Jan 19 2017 01:52
its called pipe character
Joseph
@revisualize
Jan 19 2017 01:53
|
Joey
@pbandjaysandwich
Jan 19 2017 01:53
@Zaluth dude.. thanks I appreciate it
CamperBot
@camperbot
Jan 19 2017 01:53
pbandjaysandwich sends brownie points to @zaluth :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for zaluth
Joseph
@revisualize
Jan 19 2017 01:56
Oh.
my :busstop:
brb
Adam Wayne
@AdamWayne-dev
Jan 19 2017 02:00
Hey guys, could someone explain to me what the '0' is at the end of this funtion, please?
singleVal = array.reduce(function(previousVal, currentVal){
  return previousVal + currentVal;
}, 0);
function*
FrancisOgertschnig
@FrancisOgertschnig
Jan 19 2017 02:01
How do you clear NaN items without also wiping out strings?
Edgar Pan
@edgaryp
Jan 19 2017 02:02
Hi I have a question with below code. Is it because the anonymous function is a value of object's property so it won't execute when I try to console.log it with console.log(user.clickHandler);?
var user = {
  data: [{
    name: "T. Woods",
    age: 37
  }, {
    name: "P. Mickelson",
    age: 43
  }],
  clickHandler: function(event) {
    var randomNum = ((Math.random() * 2 | 0) + 1) - 1;
    console.log(this.data[randomNum].name + " " + this.data[randomNum].age);
  }
}
console.log(user.clickHandler);
Ken Haduch
@khaduch
Jan 19 2017 02:04
@edgaryp - you aren't actually invoking the function, just reporting the value of the variable, which is a function. Try adding () at the end of the .clickHandler() and see if it changes? It should, because then it will actually run the function in that context.
Praveen Kaushik
@kaushikpraveen
Jan 19 2017 02:06
Hi everybody
I need some help
Ken Haduch
@khaduch
Jan 19 2017 02:06
@AdamWayne-dev - did you read the MDN page on Array.reduce()?
It is an initial value that is passed into the function for the first time through the previousVal parameter (in your function as shown.)
Joseph
@revisualize
Jan 19 2017 02:07
I'm back!
Ken Haduch
@khaduch
Jan 19 2017 02:07
It's worthwhile to go and read the documentation, with this hint of what that parameter means, so that you can tie the pieces together. The MDN docs are really useful!
Joseph
@revisualize
Jan 19 2017 02:07
@AdamWayne-dev Initial value.
@khaduch How was dinner?
Ken Haduch
@khaduch
Jan 19 2017 02:08
@revisualize - good enough (for my cooking skills... LOL) :) glad you're back!
Praveen Kaushik
@kaushikpraveen
Jan 19 2017 02:08
Is this code not OK for Palindrome check-
function palindrome(str) {
  // Good luck!
var reversed=[];
  str.toLowerCase();
  reversed= str.split('');
  reversed.reverse();
  reversed.join('');


  if(reversed==str){
    return true;
  }
  else 
  {return false;}

}



palindrome("eye");
Ken Haduch
@khaduch
Jan 19 2017 02:09
@kaushikpraveen - yes, it is not okay
Edgar Pan
@edgaryp
Jan 19 2017 02:10
@khaduch yes it works but also shows undefined after the function is executed with correct result.
http://codepen.io/edgaryp/pen/JEEMYM?editors=0012
Ken Haduch
@khaduch
Jan 19 2017 02:11
@kaushikpraveen - one thing that you have to do is remove characters that are not word characters - so any spaces, underscores, punctuation, etc. That's missing.
Angeleah
@gelbelle
Jan 19 2017 02:12
Good evening all,
I'm super stuck on the lookup table assignment. Is there anyone on that is familiar with this?
Timothy Kavalenka
@timothy-kavalenka
Jan 19 2017 02:12
// Example
function ourReusableFunction() {
  console.log("Heyya, World");
}

ourReusableFunction();

// Only change code below this line

function ReusableFunction ("Hi, World");
like this?
Ken Haduch
@khaduch
Jan 19 2017 02:12
@edgaryp - do you mean in the console? I think that there is a reason for that... it shows the result of the last function to be executed, which is probably console.log in this case? Let me see if I can verify that.
Victoria Zambrano
@vzambrano98
Jan 19 2017 02:13

okay does anyone see anything wrong with this lil code blurb here? I am wracking my brain over it lol

  if (array !== newArr){
    return false;
  }

I put it in python tutor and this is the part getting skipped

Edgar Pan
@edgaryp
Jan 19 2017 02:13
yes in the console I mean @khaduch
Ken Haduch
@khaduch
Jan 19 2017 02:14
@edgaryp - I don't know the answer off the top of my head.
Stephen James
@sjames1958gm
Jan 19 2017 02:14
@vzambrano98 Can you show more like where array and newArr came from?
Generally you cannot compare arrays like that.
Ken Haduch
@khaduch
Jan 19 2017 02:14
@vzambrano98 - I don't think that you can compare arrays like that? If that's what you're trying to do. What is the other code that goes along with that.
Zaluth
@Zaluth
Jan 19 2017 02:15
i want to make arr[0] become arr[1] and remainder become arr[0] after each iteration, but i can't figure this out, help?
while (remainder > 0) {

    arr[1] = arr[0] * quotient + remainder;

    temp = arr[0];
    arr[0] = arr[1];
    arr[1] = temp;

    temp2 = remainder;
    remainder = arr[0];
    arr[0] = temp2;

  }
Alex Maroa
@Maroa01
Jan 19 2017 02:15

Hey everyone can anyone help me assign the value 7 to both variables...

var a = 7;
var b = var a;

Adam Wayne
@AdamWayne-dev
Jan 19 2017 02:15
@khaduch Thank you, I did google it in the end, turns out i didn't even need it in the code, I just wanted to be thorough. Thank you for pointing me towards MDN :)
CamperBot
@camperbot
Jan 19 2017 02:15
adamwayne-dev sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2307 | @khaduch |http://www.freecodecamp.com/khaduch
Victoria Zambrano
@vzambrano98
Jan 19 2017 02:16
@khaduch and @sjames1958gm awww dang. okay. okay. that tidbit of info just solved my whole problem, I was working on the Check for Palindrome thing, lol! Thanks! that's what I needed
CamperBot
@camperbot
Jan 19 2017 02:16
vzambrano98 sends brownie points to @khaduch and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2308 | @khaduch |http://www.freecodecamp.com/khaduch
Cal-culator
@Cal-culator
Jan 19 2017 02:16
Hey guys, anyone done with Twitch API that can help?
CamperBot
@camperbot
Jan 19 2017 02:16
:star2: 5416 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Adam Wayne
@AdamWayne-dev
Jan 19 2017 02:16
@revisualize Thanks again!
CamperBot
@camperbot
Jan 19 2017 02:16
adamwayne-dev sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3045 | @revisualize |http://www.freecodecamp.com/revisualize
Andy
@amillion3
Jan 19 2017 02:16
regular expressions!, why are you so hard?? anyone have good resources to reference for them?
Greg Duncan
@GregatGit
Jan 19 2017 02:16
@Zaluth you have made that complicated and really hard to follow - simplify it
Stephen James
@sjames1958gm
Jan 19 2017 02:17
@Maroa01 if you are doing the challenge I think they are already defined with var above.
Don't repeat var keyword for the same variable and especially no var to the right of =
Cal-culator
@Cal-culator
Jan 19 2017 02:17
@GregatGit I solved the issue we had last time. It turned out to be a } issue lol
Greg Duncan
@GregatGit
Jan 19 2017 02:18
@Cal-culator well done!
Zaluth
@Zaluth
Jan 19 2017 02:18

i have this:

 arr[1] = arr[0] * quotient + remainder;

i want to make arr[0] become arr[1] and remainder become arr[0] after each iteration in a while loop

Cal-culator
@Cal-culator
Jan 19 2017 02:18
@GregatGit thanks. Do you know if the wind-bow.me works?
CamperBot
@camperbot
Jan 19 2017 02:18
cal-culator sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 830 | @gregatgit |http://www.freecodecamp.com/gregatgit
Alex Maroa
@Maroa01
Jan 19 2017 02:18
@sjames1958gm Kindly explain what exactly you mean
Ken Haduch
@khaduch
Jan 19 2017 02:19
@khaduch @edgaryp - it is reporting the result of what you returned from your function, it turns out. I was a little confused. If you add some actual return at the end of your anonymous function, like return "Haha";, it will report "Haha" in the console. So you don't have a return statement, I think that it implicitly returns undefined...
Stephen James
@sjames1958gm
Jan 19 2017 02:19
@Maroa01 remove all those var in the code you showed
Alex Maroa
@Maroa01
Jan 19 2017 02:19
@sjames1958gm what should i use instead
Stephen James
@sjames1958gm
Jan 19 2017 02:19
@y0el22 Possibly an extra space at the end of the string
Greg Duncan
@GregatGit
Jan 19 2017 02:20
@Cal-culator what is wind-bow.me
Edgar Pan
@edgaryp
Jan 19 2017 02:20
@khaduch that me read again what you said :)
Stephen James
@sjames1958gm
Jan 19 2017 02:20
@Maroa01 nothing a and b have already been declared with var so you don't do it again.
Cal-culator
@Cal-culator
Jan 19 2017 02:20
@GregatGit Its the api url that we have to use for Twitch.tv since the latter now requires client authetication
Alex Maroa
@Maroa01
Jan 19 2017 02:20
@sjames1958gm Should i replace the var??
Vladimir Remeniuk
@Remek1990
Jan 19 2017 02:21
@frontender007 , thank you! Sometimes I get stuck on some really simple challenges
CamperBot
@camperbot
Jan 19 2017 02:21
remek1990 sends brownie points to @frontender007 :sparkles: :thumbsup: :sparkles:
:cookie: 291 | @frontender007 |http://www.freecodecamp.com/frontender007
Stephen James
@sjames1958gm
Jan 19 2017 02:21
@Maroa01 no
Ken Haduch
@khaduch
Jan 19 2017 02:21

@edgaryp - basically, I changed the code to this:

  clickHandler: function(event) {
    var randomNum = ((Math.random() * 2 | 0) + 1) - 1;
    console.log(this.data[randomNum].name + " " + this.data[randomNum].age);
    return "Haha";
  }

Then upon running it, the console reported:

"P. Mickelson 43"

"Haha"

without that return, it just reports "undefined"

Joseph
@revisualize
Jan 19 2017 02:22
I really should work on some projects that require DOM manipulation.
Alex Maroa
@Maroa01
Jan 19 2017 02:23
@sjames1958gm var a = 7;
var b = var a ;
Ken Haduch
@khaduch
Jan 19 2017 02:23
@revisualize - yes, that makes two of us! (At least...)
Alex Maroa
@Maroa01
Jan 19 2017 02:23
I did this
Stephen James
@sjames1958gm
Jan 19 2017 02:24

@Maroa01 How is that removing the var keywords?
This is the setup it already declares the variables with var so you don't repeat those
// Setup
var a;
var b = 2;

// Only change code below this line

Yoel Trujillo
@y0el22
Jan 19 2017 02:25
@sjames1958gm yes is that but i can't see where is the code making it
Edgar Pan
@edgaryp
Jan 19 2017 02:25
@khaduch thank you
CamperBot
@camperbot
Jan 19 2017 02:25
edgaryp sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2309 | @khaduch |http://www.freecodecamp.com/khaduch
Stephen James
@sjames1958gm
Jan 19 2017 02:26
@y0el22 At the end of each loop you add capitalizedWord + " "
so the last one has a blank at the end.
Hejhal
@Hejhal
Jan 19 2017 02:26
Hello, I have a question on the "Escape Sequences in Strings" activity. I'm inputting this as my code, but it's not working: var myStr = 'FirstLine\n\SecondLine\\nThirdLine';
Any hints?
Stephen James
@sjames1958gm
Jan 19 2017 02:26
@y0el22 If you did arrayNew[i] = firstLetter + remainingLettersL; rather than build a new string then you could simply join(' ');
Praveen Kaushik
@kaushikpraveen
Jan 19 2017 02:27
@khaduch Do i have to use .replace method?
Stephen James
@sjames1958gm
Jan 19 2017 02:27
@Hejhal the keywords were newline and carriage return new line is \n but carriage return is \r
@Maroa01 If you are still stuck:
a = 7;
b = a;
Ken Haduch
@khaduch
Jan 19 2017 02:28
@kaushikpraveen - that sounds about right...
Hejhal
@Hejhal
Jan 19 2017 02:29
@sjames1958gm ok, thanks for the hint, Now I'm getting all green checks except: myStr should have encoded text with the proper escape sequences and no spacing
CamperBot
@camperbot
Jan 19 2017 02:29
hejhal sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5417 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Yoel Trujillo
@y0el22
Jan 19 2017 02:29
@sjames1958gm without that space i get "I'malittleteapot
Praveen Kaushik
@kaushikpraveen
Jan 19 2017 02:29
@khaduch Can you plz explain abt replace method?
Hejhal
@Hejhal
Jan 19 2017 02:29
@sjames1958gm when I use the \r as one of the returns instead of \n
@sjames1958gm nevermind, I've solved it...apparently it wanted me to use \n for the first one and \r for the second one..didn't explicitly state that. thanks!
CamperBot
@camperbot
Jan 19 2017 02:31
hejhal sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: hejhal already gave sjames1958gm points
Yoel Trujillo
@y0el22
Jan 19 2017 02:32
@sjames1958gm where i put the join("")sorry
Ken Haduch
@khaduch
Jan 19 2017 02:32
@kaushikpraveen - here is a link to the MDN documentation on String.replace. You can read about it there, it gives you a lot of detailed information about how the function works. The best thing is to try and experiment with it, you can then come back and ask questions after you get an idea of how it works (or get frustrated, or both...)
Praveen Kaushik
@kaushikpraveen
Jan 19 2017 02:34
@khaduch I've already gone through it.. this is the only thing I'm still confused about
Do I have to replace every special character with '' using regular expressions
Joey
@pbandjaysandwich
Jan 19 2017 02:34
for the golfer scenario do you have a par and a stroke argument for each if statement?
JuscelinoJunior
@JuscelinoJunior
Jan 19 2017 02:37
please anyboy help me, i don't understand the Return Largest Numbers in Arrays challenge, that's my code

function largestOfFour(arr) {
  // You can do this!
  var arrL;

  for(i=0;i<arr.length;i++){
    for(j=0;j<arr[i].length;j++){
      if (arr[i][j] > arrL[j]){
        arrL[j] = arr[i][j];
      }
    }    
  }

  return arrL;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Colin McAtee
@colinmac17
Jan 19 2017 02:40

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  arr = [ [], [], [] ];
  for (var i = 0; i < arr.length; i++ ){
    for (var j=0; j <arr[i].length; j++){
      arr[i][j] * product;
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
is this the correct setup?
Manish Giri
@Manish-Giri
Jan 19 2017 02:41
@colinmac17 arr[i][j] * product;
that returns something.
where are you saving it?
mrcool4
@mrcool4
Jan 19 2017 02:42
Hi All
Manish Giri
@Manish-Giri
Jan 19 2017 02:42
also, what's this? arr = [ [], [], [] ];
mrcool4
@mrcool4
Jan 19 2017 02:42
I am working on Jquery module
Praveen Kaushik
@kaushikpraveen
Jan 19 2017 02:42
@colinmac17 I think it should be this way- product*= arr[i][j]
mrcool4
@mrcool4
Jan 19 2017 02:42
and animated bounce isn't working when I use it in my own page
Colin McAtee
@colinmac17
Jan 19 2017 02:43
@Manish-Giri I didn't know if I needed to set the value to length of three
mrcool4
@mrcool4
Jan 19 2017 02:43

<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">

<script src="//code.jquery.com/jquery-1.12.4.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$("button").addClass("animated shake");
});
</script>

Jarett
@DecentLuck
Jan 19 2017 02:44
Hello folks, I’m stuck and need some help.
Manish Giri
@Manish-Giri
Jan 19 2017 02:44
@colinmac17 not really, you already get the array in arr here -
function multiplyAll(arr)
Jarett
@DecentLuck
Jan 19 2017 02:44
Instructions: Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
Manish Giri
@Manish-Giri
Jan 19 2017 02:44
no need to do anything to/with arr
after that
Jarett
@DecentLuck
Jan 19 2017 02:44
Screen Shot 2017-01-18 at 9.43.16 PM.png
Manish Giri
@Manish-Giri
Jan 19 2017 02:45
@DecentLuck first, use the || logical OR operator
not sure why the ,
then, return the keyword undefined, not the string "undefined"
Colin McAtee
@colinmac17
Jan 19 2017 02:45
@kaushikpraveen bingo! thanks!
CamperBot
@camperbot
Jan 19 2017 02:45
colinmac17 sends brownie points to @kaushikpraveen :sparkles: :thumbsup: :sparkles:
:cookie: 267 | @kaushikpraveen |http://www.freecodecamp.com/kaushikpraveen
mrcool4
@mrcool4
Jan 19 2017 02:45
?
Colin McAtee
@colinmac17
Jan 19 2017 02:46
@Manish-Giri awesome, thank you!
CamperBot
@camperbot
Jan 19 2017 02:46
colinmac17 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3866 | @manish-giri |http://www.freecodecamp.com/manish-giri
mrcool4
@mrcool4
Jan 19 2017 02:46
am I posting in the wrong room? Is there any room for jquery
Ishola Daniel
@itamelions
Jan 19 2017 02:46

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

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

Manish Giri
@Manish-Giri
Jan 19 2017 02:46
@colinmac17 :+1:
Jarett
@DecentLuck
Jan 19 2017 02:46
@Manish-Giri thanks!! I took a few days off and I’m all messed up.
CamperBot
@camperbot
Jan 19 2017 02:46
decentluck sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3867 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jan 19 2017 02:47
@itamelions why this line? var newArray = oldArray;
Ishola Daniel
@itamelions
Jan 19 2017 02:48
@Manish-Giri oh! thanks my mistake
CamperBot
@camperbot
Jan 19 2017 02:48
itamelions sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3869 | @manish-giri |http://www.freecodecamp.com/manish-giri
James Shore
@Jimbobmahooley
Jan 19 2017 02:50
Hello, I am doing a challenge and need some help, I'm essentially trying to create a bubble sort and was wondering if theres an easy way to easily swap two numbers in an array? any help would be appreciated thanks.
Manish Giri
@Manish-Giri
Jan 19 2017 02:50
@itamelions :+1:
@DecentLuck welcome
Adam-Gardener
@Adam-Gardener
Jan 19 2017 02:50

Brand new to JAVA and stumped on this simple task. Please help. No workee! function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

var a = 9;
var b = 5;
var c = 32;
var d = d;
var e = e;
var f = f;

d = convertToF * a;
e = d / b;
f = e + c;

fahrenheit = f;

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

wowcoolwebsite
@wowcoolwebsite
Jan 19 2017 02:51
hey guys for project Destroyer, javascript basic algorithms, does anyone see the flaw in my logic?? thank you!

function destroyer(arr) {
  var initialArray = arr;

  initialArray = initialArray.filter(function(val){
    var notInArguments = true;
    for (var i = 1; i < arguments.length; i++)
      {
        if(val === arguments[i])
          {
            notInArguments = false;
          }
      }

    return notInArguments;

  });

  return initialArray;

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
I don´t understand why it just keeps returning the array without filtering out the, second and third (and possibly more) arguments
Joseph
@revisualize
Jan 19 2017 02:52
Arguments Scopes to the function that it is instantiated from.
wowcoolwebsite
@wowcoolwebsite
Jan 19 2017 02:52
oooh okay
Joseph
@revisualize
Jan 19 2017 02:52
Basically, Every function has its own arguments object.
/me learns how to write sentence correct.
wowcoolwebsite
@wowcoolwebsite
Jan 19 2017 02:53
okay i think i understand what you mean!! let me check
CoryCMyers
@CoryCMyers
Jan 19 2017 02:54
Good Evening everyone!
How are ya'all?
wowcoolwebsite
@wowcoolwebsite
Jan 19 2017 02:54
@CoryCMyers Good evening! Struggling, but that means progress! and what about you :P
CoryCMyers
@CoryCMyers
Jan 19 2017 02:56

I was popping in because I was able to solve this correctly, however i want to be sure I understand what is going on in this reduce function. I am using python tutor for visualization help.

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

// Only change code below this line.

singleVal = array.reduce(function(previousVal, currentVal) {
  return previousVal + currentVal;
});

What I do not understand on this or the previous problem, is why does the normal bracket end beyond the curly bracket that ends the function?

Joseph
@revisualize
Jan 19 2017 02:56
@wowcoolwebsite Let me tell you.. That lesson.. It took me DAYS to solve.
@wowcoolwebsite My first attempt at it on my own. I spent two hours a day across 4 days. I got frustrated and skipped it.
Ken Haduch
@khaduch
Jan 19 2017 02:57
@kaushikpraveen - that is the most efficient way to do it, I think. There are probably other more complicated ways to do it - I'll bet that you could even use the .reduce() method to do it? But, yet, try it with regular expressions...
wowcoolwebsite
@wowcoolwebsite
Jan 19 2017 02:57
@revisualize wow you definitely tried though! i think you helped me on the right way, i think know how to solve it, i'll tell you, thanks!!
CamperBot
@camperbot
Jan 19 2017 02:57
wowcoolwebsite sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
Joseph
@revisualize
Jan 19 2017 02:57
@wowcoolwebsite Then after I skipped it... I came back around spent another couple days on it and finally sat down with someone for about 5 to 7 hours or so and got help on it.
CamperBot
@camperbot
Jan 19 2017 02:57
:star2: 3046 | @revisualize |http://www.freecodecamp.com/revisualize
wowcoolwebsite
@wowcoolwebsite
Jan 19 2017 02:58
@revisualize nice persistence!!!
Don't know why it doesn't work
Ken Haduch
@khaduch
Jan 19 2017 02:59
@CoryCMyers - you basically have this: array.reduce( function ( ) { } ); so the last paren closes the code block (the parameter to .reduce) that stars with the opening paren after the word "reduce". Is that what you wanted to know? The callback function is the parameter to the .reduce() method.
CoryCMyers
@CoryCMyers
Jan 19 2017 03:00
@khaduch That part I get, but I am wondering on the Why of it when everything has been curly before?
Or is it to assign the entirety of the function and saying this is what reduce will be doing in this situation?
James Shore
@Jimbobmahooley
Jan 19 2017 03:01
function largestOfFour(arr) {
  var largestNumbers;
  for (var i=0; i < 4; i++) {
    if (arr[i][0] > arr[i][1]) {
      arr[i][1] = arr[i][0];
    }
    if (arr[i][1] > arr[i][2]) {
      arr[i][2] = arr[i][1];
    }
    if (arr[i][2] > arr[i][3]) {
      arr[i][3] = arr[i][2];
    }
    largestNumbers.push(arr[i][3]);
  }
  return largestNumbers;
}
Hello, there is a flaw in my logic somewhere, can anyone help? thanks
Ken Haduch
@khaduch
Jan 19 2017 03:01
@CoryCMyers - normal parentheses always end the function parameter list - in this case, the parameter list for .reduce() is a function, and there could be an optional initial value. So to close the function argument list, a closing paren ) is the normal and required thing to do.
wowcoolwebsite
@wowcoolwebsite
Jan 19 2017 03:02
@revisualize THANKS a lot! your quick response on how arguments scope SAVED me a lot of time!!! SOLVED .)
CamperBot
@camperbot
Jan 19 2017 03:02
wowcoolwebsite sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: wowcoolwebsite already gave revisualize points
CoryCMyers
@CoryCMyers
Jan 19 2017 03:03
@khaduch That makes sense, guess it is just another thing I will be paying attention to what errors I am getting until it becomes a habit.
@khaduch thanks
CamperBot
@camperbot
Jan 19 2017 03:03
corycmyers sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2310 | @khaduch |http://www.freecodecamp.com/khaduch
Joseph
@revisualize
Jan 19 2017 03:04
@wowcoolwebsite Grats.
Ken Haduch
@khaduch
Jan 19 2017 03:04
@Jimbobmahooley - you are putting too many "hard-coded" things into your code, for one thing. This should be done with something like a couple nested for loops, if I remember correctly.
James Shore
@Jimbobmahooley
Jan 19 2017 03:06
@khaduch ah okay I'll try that thanks
CamperBot
@camperbot
Jan 19 2017 03:06
jimbobmahooley sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2311 | @khaduch |http://www.freecodecamp.com/khaduch
kez
@keztheminer
Jan 19 2017 03:06
return Math.floor(Math.random() * (myMax - myMin + 1)) +myMin; can someone explain what the last "+myMin "does please
Ken Haduch
@khaduch
Jan 19 2017 03:07
@Jimbobmahooley - are they still asking you to use array.map in there? My version looks like that's what I did? But maybe that wasn't what they put in their template code, it might be what I used... A couple nested for loops will do nicely. Probably could also do some higher-level functions. But go with the for loops for starters!
James Shore
@Jimbobmahooley
Jan 19 2017 03:09
@khaduch They didn't specifically ask for array.map I don't think so I'll give the for loops a go first
Flying_Fish
@FlyingFish195
Jan 19 2017 03:10
function rot13(str) { // LBH QVQ VG!
  var array;
  for(var i=0;i<str.length;i++){
    var UNicode=str.charCodeAt(i);
    var j;
    while(UNicode>=65&&UNicode<=90){

      if(UNicode>=78){
         j=String.fromCharCode(UNicode-13);
        array.push(j);
     }
      else{
        j=String.fromCharCode(UNicode-13+26);
        array.push(j);
     }
    }

  }
  var str2=array.join('');
  return str2;
}
who can tell me where is troble??please!!the output is always Cannot read property 'push' of undefined
Diego Mayer
@Chrono79
Jan 19 2017 03:10
@Jimbobmahooley for starters, you should make largestNumbers an array before trying to use push with it
Ken Haduch
@khaduch
Jan 19 2017 03:11
@Jimbobmahooley - I just redid it using array.map and array.reduce (since I'm trying to get more fluent with those methods...) go for the for loops!
Joseph
@revisualize
Jan 19 2017 03:11
@kezdarkriser It adds whatever the myMin value is.
FrancisOgertschnig
@FrancisOgertschnig
Jan 19 2017 03:11

I'm dong the Falsy Bouncer algorithm where you filter out anything false, 0, "", NaN, and undefined. I can clear out all but NaN and I'm not sure how to filter that out and leave values it wants. function bouncer(arr) {
// Don't show a false ID to this bouncer.

function clean1(value){
return value != false;
}

function clean2(value){
return value != null;
}

function clean3(value){
return !isNaN(value);
}

arr = arr.filter(clean1).filter(clean2).filter(clean3);

return arr;

}

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

Diego Mayer
@Chrono79
Jan 19 2017 03:12
@khaduch only one loop and sort wouldn't be enough?
Ken Haduch
@khaduch
Jan 19 2017 03:13
@Chrono79 - probably... just depends on what gets stuck in your head. :school: -- always new ways to think about it!
Diego Mayer
@Chrono79
Jan 19 2017 03:13
true
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 19 2017 03:13

Hey, I'm on the "Profile Lookup" section, can someone help me out with out just pasting the answer here???? Here's what I have so far:

//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 lookUpProfile(firstName, prop){
// Only change code below this line
var i = 0;

while (i < contacts.length) {

if (contacts.hasOwnProperty(firstName)) {

if (contacts.hasOwnProperty(prop)) {

  return contacts.prop;
}
return "No such property";

}
return "No such contact";
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "address");

CoryCMyers
@CoryCMyers
Jan 19 2017 03:13
So why are words or would they be strings? Okay to use here without qoutes?

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

// Only change code below this line.

array.sort(function(small, large) {
           return large - small;
           });
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 19 2017 03:13
*without
Diego Mayer
@Chrono79
Jan 19 2017 03:14
@TheRealChrisEdwards where are you changing i value? contacts is an array, you can't use hasOwnProperty with it either
Jceciliani
@Jceciliani
Jan 19 2017 03:14
can someone lead me in the right direction with switch statements? i''ve looked at the exernal link but i dont think I am completely understanding it. Here's what i have so far

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val)
case "alpha":
console.log(answer = "1");
break;

case "beta":
console.log(answer = "2");
break;
case "gamma":
console.log(answer = "3");
break;
case "delta":
console.log(answer = "4");
break;

}

Diego Mayer
@Chrono79
Jan 19 2017 03:15
@Jceciliani you function returns answer, so instead of using console.log, change answer value
Also, you have the values and the cases inverted, and the cases are numbers, not strings if I remember it well
switch(something){
  case 1:
    do something
  break;
  ...
}
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 19 2017 03:16
@Chrono79 yes, contacts is an array, but its a single array with 4 objects, that's why i tried to use .hasOwnProperty to check property value validity
James Shore
@Jimbobmahooley
Jan 19 2017 03:16
unction largestOfFour(arr) {
  var currentLargestNumber;
  var largestNumbers = [];
  for (var i=0; i < 4; i++) {
    for (var j=0; j < 4; j++) {
      if (arr[i][j] > currentLargestNumber) {
        currentLargestNumber = arr[i][j];
      }
    }
    largestNumbers.push(currentLargestNumber); 
  }
    return largestNumbers;
}
@khaduch is my logic wrong now?
Diego Mayer
@Chrono79
Jan 19 2017 03:17
@TheRealChrisEdwards you need to use contacts[i] (and change i inside the loop, otherwise it'll be an infinite loop)
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 19 2017 03:17
how am i supposed to with a while loop?
Moisés Man
@moigithub
Jan 19 2017 03:18
@Jimbobmahooley u need to reset ur currentLargestNum variable on each sub-iteration
OR.. it will keep previous subarray biggest value
Diego Mayer
@Chrono79
Jan 19 2017 03:18
@TheRealChrisEdwards do i++ before closing the loop (or use a for loop)
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 19 2017 03:18
ahhh, yes, i tried that, but WITH the .hasOwnProperty, and it did give me the message about never-ending loop
cool, thanks @Chrono79
CamperBot
@camperbot
Jan 19 2017 03:18
therealchrisedwards sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3172 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jan 19 2017 03:19
that's because the code inside the loop needs some fixing too
James Shore
@Jimbobmahooley
Jan 19 2017 03:19
@moigithub I see so after its been pushed set it to 0, however at the moment its returning the array [null, null, null, null,]
Moisés Man
@moigithub
Jan 19 2017 03:20
@Jimbobmahooley initialize ur variable to 0
9999999>undefined
///false
soo ur variable value never get replaced
Ken Haduch
@khaduch
Jan 19 2017 03:21
@Jimbobmahooley - can the hardcoded 4's - and think about initialization of the currentLargestNumber variable.
James Shore
@Jimbobmahooley
Jan 19 2017 03:21
@moigithub ah I see, and it works now so thanks a lot
CamperBot
@camperbot
Jan 19 2017 03:21
jimbobmahooley sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2550 | @moigithub |http://www.freecodecamp.com/moigithub
Ken Haduch
@khaduch
Jan 19 2017 03:22
@Chrono79 - I just rewrote the third version using array.map and sort... cool - thanks for the idea!
CamperBot
@camperbot
Jan 19 2017 03:22
khaduch sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
FrancisOgertschnig
@FrancisOgertschnig
Jan 19 2017 03:22

I'm dong the Falsy Bouncer algorithm where you filter out anything false, 0, "", NaN, and undefined. I can clear out all but NaN and I'm not sure how to filter that out and leave values it wants. function bouncer(arr) {
// Don't show a false ID to this bouncer.

function clean1(value){
return value != false;
}

function clean2(value){
return value != null;
}

function clean3(value){
return !isNaN(value);
}

arr = arr.filter(clean1).filter(clean2).filter(clean3);

return arr;

}

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

CamperBot
@camperbot
Jan 19 2017 03:22
:star2: 3173 | @chrono79 |http://www.freecodecamp.com/chrono79
James Shore
@Jimbobmahooley
Jan 19 2017 03:22
@khaduch you mean in the for loops?
Ken Haduch
@khaduch
Jan 19 2017 03:22
@Jimbobmahooley - at the correct place in the for loops...
Diego Mayer
@Chrono79
Jan 19 2017 03:23
@khaduch :+1: Another idea, map and Math.max
James Shore
@Jimbobmahooley
Jan 19 2017 03:24
@khaduch I think you mean arr.length and arr[i].length but it does say that it will always be 4 so does it matter?
CoryCMyers
@CoryCMyers
Jan 19 2017 03:24
Oh God...what is this Hello Bonfire...what have i gotten myself into?
Ken Haduch
@khaduch
Jan 19 2017 03:25
@Jimbobmahooley - just good coding practice to always use .length for arrays, because if they change the test cases at some point, then you'd have to go back and modify your code to have it run successfully... but in this case, hardcoded 4 will work. It would be greatly frowned upon :)
@Chrono79 - too.many.ideas... :octopus:
Moisés Man
@moigithub
Jan 19 2017 03:27
@FrancisOgertschnig global isNaN function return false positives
use Number.isNaN
or Boolean function
Diego Mayer
@Chrono79
Jan 19 2017 03:27
@khaduch Gotta catch'em all like pokemons
James Shore
@Jimbobmahooley
Jan 19 2017 03:27
@khaduch ah I see what you mean now, I'll change it, thanks for all the help, and thanks as well @Chrono79
CamperBot
@camperbot
Jan 19 2017 03:27
jimbobmahooley sends brownie points to @khaduch and @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: jimbobmahooley already gave khaduch points
:star2: 3174 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jan 19 2017 03:28
:+1:
Jceciliani
@Jceciliani
Jan 19 2017 03:28
I'm sorry, I am not understand switch statements at all. I know its probably just a simple switch here and there, no irony intended, but I can't wrap my brain around it. Can someone explain somewhat indepth what the issue is?

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case "a":
do "apple";
break;
case "b":
do "bird";
break;
case "c":
do "cat";
break;
default:
do "stuff";

}

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

// Change this value to test
switchOfStuff(1);

Ken Haduch
@khaduch
Jan 19 2017 03:29
@FrancisOgertschnig - here is a hint - array.filter docs say: callback returns a value that coerces to true. returns _ a _ value _ that _ coerces _ to _ true...
the hint is that it makes this super simple
@Jimbobmahooley - you're welcome... we're all learning a lot of stuff here this evening! @Chrono79 pushing a lot of brain cells into overload... :)
Vizij
@Vizij
Jan 19 2017 03:32
@Jceciliani Think of them like multi-branched if statements.
switch (value) {
  case "a":    // If value is a
  answer = "apple";     // then answer is "apple"
  break;
  case "b":
  answer = "blueberry";
  break;
  default:  // This happens if none of the cases match
  do something here
}
Jceciliani
@Jceciliani
Jan 19 2017 03:33
@Vizij you sir, are a legend. thank you
CamperBot
@camperbot
Jan 19 2017 03:33
jceciliani sends brownie points to @vizij :sparkles: :thumbsup: :sparkles:
:cookie: 314 | @vizij |http://www.freecodecamp.com/vizij
Diego Mayer
@Chrono79
Jan 19 2017 03:33
@Jceciliani do something was pseudocode, you have to change answer value there
andrewKyres
@andrewKyres
Jan 19 2017 03:35
for the Make a Person algorithm challenge, why should Object.keys(bob).length return 6?
Cory Ramirez
@CoryARamirez
Jan 19 2017 03:35

Hi guys, I was hoping someone could help me understand the logic behind the below function. The challenge lesson didn't really explain it that well:

function randomRange(myMin, myMax) {
return Math.floor(Math.random() * (myMax - myMin + 1)) + myMin;
}

var myRandom = randomRange(5, 15); //test case

andrewKyres
@andrewKyres
Jan 19 2017 03:36
@Chrono79 thanks I'll take a look
CamperBot
@camperbot
Jan 19 2017 03:36
andrewkyres sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3175 | @chrono79 |http://www.freecodecamp.com/chrono79
Cory Ramirez
@CoryARamirez
Jan 19 2017 03:36
I understand that we're using math.floor to round down the result of the randomly generated decimal number, but I'm not quite following this part: (myMax - myMin + 1)) + myMin;
Diego Mayer
@Chrono79
Jan 19 2017 03:37
@CoryARamirez Math.random returns a number between 0 (inclusive) and 1 (exclusive)
So, if it's 0, you'll get myMin of all that
If it is, let's say 0,9999999, you'll get Math.floor(almost myMax, - almostmyMin + almost 1) + myMin
you can cancel -almost myMin with myMin, and Math.floor(almost myMax + almost 1) will give you myMax
Put some values to see it better
Cory Ramirez
@CoryARamirez
Jan 19 2017 03:37

@Chrono79 That part I understand, I'm just not following: (myMax - myMin + 1)) + myMin;

what is the point of adding the 1, then re-adding our min number to the entire result?

Dylan Hsiao
@greedylan
Jan 19 2017 03:38
I found myself stuck on most of the exercises in intermediate algorithm scripting...tried reading the hint on github but still can not solve them on my own for hours...I realize there are many methods I dont even know after reading the solution...damn this is so hard...
Ken Haduch
@khaduch
Jan 19 2017 03:41
@CoryARamirez - I think of it as "raising" the lowest random number calculated up to the myMin level.
Diego Mayer
@Chrono79
Jan 19 2017 03:41
@CoryARamirez the +1 is there because Math.random will never return 1, so you'll never get myMax otherwise
the +myMin outside is so the lesser value you get is myMin
Simon Herrera
@HamsaSimon
Jan 19 2017 03:42
can someone help me I'm getting the correct result in my output but it still considered wrong?

function isLess(a, b) {
// Fix this code
var boolean = "";
switch(true) {
case a < b:
boolean= "true";
break;
default:
boolean = "false";

}

return boolean;
}

// Change these values to test
isLess(15, 10);

Diego Mayer
@Chrono79
Jan 19 2017 03:43
@HamsaSimon are you using global vars?
Cory Ramirez
@CoryARamirez
Jan 19 2017 03:43
@Chrono79 Thanks! I'll have to look more into it. :)
CamperBot
@camperbot
Jan 19 2017 03:43
coryaramirez sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3176 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jan 19 2017 03:43
@HamsaSimon "true" is not a boolean, that's a string
Ken Haduch
@khaduch
Jan 19 2017 03:43
@greedylan - it takes time. As I see just this evening with my different attempts at the largestOfFour (and the fact that I've been programming for years, which might be part of the problem) there are always new ways to think about problems and you start with the basics, like I was using for loops to do that, and @Chrono79 pointed out a couple different takes on it after I tried a different one. There are a lot of new things to learn, and in my case new things that are hard to remember. You just have to persevere, keep plugging away, try to laugh about it now and then. As they say in the intro materials - Coding is hard...
And on top of that, all of these new JavaScript methods and even ES6 that is coming along - there is a LOT to learn to be really proficient at this!
Simon Herrera
@HamsaSimon
Jan 19 2017 03:44
oh ok !
thanks I will try to look how to output a boolean then
@Chrono79 thanks
CamperBot
@camperbot
Jan 19 2017 03:44
hamsasimon sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3177 | @chrono79 |http://www.freecodecamp.com/chrono79
Simon Herrera
@HamsaSimon
Jan 19 2017 03:44
ok i will
Diego Mayer
@Chrono79
Jan 19 2017 03:44
@HamsaSimon another thing, the goal of that challenge is not replacing an if/else with switch
Look at the example code
fiehl
@fiehl
Jan 19 2017 03:45
anyone know about this challenge? Stand in Line
Clara Mae Wells
@run-cmw
Jan 19 2017 03:45
@HamsaSimon The computer recognizes a boolean just as it recognizes a number. No quotes necessary.
FrancisOgertschnig
@FrancisOgertschnig
Jan 19 2017 03:45
@khaduch Ok, I'm still not getting it, I've tried a few combinations but it's passing some but not all of the test cases. Maybe I need a break as I've been on fCC since the morning.
Simon Herrera
@HamsaSimon
Jan 19 2017 03:45
@chrono79 oh ok !
fiehl
@fiehl
Jan 19 2017 03:45
please help
Diego Mayer
@Chrono79
Jan 19 2017 03:46
@fiehl review array manipulation methods: pop, push, shift and unshift, you need to use 2 of them there
See how to use them and what they return
Simon Herrera
@HamsaSimon
Jan 19 2017 03:46
@camperbot how do I give brownie points ?
Ken Haduch
@khaduch
Jan 19 2017 03:46
@FrancisOgertschnig - what's your code look like now? Although somewhere i just read that you should not end your programming time with a success, it should be something that you're hanging on to, it helps you to learn better?
fiehl
@fiehl
Jan 19 2017 03:46
yes i use the shift and push, but the didn't get the right output
Diego Mayer
@Chrono79
Jan 19 2017 03:47
@fiehl show your code then
fiehl
@fiehl
Jan 19 2017 03:47

function nextInLine(arr, item) {
// Your code here
var item1 = arr.shift();
arr.push(item);
return item1; // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine([], 1)); // Modify this line to test
console.log("After: " + JSON.stringify

Ken Haduch
@khaduch
Jan 19 2017 03:47
@HamsaSimon - mention the persons name with @ and name concatenated without spaces, and say thanks or some variation thereof...
Diego Mayer
@Chrono79
Jan 19 2017 03:47
@fiehl order matters, what do the instructions say?
fiehl
@fiehl
Jan 19 2017 03:48
nextInLine([], 1) should return 1
Simon Herrera
@HamsaSimon
Jan 19 2017 03:48
@khaduch ok thanks I already did that!
CamperBot
@camperbot
Jan 19 2017 03:48
hamsasimon sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2312 | @khaduch |http://www.freecodecamp.com/khaduch
Dylan Hsiao
@greedylan
Jan 19 2017 03:48
@khaduch to be honest I am at the low point of doing FCC right now...but imma keep at it.
fiehl
@fiehl
Jan 19 2017 03:48
the other 3 was right and this one was the only one left
Diego Mayer
@Chrono79
Jan 19 2017 03:48
I mean what are you supposed to do first @fiehl adding or removing?
fiehl
@fiehl
Jan 19 2017 03:48
first add the number at the end
Adam Wayne
@AdamWayne-dev
Jan 19 2017 03:48

Hey guys, just to clarify. With a recursion, when it comes to calling the method at the end, e.g.

return num * factorialize(num - 1);

Does this re-call the method, and loop around until the condition inside the method is met?

fiehl
@fiehl
Jan 19 2017 03:49
then remove the first element of array
Diego Mayer
@Chrono79
Jan 19 2017 03:49
@fiehl so, is shift the first method you should be using?
Simon Herrera
@HamsaSimon
Jan 19 2017 03:49
@run-cmw ok actually that worked !
@run-cmw appreciate the help
Clara Mae Wells
@run-cmw
Jan 19 2017 03:50
@HamsaSimon Awesome!
Dylan Hsiao
@greedylan
Jan 19 2017 03:50
@AdamWayne-dev you need to give it a base case and call it to stop.
Diego Mayer
@Chrono79
Jan 19 2017 03:51
@fiehl that test case failed because you can't remove what is not there ;)
Adam Wayne
@AdamWayne-dev
Jan 19 2017 03:51
@greedylan hang on, I'll post the code. I was just curious as to how the code loops, and carries on until the base case is met.
function factorialize(num) {
  if (num === 0) {
    return 1;
  }
  return num * factorialize(num - 1);
}

factorialize(5);
Clara Mae Wells
@run-cmw
Jan 19 2017 03:52
I'm on the Profile Lookup. My code didn't work, so I went to CodeCademy for a few days of JS to try to fill in some gaps. I learned new things, but not what I need for this challenge. Anyone down to view my code and give hints? Or direct me where I could learn more? https://gist.github.com/run-cmw/b7711f9a1d8988c2f4e4c20b0b84c1de
Diego Mayer
@Chrono79
Jan 19 2017 03:52
@AdamWayne-dev try your code here: http://www.pythontutor.com/javascript.html#mode=display
Ken Haduch
@khaduch
Jan 19 2017 03:52
@greedylan - it might be good to pursue a couple other learning venues at the same time - something that, perhaps, goes into JavaScript in more depth? There are tons of youtube videos, for example, I'm going through a series that someone pointed to a few nights ago here, this guy is covering "higher-order functions" - like the array methods filter, reduce, etc. That seems to be a way to do a lot of things in a more advanced way. There are so many resources out there! I don't know if this is the right place to start - higher-order functions video lessons - but if you google something like "javascript lessons" you'd probably find a lot. You just might get a lot out of them with the foundation that you started to build, and seeing someone who is trying to teach new things, it might just firm up the knowledge or hit you in a different way to help you remember? Just a thought...
Diego Mayer
@Chrono79
Jan 19 2017 03:52
@run-cmw contacts is an array
to access a single contact object, you should use brackets and a var, like this: contacts[i]for instance
Dylan Hsiao
@greedylan
Jan 19 2017 03:53
@AdamWayne-dev yeah, try plugging in your code here and see how computer process your codes
http://www.pythontutor.com/javascript.html
Adam Wayne
@AdamWayne-dev
Jan 19 2017 03:53
@Chrono79 Thanks for the website, but it's giving me errors with my code ahaha :D
CamperBot
@camperbot
Jan 19 2017 03:53
adamwayne-dev sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3179 | @chrono79 |http://www.freecodecamp.com/chrono79
Clara Mae Wells
@run-cmw
Jan 19 2017 03:53
Thanks @Chrono79
CamperBot
@camperbot
Jan 19 2017 03:53
run-cmw sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3180 | @chrono79 |http://www.freecodecamp.com/chrono79
Adam Wayne
@AdamWayne-dev
Jan 19 2017 03:53
@greedylan Thank you!
CamperBot
@camperbot
Jan 19 2017 03:53
adamwayne-dev sends brownie points to @greedylan :sparkles: :thumbsup: :sparkles:
:cookie: 206 | @greedylan |http://www.freecodecamp.com/greedylan
Diego Mayer
@Chrono79
Jan 19 2017 03:54
@AdamWayne-dev are you sure? It works for me
Adam Wayne
@AdamWayne-dev
Jan 19 2017 03:54
Yeah it says it's taking too long or taking up too much memory
Diego Mayer
@Chrono79
Jan 19 2017 03:55
@AdamWayne-dev is this the code you've tried?
function factorialize(num) {
  if (num === 0) {
    return 1;
  }
  return num * factorialize(num - 1);
}

factorialize(5);
Adam Wayne
@AdamWayne-dev
Jan 19 2017 03:55
Yes
Dylan Hsiao
@greedylan
Jan 19 2017 03:55
@khaduch yeah I definitely need more in-depth knowledge...I been dealing with problem beyond my current level. Thanks for the info!
CamperBot
@camperbot
Jan 19 2017 03:55
greedylan sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2313 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Jan 19 2017 03:55
@greedylan - google "javascript lessons free online" - there are tons of resources there. As I said, maybe just looking at a different approach, more examples, more explanations will be helpful. I find that it's good to try something and struggle with it and through it, then go and get material to back it up or approach it from a different angle. It just takes a lot of time, but that's really the price to pay for learning this stuff! As I said - just my opinion but maybe others will have additional takes on it.
John Roper
@jroper19
Jan 19 2017 03:55
// Setup
function abTest(a, b) {
  // Only change code below this line
  console.log (a,b <= 0);
return "undefined";


  // Only change code above this line

  return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(2,2);
Can anyone tell me if im on the right track here? The focus is the "console.log" and "undefined" parts.
Diego Mayer
@Chrono79
Jan 19 2017 03:56
@jroper19 you need to use an if and "undefined" is a string, not the value undefined (remove the quotes)
Adam Wayne
@AdamWayne-dev
Jan 19 2017 03:57
@Chrono79 even that isn't working lol
Diego Mayer
@Chrono79
Jan 19 2017 03:57
@AdamWayne-dev well, it doesn't like you it seems :P
Ken Haduch
@khaduch
Jan 19 2017 03:57
@greedylan - good luck - I think you can get this, just take a step back and fill in gaps in what you know. The gaps should be smaller with what you've done so far, so perhaps more easily filled?
Adam Wayne
@AdamWayne-dev
Jan 19 2017 03:57
@Chrono79 Haha indeed :( it's ok, I'll do some reading and see if I can figure out why it works! Thank you for the help though.
CamperBot
@camperbot
Jan 19 2017 03:57
adamwayne-dev sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
John Roper
@jroper19
Jan 19 2017 03:57
@Chrono79 Ahhhhhhh... I wondered about an "if". Thanks.
CamperBot
@camperbot
Jan 19 2017 03:57
:warning: adamwayne-dev already gave chrono79 points
jroper19 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3181 | @chrono79 |http://www.freecodecamp.com/chrono79
John Roper
@jroper19
Jan 19 2017 04:00
@Chrono79 Helpful, but they dont want true or false in the challenge, they want "undefined" specifically.
Dylan Hsiao
@greedylan
Jan 19 2017 04:01
@khaduch I think my problem is not able to think like a computer, every time I read a solution I go like "yeah why didn't I think of that?" lol anyway thanks for the suggestion!!
CamperBot
@camperbot
Jan 19 2017 04:01
greedylan sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: greedylan already gave khaduch points
Diego Mayer
@Chrono79
Jan 19 2017 04:01
@jroper19 it's helpful about how you use or, not commas ;)
Adam Wayne
@AdamWayne-dev
Jan 19 2017 04:02
I understand it now! It calls itself and then just minuses the number each time. Lol I feel like such a fool for not seeing that!
The method calls itself*
Ken Haduch
@khaduch
Jan 19 2017 04:03
@run-cmw - as @Chrono79 pointed out, you are recognizing that contacts is an array, and generating an index to iterate through it. But you have to do all of your matching and comparison within the loop - so your first two code lines for result1 and result2 are going down the wrong path. I like to recommend that you just put some code in there to console.log the firstName values of each contact, just to get the feel for how to access those. Then work from there.
@greedylan - I hear you - I've been doing this for years, and still feel that way with new things (or old things that I haven't seen in a long time.)
Dylan Hsiao
@greedylan
Jan 19 2017 04:04
@AdamWayne-dev I think you should also limiting the "num" from being negative
Adam Wayne
@AdamWayne-dev
Jan 19 2017 04:05
@greedylan Yes, I saw that on the CodeAcademy lesson on it. I guess I would just add another if statement with a condition for num < 0 and then I'd return if that was the case?
I've been coding too much today, I keep wanting to type a ";" at the end of my sentences lol
Diego Mayer
@Chrono79
Jan 19 2017 04:06
@AdamWayne-dev @greedylan num <=0 is safer, because if num wasn't a whole number you'll get an infinite recursive loop, I think it isn't infinite (at least in js), it's called maximum call stack error or something like that
jmgumina
@jmgumina
Jan 19 2017 04:07
Hi There I am doing the Escape Sequence in Strings on free code camp and I am having some trouble "escaping"
Adam Wayne
@AdamWayne-dev
Jan 19 2017 04:07
@Chrono79 Good idea! thanks!
CamperBot
@camperbot
Jan 19 2017 04:07
adamwayne-dev sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: adamwayne-dev already gave chrono79 points
jmgumina
@jmgumina
Jan 19 2017 04:07
var myStr = "FirstLine\nSecondLine\rThirdLine"; // Change this line
Diego Mayer
@Chrono79
Jan 19 2017 04:07
@jmgumina where are your escaped backslashes around SecondLine?
jmgumina
@jmgumina
Jan 19 2017 04:08
var myStr = "FirstLine\nSecondLine\rThirdLine"; // Change this line
like that?
var myStr = "FirstLine\nSecondLine\rThirdLine"; // Change this line
Ogundele Olumide
@Lumexralph
Jan 19 2017 04:08
@jmgumina you're not escaping backslash \\ before and after Secondline
jmgumina
@jmgumina
Jan 19 2017 04:08
hmm weird it is deleting it when i send it
Diego Mayer
@Chrono79
Jan 19 2017 04:08
@jmgumina click more info
CamperBot
@camperbot
Jan 19 2017 04:08
:bulb: to format code use backticks! ``` more info
jmgumina
@jmgumina
Jan 19 2017 04:09
\nSecondLine\
Thank you!
Diego Mayer
@Chrono79
Jan 19 2017 04:09
:+1:
And that's it for now, gotta hit the sack, see you
Ogundele Olumide
@Lumexralph
Jan 19 2017 04:10
@Chrono79 :+1:
sleep well
Simon Herrera
@HamsaSimon
Jan 19 2017 04:18

Instructions
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.

I'm doing what the instructions are telling me but I't won't let me advanced because it expects that other outputs should be met.
help??

function abTest(a, b) {
// Only change code below this line
if (a || b < 0) {
return undefined;

}

// Only change code above this line

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}
// Change values below to test your code
abTest(2,2);

Ogundele Olumide
@Lumexralph
Jan 19 2017 04:19
@HamsaSimon if (a || b < 0) { check this place
@HamsaSimon < has an other of precedence over || and || just returns a or b depending if it's true or not (a < 0 || b < 0) that will check if both a or b is less than 0
Clara Mae Wells
@run-cmw
Jan 19 2017 04:24
Thank you @khaduch
CamperBot
@camperbot
Jan 19 2017 04:24
run-cmw sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2314 | @khaduch |http://www.freecodecamp.com/khaduch
Simon Herrera
@HamsaSimon
Jan 19 2017 04:26
@Lumexralph thank you Ogundele
CamperBot
@camperbot
Jan 19 2017 04:26
:cookie: 767 | @lumexralph |http://www.freecodecamp.com/lumexralph
hamsasimon sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
Simon Herrera
@HamsaSimon
Jan 19 2017 04:27
@Lumexralph that worked :+1:
Jceciliani
@Jceciliani
Jan 19 2017 04:28
can someone tell me if I am even on the right track for the counting card function? Or if I should just scrap it and try it another way.

var count = 0;

function cc(card) {
// Only change code below this line
if (card = 2,3,4,5,6) {
return +1;
}
else if (card = 7,8,9) {
return 0;
}
else if (card = 10, 'J', 'Q', 'K', 'A') {
return -1;
}

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(10); cc(10); cc(10); cc('K'); cc('A');

Ogundele Olumide
@Lumexralph
Jan 19 2017 04:30
@Jceciliani if (card = 2,3,4,5,6) { should be if(card === 2 || card === 3 || card === 4......) { count += 1} not return +1 ditto for the else ifs
Nick Janne
@njanne19
Jan 19 2017 04:31
Hello, can someone tell me why adding the else if statement in my code makes the loop inifnite
function updateInventory(arr1, arr2) {
    // All inventory must be accounted for or you're fired!

  var x = 0;

  while (x<arr1.length) {
    for(var i = 0; i<arr2.length; i++) {
      if(arr1[x].indexOf(arr2[i][1]) > 0) {
        arr1[x][0] += arr2[i][0];
      } else if (arr1[x].indexOf(arr2[i][1]) < 0)
        arr1.push(arr2[i]);
      }  
    x++;
  }
when I have the if statement alone it works exactly as I intended it to
Ammy3165
@Ammy3165
Jan 19 2017 04:35
anybody can tell me the difference between .concat() and .push()
Ogundele Olumide
@Lumexralph
Jan 19 2017 04:35
@njanne19 where the curly braces for your esle if condtion {} ?
Ken Haduch
@khaduch
Jan 19 2017 04:36
@njanne19 - hey Nick from Boston!
You are iterating over arr1 with your while loop, but with the else if, you are potentially making arr1 longer with each iteration... so that looks like it could be infinite
Nick Janne
@njanne19
Jan 19 2017 04:36
@Lumexralph I figured it out where my loop error was, because basically my else if statement adds another piece of length to the while loop
Tes Chan
@TesChan
Jan 19 2017 04:36

Hi, I'm doing the Search and Replace exercise in Intermediate Algorithm Scripting, can someone tell me why the code below doesn't work?

function myReplace(str, before, after) {
var newBefore ='/'+before+'/gi';
var newstr=str.replace(newBefore, after);

return newstr;
}

myReplace("Let us go to the store", "store", "mall");

Ogundele Olumide
@Lumexralph
Jan 19 2017 04:37
@njanne19 arr1.push(arr2[i]); this will lead to the loop as i increases, length increases
Ammy3165
@Ammy3165
Jan 19 2017 04:37
anybody can tell me the difference between .concat() and .push()
jaghvi
@mehtajaghvi
Jan 19 2017 04:38
@Jceciliani you need to do count++ or count+=1 and not return 0 or -1
Nick Janne
@njanne19
Jan 19 2017 04:38
@khaduch Thank you for the help on that, in order to fix it, I decided to make a temporary array for all of the values that did not appear in arr1. Now my question is, what can I write to make sure that my temporary array does not have every trial, just one element for each piece of arr2 that was not in arr1
cjljohnson
@cjljohnson
Jan 19 2017 04:38
Hi, is there a way to format a number so that it has a max number of digits
CamperBot
@camperbot
Jan 19 2017 04:38
njanne19 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2315 | @khaduch |http://www.freecodecamp.com/khaduch
cjljohnson
@cjljohnson
Jan 19 2017 04:38
ie max digits rather than max sig figs
Ogundele Olumide
@Lumexralph
Jan 19 2017 04:38
@Ammy3165 concat joins 2 arrays, push adds an element to the end of an array
Jamie Lipschitz
@Jlipschitz
Jan 19 2017 04:39
@Ammy3165 concat will also return a new array, push will mutate the original
Ammy3165
@Ammy3165
Jan 19 2017 04:39
@Lumexralph thanks
CamperBot
@camperbot
Jan 19 2017 04:39
ammy3165 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 768 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ammy3165
@Ammy3165
Jan 19 2017 04:39
@Jlipschitz thanks
CamperBot
@camperbot
Jan 19 2017 04:39
ammy3165 sends brownie points to @jlipschitz :sparkles: :thumbsup: :sparkles:
:cookie: 225 | @jlipschitz |http://www.freecodecamp.com/jlipschitz
jaghvi
@mehtajaghvi
Jan 19 2017 04:39
@cjljohnson can you explain more
Jamie Lipschitz
@Jlipschitz
Jan 19 2017 04:41
@cjljohnson you can use toFixed(val) method or toPrecision(val) method
cjljohnson
@cjljohnson
Jan 19 2017 04:42
@mehtajaghvi i am trying to do the calculator. my result can fit up to 9 digits within the ui so i want to format the number so it has at most 9 digits. currently i am using Intl.NumberFormat to reduce it to max 9 sig figs, but if it's a very small number it will become 0.0000123456789 so still overflow
toFixed and toPrecision always use a set number of digits though right? i don't want to display 1 as 000000001
if you do 1/2 and then keep hitting equals you can see what i mean
Ammy3165
@Ammy3165
Jan 19 2017 04:45
can I use .unshift() before .shift()??
Jamie Lipschitz
@Jlipschitz
Jan 19 2017 04:47
@cjljohnson ahh I see you wouldn't want to change it for all... hmm i'm sure there's a better way but for a quick fix why not compare the length of the number? Then you can have a condition like if( num.toString().length > 9) { num.toFixed(9) }
Joseph
@revisualize
Jan 19 2017 04:48
Hi.
Anyone need help?
I'm sitting here sewing up my backpack and I was thinking.. Maybe I could face time some people and offer a little help.
Ogundele Olumide
@Lumexralph
Jan 19 2017 04:48
@revisualize yes
@revisualize how can I learn how to sow a backpack?
Joseph
@revisualize
Jan 19 2017 04:50
@Lumexralph I carry two laptops so.. My shoulder straps are coming undone.
I'm basically just re-enforcing the current stitching.
Ogundele Olumide
@Lumexralph
Jan 19 2017 04:50
@revisualize damn bro! that's work
@revisualize laptops are heavy on you as time increases let alone carry 2! why?
Joseph
@revisualize
Jan 19 2017 04:51
One work Surface Pro 4 and my personal laptop.
Jceciliani
@Jceciliani
Jan 19 2017 04:54
the function works, I just need to add a space inbetween the answers and quotes. any suggestions?

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 (count > 0) {
return count + "Bet";

}
else {
return count + "Hold";
}
return "Change Me";

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(10); cc('J'); cc('J'); cc('J'); cc('J');

Joseph
@revisualize
Jan 19 2017 04:54
@Lumexralph I technically don't even know if what I'm doing is "sewing" I'm really just pushing a needle and thread through fabric in locations next to each other.
@Jceciliani
@Jceciliani The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
Ogundele Olumide
@Lumexralph
Jan 19 2017 04:55
@Jceciliani space count + " Bet"
h1tag
@h1tag
Jan 19 2017 04:55
Hey, I'm on the Local Weather project, I'm working on changing the background according to the weather forecast, I've created a changeBackground(response, bgs) function that takes the response from the weather api and a backgrounds object that contains the urls to the backgrounds and uses a switch case to apply the background according to the weather but it's not working. Here's the codepen: https://codepen.io/FortMax/pen/zNNWLK
Jceciliani
@Jceciliani
Jan 19 2017 04:56
@revisualize @Lumexralph How about adding quotes around the whole thing?
Ogundele Olumide
@Lumexralph
Jan 19 2017 04:56
@revisualize it's more like it, but it's inevitable carrying 2 laptops?
@Jceciliani it will turn count to a string and you need count to be a variable holding the value
Joseph
@revisualize
Jan 19 2017 04:56
@Jceciliani How about you don't turn "count" into a string?
grantknaver
@grantknaver
Jan 19 2017 04:58
im trying to push collection[i] if it meets the criteria of my if statement, but for the life of me I cant get the var answer to return anything but an empty array. Any ideas?
jaghvi
@mehtajaghvi
Jan 19 2017 04:58
Guys, the methods inside a constructor are they also constructors as they use the function keyword?
Joseph
@revisualize
Jan 19 2017 04:59
@grantknaver Hey, I'm trying to enumerate across a complex set of objects. Any idea why I can't do it?
@grantknaver You need more info?!
NO WAY!
grantknaver
@grantknaver
Jan 19 2017 05:00
lol
here is the code. dang you on it lol
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:00
@mehtajaghvi no they are not
grantknaver
@grantknaver
Jan 19 2017 05:00
function whatIsInAName(collection, source) {
   var sourceName = Object.keys(source);
   var answer = [];

 for(var i = 0; i < collection.length; i++){
   for(var j = 0; j < sourceName.length; j++){
     if(collection[i].hasOwnProperty(sourceName[j]) && collection[i][sourceName[j]] === source[sourceName[j]]){
      answer.push(collection[i]);

      }
     return answer; //continues to return empty array
     //console.log(answer);
   }
 }

}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Joseph
@revisualize
Jan 19 2017 05:00
@grantknaver OH! I haven't done that challenge yet.
There we go.. I have re-enforced the straps on my backpack.
grantknaver
@grantknaver
Jan 19 2017 05:01
im just trying to get the collections[i] that meet the if statement to move to the answer variable
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:02
@mehtajaghvi constructor is also a function always remember that. they only change the name has this Bike just for style in Js to show it's a constructor function.....
Joseph
@revisualize
Jan 19 2017 05:02
Damn, my little attempt at sewing looks like crap.
BUT!
grantknaver
@grantknaver
Jan 19 2017 05:02
safety first...
Joseph
@revisualize
Jan 19 2017 05:02
Gets the job done.
grantknaver
@grantknaver
Jan 19 2017 05:02
lol
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:03
@revisualize just like codes :laughing:
grantknaver
@grantknaver
Jan 19 2017 05:03
what is weird is I get a empty array when I return answer, but that is not what I get when I console.log it very weird
Edgar Pan
@edgaryp
Jan 19 2017 05:04
Hi, I could not get my head around with closure functions, why mjName ("Jackson"); returns Jackson as last name?
function celebrityName(firstName) 
  var nameIntro = "This celebrity is ";
  function lastName(theLastName) {
    return nameIntro + firstName + " " + theLastName;
  }
  return lastName;
}
var mjName = celebrityName("Michael");
mjName("Jackson"); //Michael Jackson
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:04
@grantknaver return answer when the outer loop is done and if it returns an empty array you need to check your if condition in the loop, nothing is being pushed
grantknaver
@grantknaver
Jan 19 2017 05:06
hmm gotcha
Jamie Lipschitz
@Jlipschitz
Jan 19 2017 05:07
@fortMaximus your bgs is a global variable so no need to pass it into your changeBackground(response, bgs). Can you try changing all the images to display over https? Looks as though that's the only error getting returned
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:08
@edgaryp where is the opening { of your function ?
ChinaKe
@ChinaKe
Jan 19 2017 05:09
hi
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:10
@edgaryp
function celebrityName(firstName)    //where's    { ?
  var nameIntro = "This celebrity is ";
  function lastName(theLastName) {
    return nameIntro + firstName + " " + theLastName;
  }
  return lastName;
}
@ChinaKe hey
Edgar Pan
@edgaryp
Jan 19 2017 05:10
@Lumexralph accidentally deleted it
function celebrityName(firstName) {
  var nameIntro = "This celebrity is ";
  function lastName(theLastName) {
    return nameIntro + firstName + " " + theLastName;
  }
  return lastName;
}
var mjName = celebrityName("Michael");
mjName("Jackson");
Eric
@ericsolomon21
Jan 19 2017 05:10
Hi, I could use some help testing objects for properties in JS. I am working on the "Profile Lookup" project.
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:11
@edgaryp what do you need help with, the code seems fine
@ericsolomon21 what have you done?
Eric
@ericsolomon21
Jan 19 2017 05:11

function lookUpProfile(firstName, prop){
if (contacts.hasOwnProperty(firstName)){
if (contacts.hasOwnProperty([firstName],[prop])){
return contacts[firstName],[prop];
} else {return "No such contact";}
} else {return "Not Found";}

// Only change code above this line
}

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

h1tag
@h1tag
Jan 19 2017 05:11
@Jlipschitz still not working
Edgar Pan
@edgaryp
Jan 19 2017 05:12
@Lumexralph yeah the code works. My question was I could not get my head around with closure functions, why mjName ("Jackson"); returns Jackson as last name?
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:12
@ericsolomon21 first and foremost contacts is an array of objects, so you should be thinking of using s loop to access the objects
Jamie Lipschitz
@Jlipschitz
Jan 19 2017 05:12
link the pen with the img changes @fortMaximus
Eric
@ericsolomon21
Jan 19 2017 05:13
Not sure how to get my code to appear in the chat like it does on my screen...
G R Maw
@Chekhovian
Jan 19 2017 05:13
@ericsolomon21 I'm also struggling with this one.
Eric
@ericsolomon21
Jan 19 2017 05:15
@Chekhovian what do you have so far?
G R Maw
@Chekhovian
Jan 19 2017 05:15
@ericsolomon21 I'm pretty sure the idea is to use a for loop, then a series of if else statements inside.. for (var i = 0; i < contacts.length; i++){
if (contacts[i].firstName === firstName) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
} else {
return "No such property";
}
return "No such contact";
}
}
doesn't work of course
@ericsolomon21 I'm lost in a sea of curly braces
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:16
@edgaryp closure is a state of a function remembering it's environment when it was declared, var mjName = celebrityName("Michael"); returns function lastName which is where the closure occurred, when you did mjName("Jackson"); you're calling that lastName function which remembers the whole environment of celebrityName function... take a look at this https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures
Rachel Riley
@ParadiseArtist
Jan 19 2017 05:17
Hello all!
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:18
@Chekhovian return No such contact when you're done looking through the contacts i.e when the for loop is done
Rachel Riley
@ParadiseArtist
Jan 19 2017 05:18
I'm working on the find the longest word in a string problem and I think I have an ok approach but I'm trying to figure out how to compare the results of the string.length of each word.
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:18
@ParadiseArtist hi
Jamie Lipschitz
@Jlipschitz
Jan 19 2017 05:18
@fortMaximus you're passing in the "url(bgs.whatever)" as a full string, you need to concatenate
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:19
@ParadiseArtist store the initial string length and compare it with the next one, if the next string length is larger swap to the larger
Rachel Riley
@ParadiseArtist
Jan 19 2017 05:21
Ok I'll try to write that out to get something going and I'll paste the results here in a couple min
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:22
@ParadiseArtist okay
G R Maw
@Chekhovian
Jan 19 2017 05:23
@Lumexralph I get syntaxError: return not in function
for (var i = 0; i < contacts.length; i++){
if (contacts[i].firstName === firstName) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
} else {
return "No such property";
}
}
}
return "No such contact";
h1tag
@h1tag
Jan 19 2017 05:24
@Jlipschitz yea, you're right. Can you explain why is takes it as a full string?
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:24
@Chekhovian you're not creating a function to start with, put what you wrote in FCC function provided
grantknaver
@grantknaver
Jan 19 2017 05:29
an ! in front of a if statement lets say if(!collection[i].hasOwnProperty(sourceName[j]) && collection[i][sourceName[j]] === source[sourceName[j]]) does that mean if this doesnt happen?
G R Maw
@Chekhovian
Jan 19 2017 05:29
@Lumexralph Thanks. I must have accidentally deleted it. My new code is function lookUpProfile(firstName, prop){
// Only change code below this line
function LookUpProfile(firstname, prop){
for (var i = 0; i < contacts.length; i++){
if (contacts[i].firstName === firstName) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
} else {
return "No such property";
}
}
}
}
return "No such contact";
// Only change code above this line
}
CamperBot
@camperbot
Jan 19 2017 05:29
chekhovian sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 769 | @lumexralph |http://www.freecodecamp.com/lumexralph
Jamie Lipschitz
@Jlipschitz
Jan 19 2017 05:30
@fortMaximus anytime you encapsulate anything with quotes it will be considered a string. it's no different than the rest of your code that you concatenated, you're just overlooking it in this case.
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:31
@Chekhovian working now?
G R Maw
@Chekhovian
Jan 19 2017 05:31
I get one green tick for ("Bob", "number") should return "No such contact" and my console logs 'No such contact'
h1tag
@h1tag
Jan 19 2017 05:33
@Jlipschitz e.g. why it doesn't interpret "background-image" as a string?
jaghvi
@mehtajaghvi
Jan 19 2017 05:33
Guys, how is a-b working in sorting?
bensch5000
@bensch5000
Jan 19 2017 05:34
hey guys, has anyone done the DNA pairing challenge yet?
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:34
@Chekhovian you have one } more ...
@mehtajaghvi subtracting them from each other a - b =0 or 1 or -1
Eric
@ericsolomon21
Jan 19 2017 05:35
@Chekhovian do we need a second else for the "No such contact"?
jaghvi
@mehtajaghvi
Jan 19 2017 05:36
@Lumexralph but i thought it meant subtracting the passed values in the array (a,b are the values of the array element)
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:36
@mehtajaghvi so depending on the result of their subtraction a - b
Eric
@ericsolomon21
Jan 19 2017 05:37

@Chekhovian the Bob one is only red X I am getting with this code:

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

// Only change code above this line
}

Greg Duncan
@GregatGit
Jan 19 2017 05:37
@bensch5000 yes - are you stuck?
Michael Marvive
@Marvive
Jan 19 2017 05:37
Screen Shot 2017-01-18 at 9.37.03 PM.png
Guys, I'm completely stuck. Any help?
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:37
@mehtajaghvi it depends on how you're sorting, if you want to sort values like numbers, you need a callback that uses the a - b which pick previous and next value in the array to compare by subtraction to know which is larger
jaghvi
@mehtajaghvi
Jan 19 2017 05:38
@Lumexralph from the reading I understand we use a-b to sort numerically instead of the unicode sorting, what is a and b here, shouldn't comparison return 1 value (a<b) -1 , how is a-b working
h1tag
@h1tag
Jan 19 2017 05:38
@Jlipschitz got it. Thanks. It's because bgs.whatever is a variable.
CamperBot
@camperbot
Jan 19 2017 05:38
fortmaximus sends brownie points to @jlipschitz :sparkles: :thumbsup: :sparkles:
:cookie: 226 | @jlipschitz |http://www.freecodecamp.com/jlipschitz
Eric
@ericsolomon21
Jan 19 2017 05:38
@Chekhovian All my other ones are green checks now. So I am thinking we are missing a second else somewhere before the - return "No such contact"; - But I haven't been able to figure it out yet
bensch5000
@bensch5000
Jan 19 2017 05:39
@GregatGit managed the challenge but I’m really interested in other solutions. I used a switch for pushing the pairs in 2d arrays. feels like there are plenty more resource-saving solutions I didn’t came up with
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:39
@mehtajaghvi remember a - b = 1 is same as a > b ?
jaghvi
@mehtajaghvi
Jan 19 2017 05:39
@Lumexralph , so a-b <0 signifies -1 , I see
@Lumexralph thanks :)
CamperBot
@camperbot
Jan 19 2017 05:39
mehtajaghvi sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 770 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:39
@mehtajaghvi exactly
Michael Marvive
@Marvive
Jan 19 2017 05:40
Can anyone help on mine?
Greg Duncan
@GregatGit
Jan 19 2017 05:40
@bensch5000 that how I did it too
Joseph
@revisualize
Jan 19 2017 05:40
@Marvive I can.
bensch5000
@bensch5000
Jan 19 2017 05:41
@GregatGit did you also use a String.prototype.replace method?

function pairElement(str) {
  var exp = /[G+?|C+?|A+?|T+?]/gi;
  var res = []; 

  str.replace(exp, function(a,b,c){
    switch (a) {
      case "G":
        res.push([a,"C"]);
        break;
      case "C":
        res.push([a,"G"]);
        break;
      case "A":
        res.push([a,"T"]);
        break;
      case "T":
        res.push([a,"A"]);
        break;
    }
  });  
  return res;
}

pairElement("ATTA");
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:41
@Marvive push item to array arr and return the first element in arr, you have to figure that out using 2 array methods
Joseph
@revisualize
Jan 19 2017 05:41
@Marvive Can I run down a laundry list of questions so that I know where your at?
jaghvi
@mehtajaghvi
Jan 19 2017 05:41
@Marvive you need to use shift and push
Joseph
@revisualize
Jan 19 2017 05:41
Or .. nevermind.
Flying_Fish
@FlyingFish195
Jan 19 2017 05:42
function rot13(str) { // LBH QVQ VG!
  var array;
  for(var i=0;i<str.length;i++){
    var UNicode=str.charCodeAt(i);
    var j;
    while(UNicode>=65&&UNicode<=90){

      if(UNicode>=78){
         j=String.fromCharCode(UNicode-13);
        array.push(j);
     }
      else{
        j=String.fromCharCode(UNicode-13+26);
        array.push(j);
     }
    }

  }
  var str2=array.join('');
  return str2;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Please!!what'wrong with the code??
the output is **Can not read property 'push'of undefined
Edgar Pan
@edgaryp
Jan 19 2017 05:42
@Lumexralph still confused. Here is my thought, but I am probably wrong. celebrityName("Michael"); executes the lastName function and assigned to a global variable mjName. Then lastName function took Jackson as parameter frommjName("Jackson"); while accesses outer function's variable and parameter, and return Michael Jackson.
function celebrityName(firstName) {
  var nameIntro = "This celebrity is ";
  function lastName(theLastName) {
    return nameIntro + firstName + " " + theLastName;
  }
  return lastName;
}
var mjName = celebrityName("Michael");

mjName("Jackson");
Greg Duncan
@GregatGit
Jan 19 2017 05:42
@bensch5000
  for (var i = 0; i < str.length; i++){
    switch(str[i]) {
    case "A":
        arr.push(["A","T"]);
        break;
Joseph
@revisualize
Jan 19 2017 05:43
@FlyingFish195 var array; ... array is still undefined.
@FlyingFish195 You need to make it an array before you can.... .push() it.
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:44
@edgaryp no, celebrityName("Michael") returned the function lastName that also takes a parameter theLastName
bensch5000
@bensch5000
Jan 19 2017 05:44
@GregatGit haha, didn’t even thought of “just” iterating through the string with a for loop. was too focused on regex from the previous challenges :D thanks for your input
CamperBot
@camperbot
Jan 19 2017 05:44
bensch5000 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 831 | @gregatgit |http://www.freecodecamp.com/gregatgit
Flying_Fish
@FlyingFish195
Jan 19 2017 05:45
What should I do @revisualize
to define array
Joseph
@revisualize
Jan 19 2017 05:45
@FlyingFish195 var array; to .... var array = [];
See what I did there
to make the variable an defined and initialized as an array?
tricky.
I know.
It's like magic powers or some shit.
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:46
@edgaryp this mjName("Jackson"); is what executes lastName function
Joseph
@revisualize
Jan 19 2017 05:46
Okay... Enough of me being snarky.
G R Maw
@Chekhovian
Jan 19 2017 05:47
bingo - finally got it. @Lumexralph @ericsolomon21 . My code was pretty close. It's the position of the braces I found confusing.
Michael Marvive
@Marvive
Jan 19 2017 05:48
I am so lost, I understand the concepts of push and shift, but don't I have to declare the array before I can use shift and push? Why does it want me to edit the code above the array?
Joseph
@revisualize
Jan 19 2017 05:48
@Marvive No.
@Marvive Allow me to explain.
Michael Marvive
@Marvive
Jan 19 2017 05:49
thank you!
Eric
@ericsolomon21
Jan 19 2017 05:50
@Chekhovian I JUST got it too. I just had to put the return "No such contact" outside the for loop bracket but still inside the function bracket.
Joseph
@revisualize
Jan 19 2017 05:50

@Marvive So you're supposed to:
Write a function nextInLine which has two parameters
an array (arr) and a number (item).
That part has been done for you here:

function nextInLine(arr, item) { }

Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.

tyson hauke
@tysisnice
Jan 19 2017 05:50
may the force be with you
Flying_Fish
@FlyingFish195
Jan 19 2017 05:51
it doesn't work!!!why the array can not be identified automaticly
@revisualize
tyson hauke
@tysisnice
Jan 19 2017 05:52
var buttCheeks  = ‘left buttcheek’ + ‘hole’ + ‘right buttcheek’;
“aslkjvnasv”
Joseph
@revisualize
Jan 19 2017 05:53
@FlyingFish195 Show me.
Michael Marvive
@Marvive
Jan 19 2017 05:53

Okay, thanks for that, but how about the next set of instructions?

"Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed."

Flying_Fish
@FlyingFish195
Jan 19 2017 05:54
function rot13(str) { // LBH QVQ VG!
  var array=[];
  for(var i=0;i<str.length;i++){
    var UNicode=str.charCodeAt(i);
    var j;
    while(UNicode>=65&&UNicode<=90){

      if(UNicode>=78){
         j=String.fromCharCode(UNicode-13);
        array.push(j);
     }
      else{
        j=String.fromCharCode(UNicode-13+26);
        array.push(j);
     }
    }

  }
  var str2=array.join('');
  return str2;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Joseph
@revisualize
Jan 19 2017 05:54
@Marvive It isn't just ONE thing.
@Marvive You have to do a few things.
@Marvive How do you add a number (item) to the end of an array (arr)?
G R Maw
@Chekhovian
Jan 19 2017 05:55
@ericsolomon21 Yeah, I found this one pretty difficult I must admit!
Edgar Pan
@edgaryp
Jan 19 2017 05:55
@Lumexralph so celebrityName ("Michael"); returns function lastName (theLastName) { return nameIntro + firstName + " " + theLastName; } with parameter and variable then assigned to mjName, then mjName ("Jackson"); executes the lastName function with parameter which is Jackson. I hope I am close.
Michael Marvive
@Marvive
Jan 19 2017 05:57
I know push is involved..
Joseph
@revisualize
Jan 19 2017 05:57
@Marvive Okay. Can you answer the question?
Ogundele Olumide
@Lumexralph
Jan 19 2017 05:57
@edgaryp yes, very close or should i say something like that
Edgar Pan
@edgaryp
Jan 19 2017 05:58
@Lumexralph very close but not right hahaha lol
Michael Marvive
@Marvive
Jan 19 2017 05:58
no. I've tried going back to the previous lessons, but I just don't understand what it's asking me to do. @revisualize
Joseph
@revisualize
Jan 19 2017 05:58
@Marvive That's what it is asking you to do.
How do you add a number (item) to the end of an array (arr)?
How do you remove the first element from an array (arr)?
What does that method return?
Greg Duncan
@GregatGit
Jan 19 2017 05:59
@FlyingFish195 you have an infinate loop that uses up all the memory
Ogundele Olumide
@Lumexralph
Jan 19 2017 06:01
@edgaryp you're right
Greg Duncan
@GregatGit
Jan 19 2017 06:01
@FlyingFish195 dont use a while loop in this
Cory Ramirez
@CoryARamirez
Jan 19 2017 06:01

Can any of you awesome code ninja's explain to me why this isn't removing my numbers from my string upon returning?? :

.replace(/[^A-Za-z0-9]/g, '');

Flying_Fish
@FlyingFish195
Jan 19 2017 06:01
??
Michael Marvive
@Marvive
Jan 19 2017 06:02
@revisualize I know that you use shift to remove the first element from an array. But wouldn't you write the shift and push after an array was declared?
Joseph
@revisualize
Jan 19 2017 06:02
@CoryARamirez Because you're telling it not to remove any numbers.
Ogundele Olumide
@Lumexralph
Jan 19 2017 06:02
@edgaryp the twist there's is you can access the inner function and because that inner function still remembers the scope it was declared, that's closure just like callbacks
Joseph
@revisualize
Jan 19 2017 06:02
@Marvive IT HAS BEEN DECLARED!

@Marvive So you're supposed to:
Write a function nextInLine which has two parameters
an array (arr) and a number (item).
That part has been done for you here:

function nextInLine(arr, item) { }

Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.

Cory Ramirez
@CoryARamirez
Jan 19 2017 06:03
@revisualize I am? I thought everything after the ^ declared what was to be removed?? Ugh, confusing RegEx lol.
Ogundele Olumide
@Lumexralph
Jan 19 2017 06:03
@CoryARamirez because you're telling it not to using [^]
Joseph
@revisualize
Jan 19 2017 06:04
@Marvive the array (arr) is declared in the function declaration.
Ogundele Olumide
@Lumexralph
Jan 19 2017 06:04
@CoryARamirez it means notnin the pattern
Michael Marvive
@Marvive
Jan 19 2017 06:06
okay.. I thought it was referring to the testArr. sorry
Joseph
@revisualize
Jan 19 2017 06:06
@Marvive No.
Cory Ramirez
@CoryARamirez
Jan 19 2017 06:06
@Lumexralph Hmm. So if I wanted everything to be removed aside from pure text characters.. I would use something like: .replace(/[A-Za-z0-9]/g, ''); ?
Ogundele Olumide
@Lumexralph
Jan 19 2017 06:08
what do you mean by pure text character?
@CoryARamirez
Cory Ramirez
@CoryARamirez
Jan 19 2017 06:09
@Lumexralph Let's say my function is passed an argument that contains special characters ($@#$) and numbers (1234) and pure text (asdf), I am trying to remove both the special characters and the digits, leaving only the raw text characters of the alphabet (asdf)
Pond
@phakasem
Jan 19 2017 06:16
Screenshot 2017-01-19 13.14.37.png

Hi, I need an explain. Why the map function does not execute?

I copy it from the question which is "val * 4"

then it return the same "oldArray"

Ogundele Olumide
@Lumexralph
Jan 19 2017 06:17
@CoryARamirez /[^A-Za-z]/g should do what you want then
@phakasem it worked just remove that last line in your code newArray = old Array
@phakasem make timesFour to newArray
@phakasem should it be val * 4 or val + 3?
CamperBot
@camperbot
Jan 19 2017 06:21
phakasem sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 771 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jan 19 2017 06:22
@phakasem :+1:
Pond
@phakasem
Jan 19 2017 06:22
@Lumexralph i got it. Thank you.
CamperBot
@camperbot
Jan 19 2017 06:22
phakasem sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:warning: phakasem already gave lumexralph points
John Nunns
@johnnunns
Jan 19 2017 06:24
function transformEmployeeData(array) {

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

    var a = {}; 
    for(var j = 0; j < array[i].length; j++) {

      a[array[i][j][0]] = array[i][j][1];
    }

    array[i] = a
  }

  return array;
}

transformEmployeeData(array)
Ok almost understand my function! now wondering can anyone give a really basic explanation of the need for array[i] = a
in order to return my data in the form of an object, without that little bit of code it doesn't complete the transformation. This problem is transforming an array into an object
kevinliu6102
@kevinliu6102
Jan 19 2017 06:27
@johnnunns you gave 'a' a key and value, so after that you're assigning placing that whole object 'a' into array at index i
it's not transforming the array into an object, its filling the array with objects that you created
Hanqi Liu
@LicheeLiu
Jan 19 2017 06:28

for(var i=0;i< contacts.length;i++)
{
if(contacts[i].firstNames!=firstName){
i++;
}
else{
if(prop=="lastName"){console.log(contacts[i].lastName);return;}
else if(prop=="number"){console.log(contacts[i].number);return;}
else if(prop=="likes"){console.log(contacts[i].likes);return;}
else {console.log("No such property");return;}
}}

if(i==contacts.length-1){
console.log("No such contact");
return;
}

what's wrong with this function?
the contact profile lookup onw
kevinliu6102
@kevinliu6102
Jan 19 2017 06:29
@LicheeLiu can you format it with ``` please
Hanqi Liu
@LicheeLiu
Jan 19 2017 06:29
sorry, what do you mean by '''? @kevinliu6102
CamperBot
@camperbot
Jan 19 2017 06:29
:bulb: to format code use backticks! ``` more info
kevinliu6102
@kevinliu6102
Jan 19 2017 06:30
click that ^
it's so we can read it easier
John Nunns
@johnnunns
Jan 19 2017 06:31
I kind of just thought a = {} just meaning it's an empty bracket that I'd fill with info. So by saying array[i] = a all i'm doing is surrounding whatever I set it equal to as the insides of {} @kevinliu6102
does that make sense?
but tbh I wouldn't see the need for that bit of code since I already showed a[i][j][0]
kevinliu6102
@kevinliu6102
Jan 19 2017 06:32
@johnnunns i think you might have it backwards in your head
John Nunns
@johnnunns
Jan 19 2017 06:33
Probably do :)
less than a month into coding so not quite grasping the little things as yet
kevinliu6102
@kevinliu6102
Jan 19 2017 06:33
a started as an empty object, by writing a[whatever value] = something, you now have a = {whatever value: something}
John Nunns
@johnnunns
Jan 19 2017 06:33
yeah got that
kevinliu6102
@kevinliu6102
Jan 19 2017 06:34
when you put it in the array, you can imagine it as array = [{whatever value: something}, {blah: blah}]
maybe i don't understand what you don't understand
paiztee
@paiztee
Jan 19 2017 06:34
@LicheeLiu are you trying to solve 'Profile Lookup' ?
kevinliu6102
@kevinliu6102
Jan 19 2017 06:34
i can't tell if you're confused or not
Hanqi Liu
@LicheeLiu
Jan 19 2017 06:34

'''
function lookUpProfile(firstName, prop){

for(var i=0;i< contacts.length;i++)
{
if(contacts[i].firstNames!=firstName){
i++;
}
else{
if(prop=="lastName"){console.log(contacts[i].lastName);return;}
else if(prop=="number"){console.log(contacts[i].number);return;}
else if(prop=="likes"){console.log(contacts[i].likes);return;}
else {consol