These are chat archives for FreeCodeCamp/HelpJavaScript

14th
Feb 2016
eliecerthoms
@eliecerthoms
Feb 14 2016 00:01
@dcnr how can i know about the methods that return something?
greg
@wearenotgroot
Feb 14 2016 00:02
@its-swats made your code work
@its-swats just say the word so i'll i can send you the version on pm
Shawn Watson
@its-swats
Feb 14 2016 00:04
The one I made works and passes all the tests, but I'd love to see another version of it. Thank you!
Norman Dela Cruz
@dcnr
Feb 14 2016 00:05
@eliecerthoms You could always check documents :D
@its-swats hi version of what?
greg
@wearenotgroot
Feb 14 2016 00:07
@its-swats check your pm :smile:
Norman Dela Cruz
@dcnr
Feb 14 2016 00:07
@its-swats oh Caesar's? You can check other people's solutions! http://www.freecodecamp.com/<username here> for example my link would be http://www.freecodecamp.com/dcnr
@its-swats or http://www.freecodecamp.com/wearenotgroot for @wearenotgroot
Mafalda
@otmeek
Feb 14 2016 00:08
I am on No repeats please and I'm getting an error Uncaught RangeError: Maximum call stack size exceeded
Norman Dela Cruz
@dcnr
Feb 14 2016 00:09
@wearenotgroot I checked your Caesar's, you could have used forEach instead :P
greg
@wearenotgroot
Feb 14 2016 00:09
@otmeek copy pasta them codes
Mafalda
@otmeek
Feb 14 2016 00:09
function permAlone(str) {

  function toggleLetters(arr, a, b) {
    var temporary = arr[a];
    a = b;
    b = temporary;
    return arr.join('');
  }

  function findPermutations(str, index, arr) {
    if(typeof str == "string") {
      str = str.split('');
    }
    if(typeof index == "undefined") {
      index = 0;
    }
    if(typeof arr == "undefined") {
      arr = [];
    }
    for(var i = index; i < str.length; i++) {
      arr.push(toggleLetters(str, index, i));
    }
    return findPermutations(str, index + 1, arr);
  }

  var a = findPermutations(str);
  console.log(a);

  return str;
}
greg
@wearenotgroot
Feb 14 2016 00:09
@dcnr like to be different :smile:
Mafalda
@otmeek
Feb 14 2016 00:09
I have a feeling something's bad about my recursive function
I'm pretty bad with recursive things
Norman Dela Cruz
@dcnr
Feb 14 2016 00:10
@otmeek you should properly define your base case, at a glance, I don't even know when your findPermutations will stop :P
Mafalda
@otmeek
Feb 14 2016 00:12
@dcnr right, I need to find out how to stop it lol
Cameron Bass
@cameronbass
Feb 14 2016 00:12
function reverseString(str) {
   str.Array.split.reverse.join();
  return str;
}

reverseString("hello");
What am I doing wrong?
greg
@wearenotgroot
Feb 14 2016 00:12
@cameronbass remove the Array
@cameronbass and .split() is a method
Norman Dela Cruz
@dcnr
Feb 14 2016 00:12
@otmeek yeah for example this stops when num <= 1
function factorialize(num, acc) {
  acc = acc || 1;

  return num <= 1 ? acc : factorialize(num - 1, acc * num);
}
@otmeek you should clearly define yours
Moisés Man
@moigithub
Feb 14 2016 00:13
missing parenthesis
no Array
Cameron Bass
@cameronbass
Feb 14 2016 00:13
Thank You! @wearenotgroot
CamperBot
@camperbot
Feb 14 2016 00:13
cameronbass sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
greg
@wearenotgroot
Feb 14 2016 00:13
@cameronbass so does .reverse()
CamperBot
@camperbot
Feb 14 2016 00:13
:star: 831 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 14 2016 00:14
@cameronbass remember method needs parenthesis
Mafalda
@otmeek
Feb 14 2016 00:15
@dcnr so I just need a condition that will make it stop
greg
@wearenotgroot
Feb 14 2016 00:15
@otmeek yes otherwise it will go on for ever :smile:
Mafalda
@otmeek
Feb 14 2016 00:16
@wearenotgroot for now, is there a way to make my code run at all step by step to debug without triggering the error?
Michael Mazzone
@GitMazzone
Feb 14 2016 00:17
@dcnr @preetamkajalrout Hey guys... still stuck on this problem. I restarted and I'm trying a new approach, but it's still not removing values. Any idea what I'm doing wrong now?
function destroyer(arr) {
  //Variable to hold elements meant to be removed from arr
  var toRemove = arguments.shift;

  //Should? filter through the array and return values that
  //aren't found to equal anything in the arr
  var destroyed = arguments[0].filter(function(val) {
    if(arr.indexOf(1, toRemove) <= 0) {
      return val;
    } 
  });

  return destroyed;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Moisés Man
@moigithub
Feb 14 2016 00:21
@GitMazzone check indexOf documentation... :)
wrong syntax
Zerka1982
@Zerka1982
Feb 14 2016 00:22
@moigithub I still can't fix the mobile version :/
greg
@wearenotgroot
Feb 14 2016 00:24
@otmeek if you had an ide you could do step by step to see the result
Moisés Man
@moigithub
Feb 14 2016 00:26
arguments is a special object who behave like an array.. but ITS NOT an array... so probably it dont have a shift method.. (also since its a method u need a set of parenthesis at the end )
so to make sure.. is better make a new copy
var toRemove = [].slice.call(arguments,1); //<--- copy the array but starting from index 1.. so its like u doin shift()
@GitMazzone
Zerka1982
@Zerka1982
Feb 14 2016 00:28
bon
Moisés Man
@moigithub
Feb 14 2016 00:29
u only returning val(which if positive can be evaluate as true) if it meet the condition.. but what if not ?
Norman Dela Cruz
@dcnr
Feb 14 2016 00:32
@wearenotgroot your .shift is missing the () too
also it's better to properly copy the array than slicing it https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/js-arguments#optimization-issues-with-arrayslice
@wearenotgroot wtf this mention autocomplete
@GitMazzone was meant for you
greg
@wearenotgroot
Feb 14 2016 00:33
@dcnr haha
Norman Dela Cruz
@dcnr
Feb 14 2016 00:34
@wearenotgroot lol man I'm so used to @+tab :( but I keep forgetting that the top one is usually the last poster
actually, seems like it's in the order of last posting!
barring self and duplicates
Mafalda
@otmeek
Feb 14 2016 00:35
is fcc down or did i break my browser with infinite loop
Shawn Watson
@its-swats
Feb 14 2016 00:35
@GitMazzone - yours is really close to what I ended up going with. your indexOf syntax needs to change a bit, I think. I can send you what i've got if you want to see something similar.
greg
@wearenotgroot
Feb 14 2016 00:36
@otmeek dont think you broke it
CamperBot
@camperbot
Feb 14 2016 00:36
wearenotgroot sends brownie points to @otmeek :sparkles: :thumbsup: :sparkles:
:star: 334 | @otmeek | http://www.freecodecamp.com/otmeek
Mafalda
@otmeek
Feb 14 2016 00:36
oh nvm
Norman Dela Cruz
@dcnr
Feb 14 2016 00:38
@otmeek did you come up with your own permutation function? I can't do that :( (or rather I didn't dedicate the time to learn the algo to make one :P)
Mafalda
@otmeek
Feb 14 2016 00:39
@dcnr I spent a ridiculous amount of time trying, but I ended up looking at several permutation functions written by other users in the end
I'm trying to switch letters around like these other functions do but mine aren't coming out that well ^^'
Priscila
@prilujan
Feb 14 2016 00:40
Hi, can someone help me in this lesson: Understanding Uninitialized Variables? Please, I'm stuck
Shawn Watson
@its-swats
Feb 14 2016 00:40
what are you stuck on?
Norman Dela Cruz
@dcnr
Feb 14 2016 00:41
@otmeek this worked great for me, even has pseudocode Heap's Algorithm
Mafalda
@otmeek
Feb 14 2016 00:43
@dcnr thanks for the link
CamperBot
@camperbot
Feb 14 2016 00:43
otmeek sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 622 | @dcnr | http://www.freecodecamp.com/dcnr
Mafalda
@otmeek
Feb 14 2016 00:44
I will try this without using recursion because it just made my browser crash moments ago lol
Norman Dela Cruz
@dcnr
Feb 14 2016 00:44
you're welcome, if you do use it though, just replace the output(A) pseudocode part with your sequence matching/counting code
Mafalda
@otmeek
Feb 14 2016 00:45
oh so that part stops the recursion
algorithms so confusing :(
Norman Dela Cruz
@dcnr
Feb 14 2016 00:46
yeah haha
@otmeek the method I used seems so inefficient though, I'd like to revisit this one sometime and redo it
Priscila
@prilujan
Feb 14 2016 00:53
// Initialize these three variables
var a; a = 5;
var b; b = 10;
var c; c = b + a;

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";
i don't understand how do to the var c
Shawn Watson
@its-swats
Feb 14 2016 00:56
so the lesson wants c to equal "I am a String!"
right now, c = c " " String!" would give you "15 String!"
so it looks like you need to make a change up in the "var c; c = b + a;" line
Jason Whisnant
@jwhisnant97
Feb 14 2016 00:57
I'm working on the Profile lookup project.
Is there someone who can look over this and tell me where I'm going wrong.
I've tried it 3 different ways and don't understand why it isn't working.
Shawn Watson
@its-swats
Feb 14 2016 00:58
sure, i'll take a look
Jason Whisnant
@jwhisnant97
Feb 14 2016 00:58
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUp(firstName, prop){
// Only change code below this line
  var errorMsg = '';

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

    if (contacts[i].firstName === firstName) { 

      if (contacts.hasOwnProperty(prop)){

        return contacts[i][prop];
    } else {
      errorMsg = 'No such property';
    }

   } else {
     errorMsg = 'No such contact';
   }

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

// Change these values to test your function
lookUp("Akira", "likes");
Moisés Man
@moigithub
Feb 14 2016 00:59
if (contacts.hasOwnProperty(prop)){
missing index
Jason Whisnant
@jwhisnant97
Feb 14 2016 01:00
OMG. I can't believe that I messed that up on this time of doing the code.
Priscila
@prilujan
Feb 14 2016 01:01
@its-swats c = c is undefined string
Jason Whisnant
@jwhisnant97
Feb 14 2016 01:01
Hmm... still not showing "No such property" on "lookUp("Akira", "address"), though.
Moisés Man
@moigithub
Feb 14 2016 01:01
it overriding ur message...
Norman Dela Cruz
@dcnr
Feb 14 2016 01:01
@prilujan
You can also define your variables in one!
var myVar =  "value";

/* instead of */
var myVar;
myVar = "value";
Mafalda
@otmeek
Feb 14 2016 01:02
uh oh i crashed my browser again with recursion :(
Norman Dela Cruz
@dcnr
Feb 14 2016 01:02
@otmeek use chrome so you only crash one tab :P
Shawn Watson
@its-swats
Feb 14 2016 01:03

@prilujan you need to change

var c; c = b + a;

somehow, so that

c = c + " String!";

will equal "I am a String!"

Mafalda
@otmeek
Feb 14 2016 01:03
@dcnr I am, but each time fcc remembers my code, and tries to execute it again, so I need to clear browsing data each time x_x
Moisés Man
@moigithub
Feb 14 2016 01:03
@jwhisnant97 u can move the "no such contact" message after for/loop ends,, (and use return) so it will act as fallback return if no contact found
and add a return for "no prop" msg
Norman Dela Cruz
@dcnr
Feb 14 2016 01:04
@otmeek oh loop protect doesn't work with recursion but you can use the disable auto run trick https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Loop-Protect
Moisés Man
@moigithub
Feb 14 2016 01:04
help autorun
CamperBot
@camperbot
Feb 14 2016 01:04
no wiki entry for: autorun
Mafalda
@otmeek
Feb 14 2016 01:05
@dcnr glad to know this exists, thanks!
CamperBot
@camperbot
Feb 14 2016 01:05
otmeek sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:warning: otmeek already gave dcnr points
Norman Dela Cruz
@dcnr
Feb 14 2016 01:05
Bill
@kirah1314
Feb 14 2016 01:05
help local
CamperBot
@camperbot
Feb 14 2016 01:05

:point_right: challenge global vs local scope in functions [wiki]

Challenge: Global vs Local Scope in Functions

It is possible to have both local and global variables with the same name. When you do this, the local variable takes precedence over the global variable.

In this example:

var someVar = "Hat";
function myFun() {
  var someVar = "Head";
  return someVar;
}

The function myFun will return "Head" because the local version of the variable is present.
:pencil: read more about challenge global vs local scope in functions on the FCC Wiki

Bill
@kirah1314
Feb 14 2016 01:05
help local storage
CamperBot
@camperbot
Feb 14 2016 01:05

:point_right: clear your browser's local storage [wiki]

Removing all your locally stored challenges will solve many problems related to the browser crashing on FreeCodeCamp

In Chrome:

  • On 'freecodecamp.com' open your console
    • Windows: Ctrl + Shift + J
    • Mac OS: Cmd + Opt + J
  • Go to resources tab(chrome).
    • There click on the localStorage link in the nav bar on the right.
  • Delete all the entries on the right side.
  • See if this solves your issue

Alternatively, if you are having issues with a specific challenge freezing your browser, find the name of that challenge in local storage and delete just that one.
:pencil: read more about clear your browsers local storage on the FCC Wiki

Jason Whisnant
@jwhisnant97
Feb 14 2016 01:07
Thank you so much @moigithub .
CamperBot
@camperbot
Feb 14 2016 01:07
jwhisnant97 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 576 | @moigithub | http://www.freecodecamp.com/moigithub
Priscila
@prilujan
Feb 14 2016 01:08
var c; c = "I am a";
that way worked
Jason Whisnant
@jwhisnant97
Feb 14 2016 01:08

Finished it out with this.
```
else {
errorMsg1 = 'No such property';
}

}

}
if (errorMsg1 !== '') {

return errorMsg1;

} else {
return "No such contact";
}

 else {
      errorMsg1 = 'No such property';
    }

   } 

  }
  if (errorMsg1 !== '') {

    return errorMsg1;
  } else {
    return "No such contact";
  }
Shawn Watson
@its-swats
Feb 14 2016 01:09
@prilujian - yep! you can also just use
var c = "I am a"
Jason Whisnant
@jwhisnant97
Feb 14 2016 01:09
Messed up format first time.
Nicol
@NicolNonga
Feb 14 2016 01:09
try var c="iam a"
Priscila
@prilujan
Feb 14 2016 01:09
@its-swats thanks!!
CamperBot
@camperbot
Feb 14 2016 01:09
prilujan sends brownie points to @its-swats :sparkles: :thumbsup: :sparkles:
:star: 172 | @its-swats | http://www.freecodecamp.com/its-swats
Priscila
@prilujan
Feb 14 2016 01:10
@dcnr and thanks you too for the information!!
CamperBot
@camperbot
Feb 14 2016 01:10
prilujan sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 623 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 14 2016 01:16
good luck! you're welcome and thanks too @prilujan
CamperBot
@camperbot
Feb 14 2016 01:16
dcnr sends brownie points to @prilujan :sparkles: :thumbsup: :sparkles:
:star: 146 | @prilujan | http://www.freecodecamp.com/prilujan
sean9
@sean9
Feb 14 2016 01:22
how do i post fancy code in here again?
and what else
it was ``` and what other symbol
Norman Dela Cruz
@dcnr
Feb 14 2016 01:24
@sean9 you do ```js <shift+enter to newline> <paste code> <shift+enter again> ```
@sean9 you can change the js part to html or css depending on code you post
I don't know what it defaults to if you don't specify it
sean9
@sean9
Feb 14 2016 01:24
@dcnr thanks
CamperBot
@camperbot
Feb 14 2016 01:25
sean9 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 624 | @dcnr | http://www.freecodecamp.com/dcnr
sean9
@sean9
Feb 14 2016 01:25
im working on the calculator right now and im just beginning, does this look right?
```js
function one() {
if (sign == "x" || sign == "+" || sign == "-" || sign == "/") {
secondNum += "1";
} else {
firstNum += "1";
}
}
function one() {
   if (sign == "x" || sign == "+" || sign == "-" || sign == "/") {
      secondNum += "1";
   } else {
      firstNum += "1";
   }
}
Norman Dela Cruz
@dcnr
Feb 14 2016 01:26
@sean9 you can also try the main chat or the frontend rooms
sean9
@sean9
Feb 14 2016 01:26
front end is always dead
ill try main help
E
@efhjones
Feb 14 2016 01:31
Hey guys, can anyone tell me why I'm getting the message newArray.reduce is not a function?
function factorialize(num) {


  //return numFactors;
 var factorial = 1;
  var newArray = [];

  for (i = 0; i <= num; i++){
    newArray.push([1*i]);

  } return newArray;
}
function multiplyArray (previousValue, currentValue) {
    return previousValue * currentValue;
    }

var result = newArray.reduce(multiplyArray);
Ekin Tiras
@IroNEDR
Feb 14 2016 01:32
hello i am currently a the caesars cipher. but somehow it returns the exact same text that has been put in without any changes
rybka02
@rybka02
Feb 14 2016 01:32
Anyone here?
Shawn Watson
@its-swats
Feb 14 2016 01:33
@efhjones - it looks like the scope is wrong. var result is in global, but newArray does not exist in the global scope.
rybka02
@rybka02
Feb 14 2016 01:34
That's not how reduce works
Ekin Tiras
@IroNEDR
Feb 14 2016 01:34
hello i am currently a the caesars cipher. but somehow it returns the exact same text that has been put in without any changes
function rot13(str) { // LBH QVQ VG!
  for(var i=0;i<str.length;i++){
    code=str.charCodeAt(i);
    if(code>64&&code<90){
      code+=13;
      if(code>90){
        var mod= code%90;
        code=64+mod;
      }   
    }
    str[i]=String.fromCharCode(code);

  }
  return str;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
E
@efhjones
Feb 14 2016 01:34
yeah I guess I'm having trouble with reduce
rybka02
@rybka02
Feb 14 2016 01:34
why do you have code%90
Shawn Watson
@its-swats
Feb 14 2016 01:35
it looks like you're trying to modify a String directly, in place, but strings are immutable.
rybka02
@rybka02
Feb 14 2016 01:36
@efhjones You shouldn't need reduce
Ekin Tiras
@IroNEDR
Feb 14 2016 01:37
the code%90 part helps me to turn back around to the beginning of the alphabet
rybka02
@rybka02
Feb 14 2016 01:37
modulas 90?
Ekin Tiras
@IroNEDR
Feb 14 2016 01:37
90 is Z in unicode
E
@efhjones
Feb 14 2016 01:37
Oh, I thought it would work for what I'm trying to do... 'The array method reduce is used to iterate through an array and condense it into one value.'
rybka02
@rybka02
Feb 14 2016 01:38
% = modulas
Ekin Tiras
@IroNEDR
Feb 14 2016 01:38
if i have 91, it returns 1 so i can add the 1 up to 64, and i have 65 which is an A
E
@efhjones
Feb 14 2016 01:39

Because in this example:

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

// Only change code below this line.

singleVal = array.reduce(function(previousVal, currentVal){

  return previousVal + currentVal;

}, 0);

It's adding the array up and returning one value, which is what I want to do except rather than add I want to multiply...

Shawn Watson
@its-swats
Feb 14 2016 01:39
it looks like str[i]=String.fromCharCode(code); is trying to modify an index of a string, but you can't do that
rybka02
@rybka02
Feb 14 2016 01:41
ok check this iron... if code=89 you're saying to add 13 which is 102
Y-->f
bitgrower
@bitgrower
Feb 14 2016 01:42
@efhjones -- what results are you getting ?
Ekin Tiras
@IroNEDR
Feb 14 2016 01:42
@its-swats thank you
CamperBot
@camperbot
Feb 14 2016 01:42
ironedr sends brownie points to @its-swats :sparkles: :thumbsup: :sparkles:
:star: 173 | @its-swats | http://www.freecodecamp.com/its-swats
E
@efhjones
Feb 14 2016 01:43
@bitgrower I'm getting newArray.reduce is not a function
rybka02
@rybka02
Feb 14 2016 01:43
@efhjones Are you set on using reduce?
bitgrower
@bitgrower
Feb 14 2016 01:43
ahh ... look at the syntax coloring ... array is a reserved word ...
E
@efhjones
Feb 14 2016 01:43
Well not set on it, it just sounded like exactly what I wanted to do..
a reserved word?
bitgrower
@bitgrower
Feb 14 2016 01:44
change the name of your arr variable ...
yeah, words like return, var, function, etc ...
just change the name of the variable and you should stop getting the error ...
red == reserved word
why it doesn't complain when you set the global variable is undoubtedly some weird idiosyncrasy of js
rybka02
@rybka02
Feb 14 2016 01:45
@efhjones You're missing your anonymous function
if you're going to use reduce,.. you need to use a callback function
Ekin Tiras
@IroNEDR
Feb 14 2016 01:45
@rybka02 in that case i would do 102%90 which is 12, i later add 64+12 and i am at 76, which is an L and exactly what i need
bitgrower
@bitgrower
Feb 14 2016 01:46
@rybka02 -- what am I missing? I see her calling one...
rybka02
@rybka02
Feb 14 2016 01:46
 if(code>64&&code<90){
      code+=13;
      if(code>90){
        var mod= code%90;
        code=64+mod;
      }   
    }
ok i see what youre saying
bitgrower
@bitgrower
Feb 14 2016 01:48
okay, my bad -- just took @efhjones code into repl.it and it works ... weird!!!
(for adding, but not for multiplying ...
rybka02
@rybka02
Feb 14 2016 01:49
var result = newArray.reduce(function(multiplyArray));
Kelsey
@kcdilla
Feb 14 2016 01:49
Hello! Trying to figure out where I'm going wrong with the Profile Lookup challenge. Here's what I have:
rybka02
@rybka02
Feb 14 2016 01:49
try that
Kelsey
@kcdilla
Feb 14 2016 01:49
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
bitgrower
@bitgrower
Feb 14 2016 01:50
@efhjones -- you need to change your intial value ...

you are setting the initial value to 0 ...

as for why you are getting the error ... can you post the exact code you are getting an error on ?

rybka02
@rybka02
Feb 14 2016 01:52
@kcdilla I think your < should be going teh other way
uriznik
@uriznik
Feb 14 2016 01:52
@kcdilla check the return contacts[i].prop; line
rybka02
@rybka02
Feb 14 2016 01:53
nvm
Kelsey
@kcdilla
Feb 14 2016 01:53
@rybka02 Why? that would create an infinite loop, wouldn't it?
rybka02
@rybka02
Feb 14 2016 01:53
i probably should get some sleep
bitgrower
@bitgrower
Feb 14 2016 01:54
LOL .. I know the feeling ..
you can always delete the embarrassing messages :)
Bill
@kirah1314
Feb 14 2016 01:54
@kcdilla contacts is an array of objects so your 2nd loop isn't necessary. Actually it'll probably cause errors
Norman Dela Cruz
@dcnr
Feb 14 2016 01:55
@efhjones hi can you post your updated code now?
bitgrower
@bitgrower
Feb 14 2016 01:55
yeah ... it would be nice to access elements of an object like you can an array ...
Norman Dela Cruz
@dcnr
Feb 14 2016 01:55
oh hello @bitgrower !
bitgrower
@bitgrower
Feb 14 2016 01:56
hi there @dcnr !!!!
Ramón Emilio Ledezma Vargas
@Mercality
Feb 14 2016 01:56
Hi guys
I could use some help with a regexp somebody?
uriznik
@uriznik
Feb 14 2016 01:57
hi @Mercality
Kelsey
@kcdilla
Feb 14 2016 01:57
@kirah1314 ok - then how do i iterate through the array that contains that firstName?
bitgrower
@bitgrower
Feb 14 2016 01:57
ran thru a nice little set of "weird stuff" js videos ... https://www.youtube.com/watch?v=JEq7Ehw-qk8&list=PLoYCgNOIyGABI011EYc-avPOsk1YsMUe_
Ramón Emilio Ledezma Vargas
@Mercality
Feb 14 2016 01:58
This is the regexp, im doing the us telephones challenge
bitgrower
@bitgrower
Feb 14 2016 01:58
well dang .. is there some way of not showing the page preview ...
Ramón Emilio Ledezma Vargas
@Mercality
Feb 14 2016 01:58
Have been hours and can't figure how to solve that last case
uriznik
@uriznik
Feb 14 2016 01:58
@kcdilla remember the .hasOwnProperty(prop) from one of the earlier challenges?
Ramón Emilio Ledezma Vargas
@Mercality
Feb 14 2016 01:59
Because javascript does not support look behind as i know.
uriznik
@uriznik
Feb 14 2016 01:59
@kcdilla that's what I used anyway
bitgrower
@bitgrower
Feb 14 2016 01:59
@Mercality -- ultimately, the point is to get something to work ... it is NOT a requirement of the challenge that it be done in 1 reg expression
Kelsey
@kcdilla
Feb 14 2016 01:59
@uriznik oohh ok
Bill
@kirah1314
Feb 14 2016 01:59
@kcdilla your first loop did that with contacts[i].firstName
bitgrower
@bitgrower
Feb 14 2016 01:59
in fact, it's my personal opinion that if you make them too complex, they become difficult to debug & hard to understand
E
@efhjones
Feb 14 2016 01:59
@bitgrower This is what I've got so far, it's hard to keep track every time I change something :laughing:
function factorialize(num) {


  //return numFactors;
 var factorial = 1;
  var factorialArr = [];

  for (i = 0; i <= num; i++){
    factorialArr.push([1*i]);

  } return factorialArr;
}
function multiplyArray (previousValue, currentValue) {
    return previousValue * currentValue;
    }

var result = factorialArr.reduce(function(multiplyArray));



factorialize(5);
bitgrower @bitgrower and @bitgrower LOVES regexes
Ramón Emilio Ledezma Vargas
@Mercality
Feb 14 2016 02:00
Well, i think i like to push myself as hard as i can hehe xD
But i admit that i'm lost here.
Bill
@kirah1314
Feb 14 2016 02:00
@kcdilla contacts[0].firstName = "Akira" while contacts[2].firstName = "Sherlock"
bitgrower
@bitgrower
Feb 14 2016 02:00
yeah ... that's why I think they should teach version control early on ... :)
Norman Dela Cruz
@dcnr
Feb 14 2016 02:02
@Mercality I'm sorry I'm having a really hard time reading your expression, the one pattern answer is much simpler than yours :(
bitgrower
@bitgrower
Feb 14 2016 02:02
@efhjones -- I get an unexpected token )
not sure whether FCC editor has bracket/paren matching ... but it can be a lifesaver -- there are text editors which will do that for you (though some get confused if you use them in comments ... )
uriznik
@uriznik
Feb 14 2016 02:04
@efhjones if you want to get all functional just use recursion :)
bitgrower
@bitgrower
Feb 14 2016 02:04
LOL .. one step at a time, @uriznik ...
E
@efhjones
Feb 14 2016 02:04
Yeah, I haven't quite finished that last part, can't figure out how to make it work yet...
Norman Dela Cruz
@dcnr
Feb 14 2016 02:05
@efhjones
  1. factorialArr is out of scope
  2. you pass callback functions by their name .reduce(multiplyArray) not function(multiplyArray)
@efhjones and it's never good to make global vars in the fcc editor, it messes up the other test cases
torilov123
@torilov123
Feb 14 2016 02:06
Hey guys, Im having problem with Nesting for loops exercise... keep getting result of 1; couldn't figure out how to work it
any suggestions?
Bill
@kirah1314
Feb 14 2016 02:06
@torilov123 post your codes?
bitgrower
@bitgrower
Feb 14 2016 02:06
yeah ... I was able to get your code to work, @efhjones -- the first code you posted with the addition -- by just changing 2 things ... removed the 0 initial value, and changed the + to *
E
@efhjones
Feb 14 2016 02:06
haha @uriznik well that looks perfect, but I do want to figure out how to make this version work
torilov123
@torilov123
Feb 14 2016 02:07
for (var x = 0; x < arr.length; x++){
for(var y = 0; y <arr[x].length; y++){
product = product * y;
}
}
Bill
@kirah1314
Feb 14 2016 02:08
@torilov123 can you copy and paste the example on the left section?
bitgrower
@bitgrower
Feb 14 2016 02:08
@efhjones -- go take your original code that used addition and make the changes I suggested -- with that one, you are very close to a solution ...
Norman Dela Cruz
@dcnr
Feb 14 2016 02:08
@efhjones
I rearranged your code, you just having scope issues
function factorialize(num) {
  //return numFactors;
  var factorial = 1;
  var factorialArr = [];

  for (i = 1; i <= num; i++) {
    factorialArr.push(1 * i);
  }

  return factorialArr.reduce(multiplyArray);
}

function multiplyArray(previousValue, currentValue) {
  return previousValue * currentValue;
}

factorialize(5)
bitgrower
@bitgrower
Feb 14 2016 02:08
in fact, you'll have a solution ...
torilov123
@torilov123
Feb 14 2016 02:08
@kirah1314 here it is: var arr = [
[1,2], [3,4], [5,6]
];
for (var i=0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++) {
console.log(arr[i][j]);
}
}
bitgrower
@bitgrower
Feb 14 2016 02:08
@dcnr -- go check out her earlier example ... it was MUCH cleaner ...
Norman Dela Cruz
@dcnr
Feb 14 2016 02:08
@efhjones also .push([1 * i]) will give you a 2d array
@bitgrower timestamp?
bitgrower
@bitgrower
Feb 14 2016 02:09
hang on ...
Bill
@kirah1314
Feb 14 2016 02:09
@torilov123 so you see the example uses the i and j variables (console.log(arr[i][j]);) while yours only used y?
bitgrower
@bitgrower
Feb 14 2016 02:09
Damien Wright
@DamienIsOK
Feb 14 2016 02:10

Hello there. I have a question regarding the challenge "Profile Lookup". Does anyone have insight as to why one must do a nested if statement for line 2 instead of using &&? Meaning, why would this work:

for (var i = 0; i < contacts.length; i++){
    if (contacts[i].firstName === firstName) {
        if (contacts[i][prop]) {
            return contacts[i][prop];
        } else {
            return "No such property";

But this NOT work:

if (contacts[i].firstName === firstName && contacts[i][prop]) {
    return contacts[i][prop];
bitgrower
@bitgrower
Feb 14 2016 02:10
well ... it was example code -- but for some reason she was getting an interpreter error ... for reasons I couldn't figure out ...
Norman Dela Cruz
@dcnr
Feb 14 2016 02:10
@bitgrower oh that was the example for the reduce, but I just rearranged this code :point_up: February 14, 2016 9:59 AM @efhjones almost had the answer he was just having scoping issues and a bad push
Kelsey
@kcdilla
Feb 14 2016 02:11
I'm getting closer! 2 of the 5 check marks....
bitgrower
@bitgrower
Feb 14 2016 02:11
yeah, I think she built on it based on some other folks' comments in here ...
Kelsey
@kcdilla
Feb 14 2016 02:11
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUp(firstName, prop){
// Only change code below this line
  for (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";
      }
    } else {
      return "No such contact";
    }
  }

// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
bitgrower
@bitgrower
Feb 14 2016 02:11
the solution you cleaned up ...
rybka02
@rybka02
Feb 14 2016 02:11
I found your error kcdilla
torilov123
@torilov123
Feb 14 2016 02:12
@kirah1314 even if i used i and j it still doesn't work. any suggestions?
bitgrower
@bitgrower
Feb 14 2016 02:12
and I think @efhjones was on the right track -- by using that first example ... I'd like to see her pursue it ...
rybka02
@rybka02
Feb 14 2016 02:12
for (j = 0; j < contacts[i].length; j++) returns undefined. so it quits loop
uriznik
@uriznik
Feb 14 2016 02:12
@kcdilla obj.prop looks for a field named 'prop'
bitgrower
@bitgrower
Feb 14 2016 02:12
where does it return undefined, @rybka02 ?
Bill
@kirah1314
Feb 14 2016 02:12
@torilov123 yes, you don't want to multiply by y, you want to multiply by the values of the sub-arrays
Kelsey
@kcdilla
Feb 14 2016 02:13
@rybka02 why does it do that?
do i need to use bracket notation, @uriznik ?
uriznik
@uriznik
Feb 14 2016 02:13
@kcdilla yes
Norman Dela Cruz
@dcnr
Feb 14 2016 02:13
@DamienIsOK what error were you having? and can you post the rest?
torilov123
@torilov123
Feb 14 2016 02:13
@kirah1314 My revised code, still doesn't seem to work:
for (var i = 0; i < arr.length; i++){
for(var j = 0; j <arr[i].length; j++){
product = product * j;
}
}
Bill
@kirah1314
Feb 14 2016 02:13
@torilov123 the example here console.log(arr[i][j]); is accessing the values of arr[i][j] sub-arrays
Kelsey
@kcdilla
Feb 14 2016 02:14
@uriznik Ok, I did that and it's still not working
rybka02
@rybka02
Feb 14 2016 02:14
contacts[i].length returns undefined
bitgrower
@bitgrower
Feb 14 2016 02:14
@torilov123 -- EVERYTHING is addressing ... so, you need to know how to address each element of the sub-arrays ...
@rybka02 -- in your example you are not using contacts[i].length ... did you change it ?
uriznik
@uriznik
Feb 14 2016 02:15
@kcdilla you're probably returning "No such contact" too early, lift it out of the loop
@kcdilla like if the first contact doesn't match firstName then it's just giving up :)
torilov123
@torilov123
Feb 14 2016 02:16
@bitgrower do i need to define the array if it's in the function, like function multiplyAll(arr){ }. can my for loop reference to arr directly?
rybka02
@rybka02
Feb 14 2016 02:16
im checking kcdilla's code.. it has an undefined line
Kelsey
@kcdilla
Feb 14 2016 02:16
@uriznik Oh I think that makes sense
rybka02
@rybka02
Feb 14 2016 02:16
nvm.,, she changed it all on me
i was checking her old code
Kelsey
@kcdilla
Feb 14 2016 02:16
I'll re-post what I have
Bill
@kirah1314
Feb 14 2016 02:17
@torilov123 j is only a loop variable which goes from 0 and increments by j++ each loop, you want to access the array and sub-array values, so you have to target those
Kelsey
@kcdilla
Feb 14 2016 02:17
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUp(firstName, prop){
// Only change code below this line
  for (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";
      }
    } else {
      return "No such contact";
    }
  }

// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
bitgrower
@bitgrower
Feb 14 2016 02:17
@torilov123 -- yes you can reference arr directly ...
what happens when you run that code @kcdilla ?
E
@efhjones
Feb 14 2016 02:18
Ah ok, @bitgrower @dcnr I wasn't registering that you declare a function outside of that for loop but then access it within the loop... Ahhhh. All working now, thank you guys!!
CamperBot
@camperbot
Feb 14 2016 02:18
efhjones sends brownie points to @bitgrower and @dcnr :sparkles: :thumbsup: :sparkles:
:star: 511 | @bitgrower | http://www.freecodecamp.com/bitgrower
:star: 625 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 14 2016 02:18
@kcdilla you're returning No such contact too early, if your contact comes much later in the contacts array, it will just return no contact
Bill
@kirah1314
Feb 14 2016 02:18
@kcdilla just need to move return "No such contact"; outside of the loop because you wouldn't know if there's no contact until the loop ends right?
Kelsey
@kcdilla
Feb 14 2016 02:18
@uriznik @kirah1314 That makes sense - but then where do i put it?
torilov123
@torilov123
Feb 14 2016 02:18
sorry, my whole code is like this. I thought i was already referencing the array and sub array to do the multiple of the numbers.

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 = product * j;
}
}

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

// Modify values below to test your code

multiplyAll([[1,2],[3,4],[5,6,7]]);

bitgrower
@bitgrower
Feb 14 2016 02:18
@dcnr @kcdilla has a loop definition problem ...
Bill
@kirah1314
Feb 14 2016 02:19
@kcdilla outside of your for loop
bitgrower
@bitgrower
Feb 14 2016 02:19
@torilov123 -- what does j represent ... ?
Bill
@kirah1314
Feb 14 2016 02:19

@torilov123

@torilov123 j is only a loop variable which goes from 0 and increments by j++ each loop, you want to access the array and sub-array values, so you have to target those

bitgrower
@bitgrower
Feb 14 2016 02:19
you are multiplying by j -- but what is it, and what are the requirements of the problem definition ?
rybka02
@rybka02
Feb 14 2016 02:19
kc which test are you failing?
Bill
@kirah1314
Feb 14 2016 02:20
@kcdilla check to see which } bracket closes your loop
uriznik
@uriznik
Feb 14 2016 02:20
@kcdilla for that code either you have already returned in either of the prop tests or you reach the end of the function because no firstName matched so then just have the return as the last statement
torilov123
@torilov123
Feb 14 2016 02:20
o ok. i think i might've got it. thanks @kirah1314 @bitgrower
CamperBot
@camperbot
Feb 14 2016 02:20
torilov123 sends brownie points to @kirah1314 and @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 959 | @kirah1314 | http://www.freecodecamp.com/kirah1314
:star: 512 | @bitgrower | http://www.freecodecamp.com/bitgrower
rybka02
@rybka02
Feb 14 2016 02:21
She has two else statements with return... so it will nvr reach the 2nd else
Bill
@kirah1314
Feb 14 2016 02:21
@torilov123 that's great! :thumbsup:
E
@efhjones
Feb 14 2016 02:21
How do you do that timestamp link?
Norman Dela Cruz
@dcnr
Feb 14 2016 02:22
@efhjones hover over the timestamp and alt+click
E
@efhjones
Feb 14 2016 02:22
Oh cool thanks!
Bill
@kirah1314
Feb 14 2016 02:22
@rybka02 I think the 2nd else is related to the first if
rybka02
@rybka02
Feb 14 2016 02:22
yeah but the return exits function
Does the exercise want both strings to return if both the prop and value is missing?
or does it just want one or the other?
Damien Wright
@DamienIsOK
Feb 14 2016 02:24
@dcnr I combined my two if conditionals into one instead of nested if statements. My code is:
Bill
@kirah1314
Feb 14 2016 02:25
@rybka02 ok but the challenge requires the returns so yes I agree return exits function but only if it reaches the return
Damien Wright
@DamienIsOK
Feb 14 2016 02:25
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];

function lookUp(firstName, prop) {
// Only change code below this line

  for (var i=0; i < contacts.length; i++) {
    if (contacts[i].firstName === firstName && contacts[i][prop]) {
    return contacts[i][prop];
    } else {
      return "No such property";
    }
  }
  return "No such contact";

// Only change code above this line
}

// Change these values to test your function
lookUp("Kristian", "lastName");
rybka02
@rybka02
Feb 14 2016 02:25
does it want both strings to be returned or just one?
Bill
@kirah1314
Feb 14 2016 02:26
@rybka02 1 or the other, they're both different conditions
Damien Wright
@DamienIsOK
Feb 14 2016 02:26
@dcnr the error says that "Kristian", "lastName" should return "Vos"
"Sherlock", "likes" should return ["Intriguing Cases", "Violin"]
"Harry","likes" should return an array
"Bob", "number" should return "No such contact"
bitgrower
@bitgrower
Feb 14 2016 02:26
so it's returning the properties & not the values @DamienIsOK
rybka02
@rybka02
Feb 14 2016 02:27
The code works for me
Which one is it failing for her?
Bill
@kirah1314
Feb 14 2016 02:28
uriznik
@uriznik
Feb 14 2016 02:29
@DamienIsOK that looks like it would return No such property in the first time where the firstName doesn't match
Kelsey
@kcdilla
Feb 14 2016 02:29
@rybka02 could you @ who you're replying to? there's just a lot of people in the chat and I get lost when i go back to work on my code
Bill
@kirah1314
Feb 14 2016 02:29
@kcdilla were you able to resolve it?
lpix
@lpix
Feb 14 2016 02:30
@DamienIsOK for this problem it's best you use .hasOwnProperty
Damien Wright
@DamienIsOK
Feb 14 2016 02:31
@uriznik yep, that's what it's doing. however, if i replace the 'if statement' with this, then it works fine. i just can't figure out why this one works, but the other doesnt:
'''
for (var i = 0; i < contacts.length; i++){
if (contacts[i].firstName === firstName) {
if (contacts[i][prop]) {
return contacts[i][prop];
} else {
return "No such property";
}
}
}
return "No such contact";
'''
CamperBot
@camperbot
Feb 14 2016 02:31
:bulb: to format code use backticks! ``` more info
rybka02
@rybka02
Feb 14 2016 02:31
@kirah1314 Your code works for me--- which test are you failing?
Kelsey
@kcdilla
Feb 14 2016 02:31
@kirah1314 No I haven't yet... i think i might need to come back to it
Bill
@kirah1314
Feb 14 2016 02:31
@rybka02 oh haha but I didn't paste any codes
Kelsey
@kcdilla
Feb 14 2016 02:31
@kirah1314 this seems so simple yet so hopeless... i'm probably overthinking
Bill
@kirah1314
Feb 14 2016 02:32
@kcdilla yeah, you just have to find out where your for loop codes close with the } bracket
bitgrower
@bitgrower
Feb 14 2016 02:32
@kcdilla -- not uncommon to overthink stuff if you don't completely understand the problem and/or the language ...
Norman Dela Cruz
@dcnr
Feb 14 2016 02:32
@DamienIsOK @uriznik :point_up: February 14, 2016 10:29 AM is right
Bill
@kirah1314
Feb 14 2016 02:32
@kcdilla and move the return right after it
rybka02
@rybka02
Feb 14 2016 02:33
@kcdilla Which test is it failing?
i meant to say kc not kira
uriznik
@uriznik
Feb 14 2016 02:34
@DamienIsOK in one case you have both branches returning so it never loops through, and the working one loops through until it matches the firstname, and then checks the prop and returns
Damien Wright
@DamienIsOK
Feb 14 2016 02:36
@uriznik Ahhhh, I see it now! That makes sense. Thank you @uriznik and @dcnr
CamperBot
@camperbot
Feb 14 2016 02:36
damienisok sends brownie points to @uriznik and @uriznik and @dcnr :sparkles: :thumbsup: :sparkles:
:star: 626 | @dcnr | http://www.freecodecamp.com/dcnr
:star: 276 | @uriznik | http://www.freecodecamp.com/uriznik
:star: 276 | @uriznik | http://www.freecodecamp.com/uriznik
Norman Dela Cruz
@dcnr
Feb 14 2016 02:36
thanks @uriznik
CamperBot
@camperbot
Feb 14 2016 02:36
dcnr sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles:
:star: 277 | @uriznik | http://www.freecodecamp.com/uriznik
rybka02
@rybka02
Feb 14 2016 02:38
@kcdilla Which test are you failing? Your code works for me.
Kelsey
@kcdilla
Feb 14 2016 02:44
@rybka02 Failing the 1st 3
uriznik
@uriznik
Feb 14 2016 02:45
@kcdilla have you moved the no such contact return out of the loop?
Kelsey
@kcdilla
Feb 14 2016 02:45
@rybka02 ah now it switched! Let me repost...
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
oh hey
i made a couple changes and it works!
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUp(firstName, prop){
// Only change code below this line
  for (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
}

// Change these values to test your function
lookUp("Akira", "likes");
thanks @kirah1314 @rybka02 @uriznik
CamperBot
@camperbot
Feb 14 2016 02:48
kcdilla sends brownie points to @kirah1314 and @rybka02 and @uriznik :sparkles: :thumbsup: :sparkles:
:star: 960 | @kirah1314 | http://www.freecodecamp.com/kirah1314
:star: 335 | @rybka02 | http://www.freecodecamp.com/rybka02
:star: 278 | @uriznik | http://www.freecodecamp.com/uriznik
Bill
@kirah1314
Feb 14 2016 02:49
@kcdilla see you got this :thumbsup:
casadaro
@Casadaro
Feb 14 2016 02:59
can someone give me someone give me some help wit hte record collection problem?
uriznik
@uriznik
Feb 14 2016 02:59
hi @Casadaro , sure fire away
greg
@wearenotgroot
Feb 14 2016 03:00
wait let me duck :smile:
casadaro
@Casadaro
Feb 14 2016 03:00
@uriznik here is the problem that I am supposed to solve

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

For the given id in collection:

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

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

If value is blank, delete that prop.

Always return the entire collection object.

Note
Don't forget to use bracket notation when accessing object properties with variables.

greg
@wearenotgroot
Feb 14 2016 03:01
@Casadaro there ya go those are your clues!
@Casadaro what mechanism can you use to test if conditions are true or false
casadaro
@Casadaro
Feb 14 2016 03:02
My first instinct was to write a for loop. so I did, then I filled it with nested if statements. the program runs but doest meet any of the specified criteria. I figured since I handent covered loops let, maybe I was supoosed to use just if statments. still dint work, I dont know whhere to state
greg
@wearenotgroot
Feb 14 2016 03:03
@Casadaro do you really need a for loop
casadaro
@Casadaro
Feb 14 2016 03:03
@wearenotgroot wew can use if statements to test whether stuff is true or false
greg
@wearenotgroot
Feb 14 2016 03:03
@Casadaro check out the structure of the object you are trying to access vs the function parameters you are given
@Casadaro yes if statesment for sure
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 14 2016 03:04
@wearenotgroot thanks for the tip on .hasOwnProperty('query')
CamperBot
@camperbot
Feb 14 2016 03:04
pkshreeman sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 837 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 14 2016 03:04
@pkshreeman YW

@Casadaro look closely, here is the object you are trying to access and operate on. now you are given id, prop, and value as function parameter

var collection = {
    2548: {                                            //<---------------------------id
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {                                            //<---------------------------id
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {                                      //<---------------------------id
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {                                         //<---------------------------id
      album: "ABBA Gold"
    }
};

then you are given prop in which you can access the inner object

Chase Childers
@d00mb0x
Feb 14 2016 03:09

Good evening everyone, just a quick question. I'm trying to access the first piece of a property using bracket notation. I understand for example if something is such as

propa: "Words" I would access words via objectName[propa] which would give me "Words". But how would I access just 'propa' in this example? For reference I'm working on 'Accessing Objects Properties with Variables'.

Norman Dela Cruz
@dcnr
Feb 14 2016 03:11
thank you @d00mb0x
CamperBot
@camperbot
Feb 14 2016 03:11
dcnr sends brownie points to @d00mb0x :sparkles: :thumbsup: :sparkles:
:star: 209 | @d00mb0x | http://www.freecodecamp.com/d00mb0x
greg
@wearenotgroot
Feb 14 2016 03:12
@d00mb0x you kinda already did as you mention--------->objectName[propa] will give you value
@d00mb0x but if you wanted to test if propa as property exist then there is .hasOwnProperty(propa) you can use to determine that
Chase Childers
@d00mb0x
Feb 14 2016 03:14
Right, but in my example propa has the value of "Words", say I only needed to return propa.
greg
@wearenotgroot
Feb 14 2016 03:14
@d00mb0x now when you are working with variables just put the variable inside the bracket
Chase Childers
@d00mb0x
Feb 14 2016 03:14
The problem won't solve that way, I already tried hah. I have to solve it by accessing the value
greg
@wearenotgroot
Feb 14 2016 03:15
@d00mb0x so you want the key?
casadaro
@Casadaro
Feb 14 2016 03:15
@wearenotgroot I think im starting to understand what I need to do.
Chase Childers
@d00mb0x
Feb 14 2016 03:15
@wearenotgroot I believe yes
greg
@wearenotgroot
Feb 14 2016 03:15
@d00mb0x there is an method to get all keys to an object
@d00mb0x Object.keys(yourcollection here)
@d00mb0x remember this will return an array of all the property names in that object you pass in the method
uriznik
@uriznik
Feb 14 2016 03:17
@d00mb0x that particular challenge doesn't need anything complex
@d00mb0x obj.thefield, obj["thefield"], and var whichField = "thefield"; obj[whichField] do the same thing
greg
@wearenotgroot
Feb 14 2016 03:18
@d00mb0x have you done that challenge? or just as reference as you said and working on something else?
@Casadaro ok good :+1: keep it up
Chase Childers
@d00mb0x
Feb 14 2016 03:19
I apologize everyone I do appreciate the help, @dcnr is also helping me in a separate chat. I'm trying to read both
greg
@wearenotgroot
Feb 14 2016 03:20
@d00mb0x alrighty then :smile:
anyways brb
junson
@junson8906
Feb 14 2016 03:47
how to user reduce to sum all the values in array
who can help me
rybka02
@rybka02
Feb 14 2016 03:48
i can
junson
@junson8906
Feb 14 2016 03:48
thank your
thank you
Pradeep CE
@cepradeep
Feb 14 2016 03:48
@junson8906 Hint: Keep adding currentValue to previousValue.
junson
@junson8906
Feb 14 2016 03:48
soga
thanks
Mafalda
@otmeek
Feb 14 2016 03:49
could someone explain why .splice() isn't working in this code? I've made sure the if is correct
var regex = /(.)\1{2,}/;
  for (var i = 0; i < permutations.length; i++) {
    if(regex.test(permutations[i])) {
      var b = permutations.splice(i, 1);
    }
  }
but no changes are being made to the array
rybka02
@rybka02
Feb 14 2016 03:49
var total = [0, 1, 2, 3].reduce(function(a, b) {
  return a + b;
});
Pradeep CE
@cepradeep
Feb 14 2016 03:50
@otmeek Which waypoint is it?
Mafalda
@otmeek
Feb 14 2016 03:50
@pradeepce No repeats please
Pradeep CE
@cepradeep
Feb 14 2016 03:50
@otmeek Excuse me?
@otmeek Ah!
Okay :)
Mafalda
@otmeek
Feb 14 2016 03:51
@pradeepce that's the name :p
Pradeep CE
@cepradeep
Feb 14 2016 03:52
@otmeek I'm behind you. But someone else should help you shortly.
casadaro
@Casadaro
Feb 14 2016 04:05
thanks @wearenotgroot
CamperBot
@camperbot
Feb 14 2016 04:05
casadaro sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 839 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
bitgrower
@bitgrower
Feb 14 2016 04:13
@otmeek -- don't know about specifics here ... but TYPICALLY, if you want to capture grouped regexes, you do something like this /(.s+)./\1/
every instance of parens is numbered, and then you put the numbered expressions in the "replacement" expression ... I am NOT as familiar with how it works in js ... but that's generally how regexes work ...
Meghana
@meghanasarikonda
Feb 14 2016 04:15

any one please help me function titleCase(str) {
var loww=str.toLowerCase();
var arr=loww.split("");
var newArr=[];
for(var i=0;i<arr.length;i++){
newArr.push(arr[i]);

}
return newArr;
}
titleCase("i'm a litTle tea pot");

bitgrower
@bitgrower
Feb 14 2016 04:30
@meghanasarikonda -- can you format your code, per camperbot's instructions ?
explain format
CamperBot
@camperbot
Feb 14 2016 04:30

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Abdul Sahibzada
@Sahia4709
Feb 14 2016 04:31
Hi
bitgrower
@bitgrower
Feb 14 2016 04:32
hello @Sahia4709
Abdul Sahibzada
@Sahia4709
Feb 14 2016 04:32
Can anyone please help me with the chunky monkey challenge?
I tried and have no idea what to do
Meghana
@meghanasarikonda
Feb 14 2016 04:32
<function titleCase(str) {
  var loww=str.toLowerCase();
  var arr=loww.split("");
 var newArr=[];
   for(var i=0;i<arr.length;i++){
  newArr.push(arr[i]);

   }
return newArr;
} 
titleCase("i'm a litTle tea pot");>
@bitgrower
bitgrower
@bitgrower
Feb 14 2016 04:33
possibly -- a good start is to post your code as per camperbot's instructions, posted a little above
David Weedmark
@DavidWeedmark
Feb 14 2016 04:33
@Sahia4709 I might be able to help. what have you got?
Abdul Sahibzada
@Sahia4709
Feb 14 2016 04:33
@DavidWeedmark Nothing I reset it
bitgrower
@bitgrower
Feb 14 2016 04:34
@meghanasarikonda -- the important thing to remember is that strings are immutable -- if you want to change a character in a string, you'll have to set it to a new variable ...
This message was deleted
Meghana
@meghanasarikonda
Feb 14 2016 04:37

@bitgrower ```

<function titleCase(str) {
var loww=str.toLowerCase();
var arr=loww.split("");
var newArr=[];

newArr.push(arr);

return newArr;
}
titleCase("i'm a litTle tea pot");
>
```

David Weedmark
@DavidWeedmark
Feb 14 2016 04:37
@Sahia4709 okay, well to give you a start, you want to create a new array, then create a loop, then push the arr.slice into that new array
Abdul Sahibzada
@Sahia4709
Feb 14 2016 04:38
ya thats what i had, im having trouble slicing it the right way
@DavidWeedmark
but I will try it again, maybe I will have more luck
David Weedmark
@DavidWeedmark
Feb 14 2016 04:40
good luck!
Abdul Sahibzada
@Sahia4709
Feb 14 2016 04:40
Thanks!
Meghana
@meghanasarikonda
Feb 14 2016 04:40
@bitgrower actually how to do it
bitgrower
@bitgrower
Feb 14 2016 04:40
ahh ... sorry -- you are almost there, @meghanasarikonda -- you need to have ```js on a line by itself, as the first line
Meghana
@meghanasarikonda
Feb 14 2016 04:42
js<function titleCase(str) {
  var loww=str.toLowerCase();
  var arr=loww.split("");
 var newArr=[];

  newArr.push(arr);



return newArr;
} 
titleCase("i'm a litTle tea pot");>
bitgrower
@bitgrower
Feb 14 2016 04:42

two pieces of info which will help you ...

read up on str.split();

and also realize that strings are immutable ... so, in order to change them, you have to put them in a different (new) variable)

E
@efhjones
Feb 14 2016 04:42
Hi again rrybody, I'm trying to figure out how to filter out unwanted characters in a string, anyone have a hint for me?
function cleanUp (arr) {
  return arr !== ("[^a-zA-Z0-9]","");

}

function palindrome(str) {

  var lowCaseStr = str.toLowerCase("");
  var strIfy = [];

  strIfy = lowCaseStr.split("");


  var cleanStr = lowCaseStr.filter(cleanUp);
  return lowCaseStr;
Well, looking at it again I'm trying to filter out unwanted characters in an arr rather...
This message was deleted
bitgrower
@bitgrower
Feb 14 2016 04:48
str.replace
E
@efhjones
Feb 14 2016 04:49
Makes more sense thanks @bitgrower
CamperBot
@camperbot
Feb 14 2016 04:49
efhjones sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 514 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 14 2016 04:52
yw @efhjones
bitgrower
@bitgrower
Feb 14 2016 04:59
@meghanasarikonda -- it will help if you sit down and write down the steps you need to take to come up with a solution first, before trying to code it ...
Abdul Sahibzada
@Sahia4709
Feb 14 2016 05:04
guys i put //no protect in my project now everytime i open the project it crashes
what do i do
rphares
@rphares
Feb 14 2016 05:04
explain auto
CamperBot
@camperbot
Feb 14 2016 05:04

:point_right: disable code auto run [wiki]

By default, the Free Code Camp site automatically loads and runs your last recorded solution. If you have accidentally created an infinite loop or other irrecoverable error or simply don't trust the code, you can disable code auto-run by putting the following in your URL:
run=disabled

Example:

URL: http://www.freecodecamp.com/challenges/Algorithm-meet-Algorithm#?solution=function%20meetBonfire(argument)

No-Run URL: http://www.freecodecamp.com/challenges/Algorithm-meet-Algorithm#?run=disabled&solution=function%20meetBonfire(argument)

:pencil: read more about disable code auto run on the FCC Wiki

rphares
@rphares
Feb 14 2016 05:05
@Sahia4709 :point_up:
Meghana
@meghanasarikonda
Feb 14 2016 05:05
@bitgrower okay
David Weedmark
@DavidWeedmark
Feb 14 2016 05:05
man. @bitgrower and @rphares are amazing. here's a shout-out even though I didn't personally need help today thanks @bitgrower @rphares
CamperBot
@camperbot
Feb 14 2016 05:05
davidweedmark sends brownie points to @bitgrower and @rphares and @bitgrower and @rphares :sparkles: :thumbsup: :sparkles:
:star: 2754 | @rphares | http://www.freecodecamp.com/rphares
:star: 515 | @bitgrower | http://www.freecodecamp.com/bitgrower
:star: 2754 | @rphares | http://www.freecodecamp.com/rphares
:star: 515 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 14 2016 05:05
awwww thanks, @DavidWeedmark
rphares
@rphares
Feb 14 2016 05:05
( @Sahia4709 , if that doesn't work, there is another way, but it will erase your code. come back disable auto fails and we'll show you the other way! :) )
Aww, way too kind, @DavidWeedmark ! :blush: thank~
CamperBot
@camperbot
Feb 14 2016 05:06
rphares sends brownie points to @davidweedmark :sparkles: :thumbsup: :sparkles:
David Weedmark
@DavidWeedmark
Feb 14 2016 05:06
actually I learn a lot here just by following the feed between projects. supreme lurker here
CamperBot
@camperbot
Feb 14 2016 05:06
:star: 324 | @davidweedmark | http://www.freecodecamp.com/davidweedmark
rphares
@rphares
Feb 14 2016 05:06
thats part of how i got here :)
David Weedmark
@DavidWeedmark
Feb 14 2016 05:07
:D
bitgrower
@bitgrower
Feb 14 2016 05:07
what's up with that ??? @camperbot respects @rphares thanks and disses mine ???? Bah humbug!!!
CamperBot
@camperbot
Feb 14 2016 05:07
bitgrower sends brownie points to @camperbot and @rphares :sparkles: :thumbsup: :sparkles:
:star: 1177 | @camperbot | http://www.freecodecamp.com/camperbot
:star: 2755 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 14 2016 05:07
lol
bitgrower
@bitgrower
Feb 14 2016 05:07
okay, @camperbot -- please thank @DavidWeedmark
CamperBot
@camperbot
Feb 14 2016 05:07
bitgrower sends brownie points to @camperbot and @davidweedmark :sparkles: :thumbsup: :sparkles:
:warning: bitgrower already gave camperbot points
:star: 325 | @davidweedmark | http://www.freecodecamp.com/davidweedmark
rphares
@rphares
Feb 14 2016 05:08
well that was unintentional, I'm sure, @bitgrower
bitgrower
@bitgrower
Feb 14 2016 05:08
whew ...
yeah, I know ... just having fun ...
rphares
@rphares
Feb 14 2016 05:08
he always does my bidding, @bitgrower ... ;)
CamperBot
@camperbot
Feb 14 2016 05:08
rphares sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 516 | @bitgrower | http://www.freecodecamp.com/bitgrower
Meghana
@meghanasarikonda
Feb 14 2016 05:09
js
<function titleCase(str) {
  var loww=str.toLowerCase();
  var arr=loww.split("");
 var newArr=[];

  newArr.push(arr);
for(var i=0;i<arr.length;i++) {
  if(arr[i]==" ") {
    newArr[i+1]=newArr[i+1].toUpperCase();
  }
}


return newArr;
} 
titleCase("i'm a litTle tea pot");
>
@bitgrower
Abdul Sahibzada
@Sahia4709
Feb 14 2016 05:11
@rphares It didn't work
bitgrower
@bitgrower
Feb 14 2016 05:11

LOL, well, the first time I did Title Case I created a mini-state machine, I was so frustrated, where iterated through EVERY single character in the string ...

...and while str.split("") will do that for you, it's a bit more standard to FIRST split the string you're passed into an array of strings ... and then handle each one ...

rphares
@rphares
Feb 14 2016 05:11
okeydoke--
help storage
CamperBot
@camperbot
Feb 14 2016 05:11

:point_right: clear your browser's local storage [wiki]

Removing all your locally stored challenges will solve many problems related to the browser crashing on FreeCodeCamp

In Chrome:

  • On 'freecodecamp.com' open your console
    • Windows: Ctrl + Shift + J
    • Mac OS: Cmd + Opt + J
  • Go to resources tab(chrome).
    • There click on the localStorage link in the nav bar on the right.
  • Delete all the entries on the right side.
  • See if this solves your issue

Alternatively, if you are having issues with a specific challenge freezing your browser, find the name of that challenge in local storage and delete just that one.
:pencil: read more about clear your browsers local storage on the FCC Wiki

Abdul Sahibzada
@Sahia4709
Feb 14 2016 05:12
nevermind it worked @rphares
rphares
@rphares
Feb 14 2016 05:12
@Sahia4709 , read that carefully, you want the bottom link that says 'delete just that one', i think--
phew!
congrats and happy coding, @Sahia4709 ~
Abdul Sahibzada
@Sahia4709
Feb 14 2016 05:12
@rphares Thanks!
CamperBot
@camperbot
Feb 14 2016 05:12
sahia4709 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2756 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 14 2016 05:14
Anytime!
Abdul Sahibzada
@Sahia4709
Feb 14 2016 05:16
Hello again
blob
bitgrower
@bitgrower
Feb 14 2016 05:16
I just realized one of the advantages of node.js ... I don't have to worry about running different versions of it because of differing browser implementation ...
Abdul Sahibzada
@Sahia4709
Feb 14 2016 05:16
I don't know why it says I have an infinite loop
Help Please.
CamperBot
@camperbot
Feb 14 2016 05:16

:point_right: algorithm no repeats please [wiki]

Problem Explanation:

  • This task requires us to look at each possible permutation of a string. This is best done using a recursion function. Being able to build a function which collects all permutations of a string is a common interview question, so there is no shortage of tutorials out there on how to do this, in many different code languages.
  • This task can still be daunting even after watching a tutorial. You will want to send each new use of the function 3 inputs: 1. a new string (or character array) that is being built, 2. a position in your new string that's going to be filled next, and 3. an idea of what characters (more specifically positions) from the original string have yet to be used. The pseudo code will look something like this:

    ```
    var str = ???;
    perm(current position in original string, what's been used in original string, current string build thus far){
    if(current string is finished) {
    print current string;
    }else{
    for(var i = 0; i < str.length; i++) {

    if(str[i] has not been used) {
      put str[i] into the current position;
      mark str[i] as used
      perm(current position in original string, what's been used in original string, current string build thus far)
      unmark str[i] as used because another branch in the tree for i + 1 will still likely use it;
    }

    }
    }
    }
    :pencil: read more about algorithm no repeats please on the FCC Wiki

bitgrower
@bitgrower
Feb 14 2016 05:17
@Sahia4709 -- can you copy and paste the code in here ???
Abdul Sahibzada
@Sahia4709
Feb 14 2016 05:17

function chunk(arr, size) {
var x=0;
var y;
var numElementsinIndex = arr.length/size;
y=numElementsinIndex;
var array =[];
var arrayStuff=[];
for (var i=0;i<size;i++){
for (var j=0;j<arr.length;j++){
arrayStuff[j]=arr.push(arr.slice(x,y));
x=x+numElementsinIndex;
y=y-arr.length-numElementsinIndex;
array[i]=arrayStuff[j];
}
}
return array;
}

chunk(["a", "b", "c", "d"], 2);

I don't know how to give it syntax
bitgrower
@bitgrower
Feb 14 2016 05:17
here's how ...
explain format
CamperBot
@camperbot
Feb 14 2016 05:17

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

bitgrower
@bitgrower
Feb 14 2016 05:19
also, when you use Array.push -- you don't have to assign it to another variable...
if a = [1,2,3] you can do a.push(4) and you get a = [1,2,3,4]
Abdul Sahibzada
@Sahia4709
Feb 14 2016 05:21
ok
cannelflow
@cannelflow
Feb 14 2016 05:21
thank you @AkiraLaine
Abdul Sahibzada
@Sahia4709
Feb 14 2016 05:21
js<function chunk(arr, size) {
  var x=0;
  var y;
  var numElementsinIndex = arr.length/size;
  y=numElementsinIndex;
  var array =[];
  var arrayStuff=[];
  for (var i=0;i<size;i++){
    for (var j=0;j<arr.length;j++){
      arrayStuff[j]=arr.push(arr.slice(x,y));
      x=x+numElementsinIndex;
      y=y-arr.length-numElementsinIndex;
      array[i]=arrayStuff[j];
    }
  }
  return array;
}

chunk(["a", "b", "c", "d"], 2);>
CamperBot
@camperbot
Feb 14 2016 05:21
cannelflow sends brownie points to @akiralaine :sparkles: :thumbsup: :sparkles:
:star: 1221 | @akiralaine | http://www.freecodecamp.com/akiralaine
Abdul Sahibzada
@Sahia4709
Feb 14 2016 05:22
@bitgrower I put the code back in
@bitgrower Disregard what y is equal to
i changed
<function chunk(arr, size) {
  var x=0;
  var y;
  var numElementsinIndex = arr.length/size;
  y=numElementsinIndex;
  var array =[];
  var arrayStuff=[];
  for (var i=0;i<size;i++){
    for (var j=0;j<arr.length;j++){
      arrayStuff[j]=arr.push(arr.slice(x,y));
      x=x+numElementsinIndex;
      y=y-numElementsinIndex;
      array[i]=arrayStuff[j];
    }
  }
  return array;
}

chunk(["a", "b", "c", "d"], 2);
>
bitgrower
@bitgrower
Feb 14 2016 05:26
@Sahia4709 -- you only need 1 for loop to do this
Abdul Sahibzada
@Sahia4709
Feb 14 2016 05:26
@bitgrower whaaaaaaaaaaaaaaaaaaaaat?
bitgrower
@bitgrower
Feb 14 2016 05:28
basically ... you just have to look at the array for each size "chunks" ...
then, you use array.slice to get the number of array elements...
Abdul Sahibzada
@Sahia4709
Feb 14 2016 05:29
ok, and what about the infinte loop issue
also how can i print output to my screen
so i can see what its printing
bitgrower
@bitgrower
Feb 14 2016 05:30
not to your screen, but you can use console.log to look at intermediate values ...
Abdul Sahibzada
@Sahia4709
Feb 14 2016 05:31
what do u mean by intermediate values?
bitgrower
@bitgrower
Feb 14 2016 05:31
if you want to run your code in a different environment, you can use repl.it (1 of many js "playgrounds") or my fav ... pythontutor.com/javascript.html
values your code creates that aren't the return value
there's some "video challenges" which talk about chrome developer tools ...
Meghana
@meghanasarikonda
Feb 14 2016 05:37
This message was deleted
@bitgrower
js
<function titleCase(str) {
  var loww=str.toLowerCase();
  var arr=loww.split("");
 var newArr=[];
  var newArr1=newArr.push(arr[0]);
  newArr1=newArr1.toUpperCase();


return newArr;
} 
titleCase("i'm a litTle tea pot");>
im not getting this
any hint
pls
bitgrower
@bitgrower
Feb 14 2016 05:40
@meghanasarikonda -- you can also get hints from camperbot ...
hint title case
CamperBot
@camperbot
Feb 14 2016 05:40
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
E
@efhjones
Feb 14 2016 05:40

Could I have some help with Check for Palindromes? I'm stuck on removing unwanted characters from the array.


function palindrome(str) {

  var lowCaseStr = str.toLowerCase("");
  var strIfy = [];

  strIfy = lowCaseStr.split("");

  // strIfy is an array 

return strIfy;
}
palindrome("RACE. CAR");

Also a little confused by one of the tests, if we are supposed to remove non alphanumeric characters from the array how would this happen? palindrome("0_0 (: /-\ :) 0-0") should return true.

bitgrower
@bitgrower
Feb 14 2016 05:40
click on the link, it (should) take you to a separate room with hints -- if not .. it will take you to a page which will have the links to the specific algo challenge "rooms"
hey .. where are you using str.replace ?
Olawale Akinseye
@brainyfarm
Feb 14 2016 05:42

@brainyfarm what is flipclock.js? Is it open source? How do u go about finding these useful APIs?

Yes @sigursiguros, it is open source and basically you could find lot of stuff by Googling and then some stuff are introduced to me here :grinning:

bitgrower
@bitgrower
Feb 14 2016 05:43
is that handy for pomodoro, @brainyfarm ?
E
@efhjones
Feb 14 2016 05:43
I don't know if I can since I'm trying to remove items from an array not a string
Olawale Akinseye
@brainyfarm
Feb 14 2016 05:43
Yes @bitgrower :D
bitgrower
@bitgrower
Feb 14 2016 05:44
well, @efhjones -- do it before you create the array ...
TheoSarran
@TheoSarran
Feb 14 2016 05:44

Hi can anyone tell me what I'm doing wrong here? Thanks!

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

// Only change code below this line

var secondTree = myPlants.type.trees1;

bitgrower
@bitgrower
Feb 14 2016 05:45
I'm pretty sure you can do palindrome without ever using arrays, @efhjones -- I have like 3 different solutions .. 1 uses a loop, 1 uses an if/else, and the 3rd way uses an ES6 feature ...
I don't think I used arrays in the 1st way -- definitely didn't in the other 2
rphares
@rphares
Feb 14 2016 05:46
sure thing, @TheoSarran
a few things,
n9exorcist
@n9exorcist
Feb 14 2016 05:46

whats wrong with my challenge "Accessing Objects Properties with Variables".. // Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

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

rphares
@rphares
Feb 14 2016 05:46
first, myPlants has two parts, right? so you need to tell it which part pine is in, @TheoSarran
is it in myPlants[0] or myPlants[1] ? @TheoSarran
@n9exorcist , two things
i think you were supposed to set var playerNumber to an actual number, right? i think it was 16?
TheoSarran
@TheoSarran
Feb 14 2016 05:47
I tried myPlants[1][1] but it didn't seem to work
rphares
@rphares
Feb 14 2016 05:47
then, for the second line, var player... @n9exorcist
very close, @TheoSarran !
n9exorcist
@n9exorcist
Feb 14 2016 05:47
@rphares yeah, The variable player should be a string and it should be 16 in this case
rphares
@rphares
Feb 14 2016 05:48
but, you are missing something that way-- where is that second [1] coming from... should me myPLants[1].SOMETHING[1] @TheoSarran
bitgrower
@bitgrower
Feb 14 2016 05:48
@TheoSarran -- describe your data structure .. you've got the first part -- which is addressing the element of the array, which is an object, but then you need to look at how to address things within the array -- uses different addressing ...
rphares
@rphares
Feb 14 2016 05:48
cool, so the second line, @n9exorcist -- in the []
you are being too specific, @n9exorcist
you dont need to test for "montana"
TheoSarran
@TheoSarran
Feb 14 2016 05:49
ohhhhhh I see! got it! thanks @rphares!
CamperBot
@camperbot
Feb 14 2016 05:49
theosarran sends brownie points to @rphanes :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for rphanes
bitgrower
@bitgrower
Feb 14 2016 05:49
thanks @rphares
CamperBot
@camperbot
Feb 14 2016 05:49
bitgrower sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:warning: bitgrower already gave rphares points
rphares
@rphares
Feb 14 2016 05:50
thats where you use your ... how did the directions put it? use player number?
i forget the exact words, I'm sorry,I'm not good at terms...
lol, what on earth for, @bitgrower ? tax ya back :blush:
CamperBot
@camperbot
Feb 14 2016 05:50
rphares sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: rphares already gave bitgrower points
rphares
@rphares
Feb 14 2016 05:51
found it! "Use the playerNumber variable" in the second line, @n9exorcist
bitgrower
@bitgrower
Feb 14 2016 05:51
LOL ... demoing how to send points ...
...to the right person ...
n9exorcist
@n9exorcist
Feb 14 2016 05:52
@rphares Sorry, I dont understand, when you say Use the playerNumber variable" in the second line,
rphares
@rphares
Feb 14 2016 05:52
right now you are testing by the specifics, @n9exorcist , using "montana"
that only works for that one guy,
with that exact code
what happens if you change the team?
your code won't work anymore...
E
@efhjones
Feb 14 2016 05:53
@bitgrower Ok. Trying to figure out str.replace and wrap my head around regular expressions. Also, how would this test pass if we need to remove all non alphanumeric characters..? : palindrome("0_0 (: /-\ :) 0-0") should return true.
rphares
@rphares
Feb 14 2016 05:54
from here on in (actually, from the last lesson, if i recall) we want to start using variables and keys and parameters and all that good stuff, that will work with more than one specific (names and values and things that are hardcoded in) so our code isn't just specific to this one case...
n9exorcist
@n9exorcist
Feb 14 2016 05:54
@rphares Actually, I tried inserting "Namath" in the place of variable player, the compiler wanted to me use with dot notation.
bitgrower
@bitgrower
Feb 14 2016 05:54
guess it depends upon all the special characters that you remove, @efhjones --
rphares
@rphares
Feb 14 2016 05:55
@n9exorcist , thats still a specific
we dont want to use any of the "montana" "namath" etc,
int he brackets, we should "Use the playerNumber variable"
(and thats not a string, so dont put quotes on it :) )
n9exorcist
@n9exorcist
Feb 14 2016 05:57
@rphares it says, Reference error: Montana is not defined
Abdul Sahibzada
@Sahia4709
Feb 14 2016 05:57
WOHOOOOOOOOOOOOO, I GOT IT
rphares
@rphares
Feb 14 2016 05:57
not montant
no montana
no namath
@bitgrower , maybe i should pass this one to you-- wanna explain the difference between using the variable and using "montana" etc, in accessing object properties with variables?
n9exorcist
@n9exorcist
Feb 14 2016 05:58
@rphares Can you copy and paste the soln for the those two lines.
rphares
@rphares
Feb 14 2016 06:00
Hmm, lets try pasting what you are trying now (with the first line set to the number now, i hope) and @bitgrower or someone with better comm skills can use a better way of explaining what goes in those bottom [] for ya :blush:
E
@efhjones
Feb 14 2016 06:03
@bitgrower well I could remove symbols and the test would return true but what if it wasn't actually a palindrome? For example what if the test was ("0_0 (: &*$@(% :) 0-0") Removing all the symbols would return 0000 and that would return true but it's not ACTUALLY a palindrome so the program wouldn't work right.
rphares
@rphares
Feb 14 2016 06:05
okay-- maybe e can look at the example, @n9exorcist
var someProp = "propName";
var myObj = {
  propName: "Some Value"
}
myObj[someProp];
if we substitute what you are working with and what you have so far..
n9exorcist
@n9exorcist
Feb 14 2016 06:06

@rphares var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16; // Change this Line
var player = "Montana"; // Change this Line

This is what I have now
rphares
@rphares
Feb 14 2016 06:07
var playerNumber = 16;
var testObj = {
  16: "Some Value"// this is the montana, namath, etc part... "Some value" note the bottom line--they dont use some value in the example, they use whats to the *left* of the :
}
testObj[???]; // so in your brackets, you should put the name of the var, what is to the *left* of the :, that you declared already...
that is the example, from above, converted into what you are using so far, except without the brackets filled in... compare it to the example above.. in the example above, they use someProp, the name of the variable , in the brackets to get the property name. You can do the same....
bitgrower
@bitgrower
Feb 14 2016 06:11
@rphares -- sorry, I fell into a node.js lesson ... I'm afraid I'm not good at explaining object addressing ...it's something I need to brush up on ...
n9exorcist
@n9exorcist
Feb 14 2016 06:11
@rphares its more like , var player = testObj[16]; isnt?
bitgrower
@bitgrower
Feb 14 2016 06:12
@efhjones ... why isn't 0000 a palindrome ? doesn't it read the same way forward and backward ?
which exercise is this one, that you are working on @n9exorcist
n9exorcist
@n9exorcist
Feb 14 2016 06:13
@bitgrower Accessing Objects Properties with Variables
rphares
@rphares
Feb 14 2016 06:14
@n9exorcist , closer, but no--
not the number,
the name of the variable
bitgrower
@bitgrower
Feb 14 2016 06:15
hmmm I'm not finding that one ... can you link me ?
rphares
@rphares
Feb 14 2016 06:15
thats the key point of the lesson, that you can "access object properties with variables"
E
@efhjones
Feb 14 2016 06:16
@bitgrower No I'm saying it IS, but the original entry wouldn't be a palindrome
rphares
@rphares
Feb 14 2016 06:16
what is the name of the variable that you set to 16? @n9exorcist
n9exorcist
@n9exorcist
Feb 14 2016 06:17
@rphares playerNumber
bitgrower
@bitgrower
Feb 14 2016 06:17
ahh ... yeah ... I think in that case, you have to follow the constraints of the challenge, @efhjones ... because neither would race car technically be one either ...
Jovvi Johnson
@jovjohnson
Feb 14 2016 06:17
does anyone know how i can append an element in jquery that continually replaces a previous element? specifically just a (negative) iteration. would this require a loop?
Franco Zapata
@Francozt01
Feb 14 2016 06:17
@n9exorcist to the variables add the way to get that number player inside the object
rphares
@rphares
Feb 14 2016 06:17
yes, @n9exorcist :blush:
n9exorcist
@n9exorcist
Feb 14 2016 06:18
@rphares I have the result, but why we are in need to set the name of the variable
bitgrower
@bitgrower
Feb 14 2016 06:18
ahahahahahaha oookay ... this actually pretty simple ... you were on the right path when you put 16 in there ... what they want you to do is, rather than using the literal property, to use the variable ...
@n9exorcist -- I don't know what the original problem was like ... but I changed the code you provided just very slightly and it passed ...
n9exorcist
@n9exorcist
Feb 14 2016 06:20

// 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

bitgrower
@bitgrower
Feb 14 2016 06:20
yup ... right ... so you are asking why do you need to set the name of the variable ?
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 14 2016 06:20
I’m working on SpindalTapCase, and it’s hair-tearing experience…I don’t understand why I get double dashes at end?
function spinalCase(str) {
  function analyzer(match,p1,p2,p3,offset,string){          
  return p1.toLowerCase() + p2+ "-";                          
  }
  var returnedstring = str.replace(/([A-Z]*)([a-z]*)([^A-Za-z]*)/g,analyzer);
return returnedstring;   
}

spinalCase("This Is Spinal Tap”);
n9exorcist
@n9exorcist
Feb 14 2016 06:20
@bitgrower yes
bitgrower
@bitgrower
Feb 14 2016 06:20
because the exercise is showing you how you can pass a variable as a property, and use it to index into the object ...
rphares
@rphares
Feb 14 2016 06:20
@bitgrower yeah, he got it now-- its the explaining (i had to use heavy handed hints) that would be useful, i think.... sorry, I'm terrible at that part, i dont know all the words...
E
@efhjones
Feb 14 2016 06:20
@bitgrower ah ok thanks. Back to regular expressions with me then...
CamperBot
@camperbot
Feb 14 2016 06:20
efhjones sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 517 | @bitgrower | http://www.freecodecamp.com/bitgrower
n9exorcist
@n9exorcist
Feb 14 2016 06:21
@rphares @bitgrower thanks guys
CamperBot
@camperbot
Feb 14 2016 06:21
n9exorcist sends brownie points to @rphares and @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 2759 | @rphares | http://www.freecodecamp.com/rphares
:star: 518 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 14 2016 06:22
actually, it's ladies ... :)
n9exorcist
@n9exorcist
Feb 14 2016 06:22
sorry :smile:
bitgrower
@bitgrower
Feb 14 2016 06:22
LOL ... np
rphares
@rphares
Feb 14 2016 06:23
no worries!
bitgrower
@bitgrower
Feb 14 2016 06:23
just showing the wonder of women in cs ...
@pkshreeman -- because your analyzer function is adding "-" at the end ... I'm not sure why you have 2 at the end ... but having the string end at "-" is not a surprise ...
n9exorcist
@n9exorcist
Feb 14 2016 06:24
I have this notion as if only guys do programming :smile:
bitgrower
@bitgrower
Feb 14 2016 06:25
yeah ... what's sad is that the % of women in cs/programming has actually dropped in the last few decades ...
E
@efhjones
Feb 14 2016 06:25
@n9exorcist I know I'm always worried I'll be the only lady in the room.... thankfully not here!
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 14 2016 06:25
@bitgrower yes…I guess I can splice or something off the end and then call it night.
n9exorcist
@n9exorcist
Feb 14 2016 06:25
@efhjones Now you know that you have comapnies
Olawale Akinseye
@brainyfarm
Feb 14 2016 06:26

Oh! @bitgrower ?

actually, it's ladies ... :)

bitgrower
@bitgrower
Feb 14 2016 06:26
why would I lie ?
Olawale Akinseye
@brainyfarm
Feb 14 2016 06:26
I never knew :D
bitgrower
@bitgrower
Feb 14 2016 06:27
yeah, I'm prolly less obvious ... except for when i do things like this ...
bitgrower @bitgrower thinks she would like a different tutorial on node.js
rphares
@rphares
Feb 14 2016 06:27
thats when i noticed :)
bitgrower
@bitgrower
Feb 14 2016 06:27
@pkshreeman -- you COULD ... but that's kinda of an ugly hack ...
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 14 2016 06:28
yes…it’s interesting…if I removed p3 …like this I get double dashes everywhere…
function spinalCase(str) {
  function analyzer(match,p1,p2,offset,string){          
  return p1.toLowerCase() + p2 + "-";                          
  }
  var returnedstring = str.replace(/([A-Z]*)([a-z]*)/g,analyzer);
return returnedstring;   
}

spinalCase("This Is Spinal Tap”);
n9exorcist
@n9exorcist
Feb 14 2016 06:29
@efhjones Some this so consolidating here : http://www.bbc.com/news/technology-35559439
bitgrower
@bitgrower
Feb 14 2016 06:29
I mean, that's a fun use of str.replace ... I forget how I solved it ... but it wasn't that way ...
yeah, I think closures are messing you up ...
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 14 2016 06:30
can you explain “closures”?
bitgrower
@bitgrower
Feb 14 2016 06:30
just assume it's like a .forEach in arrays ...or a for loop
E
@efhjones
Feb 14 2016 06:31
@n9exorcist I read that! And then directly changed my profile pic... :grimacing:
bitgrower
@bitgrower
Feb 14 2016 06:31
probably not at 10:31 pm ... however, I can link you to a nice set of short videos on weird stuff in js that I just watched today ...
n9exorcist
@n9exorcist
Feb 14 2016 06:31
@efhjones :smile:
akhil
@akhil451
Feb 14 2016 06:32
I'm doing Seek and Destroy problem from the bonfires .
in essence, to use replace in the way you are using it, assume the function is running on each chunk of text ...
akhil
@akhil451
Feb 14 2016 06:33
I'm doing Seek and Destroy problem from the bonfires .my function always seems to return an empty array ,olease help.
bitgrower
@bitgrower
Feb 14 2016 06:33
post your code, please @akhil451
akhil
@akhil451
Feb 14 2016 06:33

///jsfunction destroyer(arr) {
// Remove all the values
var arr1=arguments[0];

function found(arr1){
for(i=0;i<arr1.length;i++)
{
for(j=1;j<arguments.length;j++)
{
if(arr1[i]===arguments[j]) return false;
}

}
}
return arr1.filter(found);
}

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

sorry for that
bitgrower
@bitgrower
Feb 14 2016 06:34
explain format -- if you want try improving it, @akhil451 -- (and earn undying love from your helpers)
CamperBot
@camperbot
Feb 14 2016 06:34
no wiki entry for: format -- if you want try improving it @akhil451 -- and earn undying love from your helpers
bitgrower
@bitgrower
Feb 14 2016 06:34
bah!
explain format
CamperBot
@camperbot
Feb 14 2016 06:34

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Adi
@kiniadit
Feb 14 2016 06:35

I'm getting this error - TypeError: arr.join is not a function
function reverseString(str) {
var arr = [];
arr = str.split("");
arr = arr.reverse;
arr = arr.join("");
return arr;
}

reverseString("hello");

any ideas why?
akhil
@akhil451
Feb 14 2016 06:35

```js function destroyer(arr) {
// Remove all the values
var arr1=arguments[0];

function found(arr1){
for(i=0;i<arr1.length;i++)
{
for(j=1;j<arguments.length;j++)
{
if(arr1[i]===arguments[j]) return false;
}

}
}
return arr1.filter(found);
}

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

@kiniadit instead of using arr use str=str.split("").reverse("").join("");
Preetam Kajal Rout
@preetamkajalrout
Feb 14 2016 06:39
@kiniadit :
arr = arr.reverse();
bitgrower
@bitgrower
Feb 14 2016 06:40
@kiniadit -- if you are getting arr.join is not a function, that means arr is not an array ...
Jason
@carpediem1213
Feb 14 2016 06:40
help mutations
CamperBot
@camperbot
Feb 14 2016 06:40

:point_right: algorithm mutations [wiki]

Problem Explanation:

  • Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array..
:pencil: read more about algorithm mutations on the FCC Wiki
Preetam Kajal Rout
@preetamkajalrout
Feb 14 2016 06:41
@carpediem1213 : Hey, How can we help?
bitgrower
@bitgrower
Feb 14 2016 06:41

@akhil451 -- I like to think of @camperbot 's format explanations as an exercise in following instructions ... you have to follow them EXACTLY ... close doesn't count ...

in your case ... you need to put the ```js on it's own line, with nothing else ...

Adi
@kiniadit
Feb 14 2016 06:41
thank you! @preetamkajalrout @akhil451
CamperBot
@camperbot
Feb 14 2016 06:41
kiniadit sends brownie points to @preetamkajalrout and @akhil451 :sparkles: :thumbsup: :sparkles:
:star: 178 | @preetamkajalrout | http://www.freecodecamp.com/preetamkajalrout
:star: 259 | @akhil451 | http://www.freecodecamp.com/akhil451
bitgrower
@bitgrower
Feb 14 2016 06:41
This message was deleted
akhil
@akhil451
Feb 14 2016 06:41
function destroyer(arr) {
  // Remove all the values
   var arr1=arguments[0];

function found(arr1){
  for(i=0;i<arr1.length;i++)
  {
    for(j=1;j<arguments.length;j++)
    {
      if(arr1[i]===arguments[j]) return false;
    }

  }
}
  return arr1.filter(found);
}

destroyer([3, 5, 1, 2, 2], 2, 3, 5);
bitgrower
@bitgrower
Feb 14 2016 06:42
hey @carpediem1213 -- how goes it ...
DJ
@qualitymanifest
Feb 14 2016 06:42
@akhil451 arguments[0] is arr
akhil
@akhil451
Feb 14 2016 06:42
this function always seems to give an empty array
please help . what am i doing wrong?
bitgrower
@bitgrower
Feb 14 2016 06:43
I would also highly, highly, highly recommend using indexOf & arr.filter for this problem ...
Preetam Kajal Rout
@preetamkajalrout
Feb 14 2016 06:44
@akhil451 :
arguments[0] === arr; //true
arguments[1] === 2; //true
arguments[2] === 3; //true
arguments[3] === 5; //true
akhil
@akhil451
Feb 14 2016 06:45
thanks @preetamkajalrout and @bitgrower
CamperBot
@camperbot
Feb 14 2016 06:45
akhil451 sends brownie points to @preetamkajalrout and @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 179 | @preetamkajalrout | http://www.freecodecamp.com/preetamkajalrout
:star: 519 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 14 2016 06:45
@akhil451 - you are trying to do the work of array.filter twice ... both from arr1.filter, and then also in your for loop
DJ
@qualitymanifest
Feb 14 2016 06:45
@preetamkajalrout basically except arguments[2] === 2; //false it's 3. guessing you just made a typo there
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 14 2016 06:46
Screen Shot 2016-02-14 at 12.46.10 AM.png
Okay this is bizzare…if I do console.log analysis, it seems there are cached string there? I have more than three strings here in my console log while I use only one string...
Preetam Kajal Rout
@preetamkajalrout
Feb 14 2016 06:46
@qualitymanifest : Yes. Typo alert! :smile: Editing it!
Brett
@BLayman
Feb 14 2016 06:47
I'm trying to take a number, convert it into a string, and split it into an array, but whenever I split it, the last item of the array is missing. I don't know what's going wrong. Here's some of the code:
numString = num.toString();
    inputArray = numString.split("");

if you need to see that in context:

function convert(num) {
  var x = "";
  var y = "";
  var z = "";
  var numString = "";
  var inputArray = [];
  var lastDigit = 0;
  var numArray = [x,
                  x+x,
                  x+x+x,
                  x+y,
                  y,
                  y+x,
                  y+x+x,
                  y+x+x+x,
                  x+z];
    numString = num.toString();
    inputArray = numString.split("");
    lastDigit = inputArray.splice(-1,1);
  return inputArray;

  function assignLast(dig){
    x = "I";
    y = "V";
    z = "X";
  return numArray[(dig-1)];

  }

you can ignore the function at the bottom

DJ
@qualitymanifest
Feb 14 2016 06:48
@pkshreeman it will show you console.log outputs for each test FCC uses. if you're just trying to test one function call, use repl.it
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 14 2016 06:49
@qualitymanifest how do I do that?
bitgrower
@bitgrower
Feb 14 2016 06:49
ahhhh ... roman numerals...
DJ
@qualitymanifest
Feb 14 2016 06:50
@pkshreeman run your code here https://repl.it/languages/javascript
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 14 2016 06:50
oh…thanks! @qualitymanifest :)
CamperBot
@camperbot
Feb 14 2016 06:50
pkshreeman sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 959 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Jason
@carpediem1213
Feb 14 2016 06:51
@qualitymanifest that link is great! thanks
CamperBot
@camperbot
Feb 14 2016 06:51
carpediem1213 sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 960 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
bitgrower
@bitgrower
Feb 14 2016 06:59
check this one out, @carpediem1213 -- http://pythontutor.com/javascript.html
DJ
@qualitymanifest
Feb 14 2016 07:03
@BLayman so your problem is that you're using .splice which starts deleting elements at the second argument, which in your case is an index of 1. either way, i can't see where you're going with this, but i can suggest another way of doing this algorithm
E
@efhjones
Feb 14 2016 07:04
@bitgrower I don't thing I've grasped str.replace yet, I thought "" would delete the empty space (by essentially replacing the space with nothing) here but the result I get is r,a,c,e,.,,c,a,r
function noWhiteSpace (notThis, butThis){


}
function palindrome(str) {

  var lowCaseStr = str.toLowerCase("");
  var strIfy;

  strIfy = lowCaseStr.split('').join().replace(/\s+/g,'');
  //.reverse();
//  var returnedstring = strIfy.replace(" ","");
  // strIfy is an array 

return strIfy;
}

palindrome("RACE. CAR");
bitgrower
@bitgrower
Feb 14 2016 07:06
@efhjones ... did you read the MDN page on str.replace ?
"" !== " "
DJ
@qualitymanifest
Feb 14 2016 07:07
bitgrower
@bitgrower
Feb 14 2016 07:08
LOL @qualitymanifest
Pradeep CE
@cepradeep
Feb 14 2016 07:08
@efhjones .replace() works on a string. You need something like
strIfy = lowCaseStr.replace(/\s+/g,'');
Jason
@carpediem1213
Feb 14 2016 07:09
@pradeepce what exactly does that regex do?
bitgrower
@bitgrower
Feb 14 2016 07:09
...there's some brave coding in there @efhjones ...
Brett
@BLayman
Feb 14 2016 07:10
@qualitymanifest Oh, I didn't know that .splice() modified the array, that makes sense. Thanks. I'm open to any suggestions on how to approach the challenge. I was hoping to use my array as a pattern for each digit of the number, substituting different letters into the pattern for different placements of that digit.
CamperBot
@camperbot
Feb 14 2016 07:10
blayman sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 961 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Pradeep CE
@cepradeep
Feb 14 2016 07:10
@carpediem1213 A RegEx simply matches the parts of the string that agree with the pattern. What you do with the match is up to you.
bitgrower
@bitgrower
Feb 14 2016 07:10
help regex
CamperBot
@camperbot
Feb 14 2016 07:10

:point_right: js regex resources [wiki]

Links to useful RegEx resources.

See also: :clipboard: Tutorials | :syringe: Testing | :soccer: Games | :newspaper: Blogs | :package: Software

:pencil: read more about js regex resources on the FCC Wiki

bitgrower
@bitgrower
Feb 14 2016 07:11
TONS of awesome resources for your regex learning consumption ...
Jason
@carpediem1213
Feb 14 2016 07:11
@pradeepce @qualitymanifest thanks
CamperBot
@camperbot
Feb 14 2016 07:11
carpediem1213 sends brownie points to @pradeepce and @qualitymanifest :sparkles: :thumbsup: :sparkles:
:warning: carpediem1213 already gave qualitymanifest points
:star: 326 | @pradeepce | http://www.freecodecamp.com/pradeepce
Pradeep CE
@cepradeep
Feb 14 2016 07:11
@pradeepce If you what that regex does, I think I should have had a capturing group there.
DJ
@qualitymanifest
Feb 14 2016 07:11
@BLayman my way was to create an array of roman numerals and another array of their number equivalents. from there on out you add roman numerals to an array while doing... something... to your number until it gets to 0
bitgrower
@bitgrower
Feb 14 2016 07:11
@BLayman -- it's important to know that splice does TWO things ... it changes the array, AND returns values ... it' a very powerful function ... and NOT to be confused with slice !
Zerka1982
@Zerka1982
Feb 14 2016 07:12
Hi guys, since yesterday I tried to fix my page to be mobile friendly, but I couldn't make it.
Anybody help me please
bitgrower
@bitgrower
Feb 14 2016 07:13
the only candidate I've seen in the algo challenges which require a capturing group is the phone number challenge ... I don't think I used it there, even (but I also didn't try to solve it in 1 single regex, either ... I don't really see the point of doing so -- just makes for unreadable regexes...)
greg
@wearenotgroot
Feb 14 2016 07:13
@Zerka1982 did you tried @media queries stuff?
bitgrower
@bitgrower
Feb 14 2016 07:13
@Zerka1982 -- you are using bootstrap ?
Zerka1982
@Zerka1982
Feb 14 2016 07:13
yes I am using bootstrap
if anybody could check the code with me
DJ
@qualitymanifest
Feb 14 2016 07:14
@bitgrower wanna compare phone number regexes? i think mine is readable :pensive:
Zerka1982
@Zerka1982
Feb 14 2016 07:14
I am little lost ....
because the code is mix of php and html .
DJ
@qualitymanifest
Feb 14 2016 07:14
@Zerka1982 have you looked up bootstraps' docs on their grid system?
Pradeep CE
@cepradeep
Feb 14 2016 07:14
@bitgrower I've been kind of hooked to trying to solve everything in one line of regex, lately :P
DJ
@qualitymanifest
Feb 14 2016 07:14
ah
@Zerka1982 this is a JS room......
Zerka1982
@Zerka1982
Feb 14 2016 07:15
I went to CSS room, but I wasn't able to open it
bitgrower
@bitgrower
Feb 14 2016 07:15

here's the thing ... if you want do do that, you can ... but IN GENERAL...

...it neither improves the readability or maintainability of your code ... imnsho ...

(and can cause you conniptions in trying to change it, should you need to fix a bug ...

Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 14 2016 07:15
@Zerka1982 might be helpful if you remove php components, and keep it simple with HTML, CSS, JS only when you work on FCC challenges.
bitgrower
@bitgrower
Feb 14 2016 07:15
@qualitymanifest -- did you do it one line ? :)
DJ
@qualitymanifest
Feb 14 2016 07:16
@bitgrower indeed. it makes sense to me and i commented it to allow explanation.
Lavesh Chowdhary
@Laveshc
Feb 14 2016 07:17

hi guys i'm stuck on the make object properties private waypoint.. MY Code:- var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

var Bike = function() {

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

this.setGear=function(x){
gear+=x;
};

this.getGear=function()
{
return gear;
};
};

var myCar = new Car();

var myBike = new Bike();

bitgrower
@bitgrower
Feb 14 2016 07:19
... awesome ... well ... I'm not into any kind of regex showdowns, to be honest, but if you want to share, I'm more than willing to sit at your feet and learn ... @qualitymanifest
Pradeep CE
@cepradeep
Feb 14 2016 07:20
@bitgrower Readability apart, it's efficient. It's a subjective choice between the two I guess.
bitgrower
@bitgrower
Feb 14 2016 07:20
@Laveshc -- for the poor eyes of folks who want to help can you follow @camperbot's instructions on formatting your code (and please do note, you need to follow the instructions EXACTLY...not to worry, once you do it once, it will be easy...
George Armstrong
@george-of-croton
Feb 14 2016 07:20

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

// Only change code below this line

switch(val) {
case "alpha":
result = "Adams";
break;
case "bravo":
result = "Boston";
break;
case "charlie":
result = "Chicago";
break;
case "delta":
result = "Denver";
break;
case "echo":
result = "Easy";
break;
case "foxtrot":
result = "Frank";
}

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

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

uriznik
@uriznik
Feb 14 2016 07:20
@Laveshc I think your public functions just need to set/get and not add or subtract
George Armstrong
@george-of-croton
Feb 14 2016 07:21
i need to convert this switch statement into a look up table called lookup and use it to lookup val
how do I lookup val?
bitgrower
@bitgrower
Feb 14 2016 07:21
Readability apart, it's efficient. It's a subjective choice between the two I guess. <<<<--- yep ... there's some great books about writing efficient programs ... programming pearls is one of them (though his examples are rather out of date now)
DJ
@qualitymanifest
Feb 14 2016 07:22
@bitgrower dude you've made it as far (algorithm-wise) within two months, as i have in 6 months. so you don't have to "sit down and learn" from me haha. it's not a "regex showdown", i'm just curious to see what you did, and if you consider mine to be readable.
here i'll PM you
Lavesh Chowdhary
@Laveshc
Feb 14 2016 07:23
@george-of-croton you need to make an object with the properties given in the switch statement
bitgrower
@bitgrower
Feb 14 2016 07:23
...because part of the equation is deciding when it makes sense to spend the time shaving extra microseconds off an algo or saving the amount of programmer time & expense to maintain ...
E
@efhjones
Feb 14 2016 07:23
@bitgrower Is this any closer? This works but I can't figure out how to tell it to replace several things without repeating myself
strIfy = lowCaseStr.replace(/\s+/g,'').replace(".",'');
bitgrower
@bitgrower
Feb 14 2016 07:25
not sure @efhjones ... :(
DJ
@qualitymanifest
Feb 14 2016 07:25
@efhjones replace(/this|that|orthisthing|/g or replace([thisthatorthisthing])/g are two ways of replacing multiple things
uriznik
@uriznik
Feb 14 2016 07:25
@efhjones is this for the palindrome?
E
@efhjones
Feb 14 2016 07:26
@uriznik yeah
ok thanks @qualitymanifest
CamperBot
@camperbot
Feb 14 2016 07:26
efhjones sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 962 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Feb 14 2016 07:26
@efhjones the thing is \s only replaces spaces. you want to replace all non-alphanumerics. there's a regex metacharacter that takes care of all but one of those
E
@efhjones
Feb 14 2016 07:26
OoO
greg
@wearenotgroot
Feb 14 2016 07:27
@efhjones regex is like another language you have to learn the words before you can make a full sentence
DJ
@qualitymanifest
Feb 14 2016 07:27
@efhjones go here http://www.w3schools.com/jsref/jsref_obj_regexp.asp click the link when you find one that sounds good and read the fine print
Pradeep CE
@cepradeep
Feb 14 2016 07:27

@efhjones

strIfy = lowCaseStr.replace(/\s+/g,'');

removes all the whitespaces for me. What is the problem you're facing?

uriznik
@uriznik
Feb 14 2016 07:28
@efhjones you could use a regexp like [^0-9aq-z] which will match any non lowercase or number character
DJ
@qualitymanifest
Feb 14 2016 07:28
@uriznik :facepalm:
greg
@wearenotgroot
Feb 14 2016 07:28
@efhjones here try some rules on the bottom right--->https://regex101.com/
DJ
@qualitymanifest
Feb 14 2016 07:28
@uriznik a. don't provide the solution b. that's wrong
Pradeep CE
@cepradeep
Feb 14 2016 07:28
@efhjones What are you trying to do?
E
@efhjones
Feb 14 2016 07:29

@pradeepce No that works I was trying to condense these two .replace into one:

 strIfy = lowCaseStr.replace(/\s+/g,'').replace(".",'');

but I'll have to take a look at regexs

greg
@wearenotgroot
Feb 14 2016 07:31
@efhjones are you trying to replace a literal . ?
@efhjones because . will match any single character
@efhjones if you wanted a literal . you need to enclosed it in square brackets --> [.]
Jason
@carpediem1213
Feb 14 2016 07:33
function mutation(arr) {
  var match = 0; 
  arr[0] = arr[0].toLowerCase();
  arr[1] = arr[1].toLowerCase();

   for (var j = 0; j < arr[1].length; j++) {
     // for each letter of string arr[1], does it match with string arr[0]? 
     if (arr[0].indexOf(arr[1][j]) !== -1) { 
     //console.log("It's true.", arr[0], arr[1][j]);
     match++; 
        if (match === arr[1].length) { return true; }
     }
     else {
     //console.log("It's false", arr[0], arr[1][j]);
     }
   }
     return false;
}
The previous problem was a single line (a return) so this feels like a lot of lines. How else could I have solved this one?
Pradeep CE
@cepradeep
Feb 14 2016 07:34
@wearenotgroot In his code, it will match . because it's a string. \. is needed only if he is using regex to match.
George Armstrong
@george-of-croton
Feb 14 2016 07:34
@Laveshc could you give an example of what that might look like?
greg
@wearenotgroot
Feb 14 2016 07:35
@pradeepce :smile: yes that why i was asking, what is the intended purpose, this or that :smile:
Zerka1982
@Zerka1982
Feb 14 2016 07:35
Guys , why I can't get access to CSS room o ask for help !
Pradeep CE
@cepradeep
Feb 14 2016 07:35
@carpediem1213 What are you expected to do?
Zerka1982
@Zerka1982
Feb 14 2016 07:35
I tried man times but still I cannot open it.
'many
Pradeep CE
@cepradeep
Feb 14 2016 07:35
@wearenotgroot Cool, regex is starting to be fun :P
Jason
@carpediem1213
Feb 14 2016 07:36
@pradeepce That's the solution, but I was wondering if there are other ways to do it before I move on.
@pradeepce it's called Mutations. You are given two strings ["a", "b"] and you see if string b has all of its letters accounted for in string a
@pradeepce case insensitive
George Armstrong
@george-of-croton
Feb 14 2016 07:37

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

switch(val) {
case "alpha":
result = "Adams";
break;

how would I convert this into a look up table?

Pradeep CE
@cepradeep
Feb 14 2016 07:37
@carpediem1213 Oh, I remember solving it with RegEx (sorry!).
greg
@wearenotgroot
Feb 14 2016 07:38
Jason
@carpediem1213
Feb 14 2016 07:38
@pradeepce Yeah that's just the sort of thing I'm curious to see. Do you have your code?
DJ
@qualitymanifest
Feb 14 2016 07:38
@carpediem1213 rather than reviewing code i'd really recommend trying http://regexone.com/ then reading regex docs to fill in the gaps
Pradeep CE
@cepradeep
Feb 14 2016 07:39
@george-of-croton Hint: Each of your cases should be a key in the object, and the value you want result to have, will be the key's value.
Jason
@carpediem1213
Feb 14 2016 07:39
@qualitymanifest that's cool! I was checking out regex101.com earlier today as well
Pradeep CE
@cepradeep
Feb 14 2016 07:39
@carpediem1213 If you managed to solve it, then you can PM me for the code :)
Jason
@carpediem1213
Feb 14 2016 07:40
@pradeepce yeah, I just posted the solution above. I was proud of it, but it's not as fancy as regex lol
DJ
@qualitymanifest
Feb 14 2016 07:40
@carpediem1213 regex101 is great for testing. regexone is a tutorial website, for getting started
Nick Robson
@nickrobson
Feb 14 2016 07:40
@carpediem1213 Try solving a crossword of regular expressions! :) https://regexcrossword.com/
Jason
@carpediem1213
Feb 14 2016 07:40
@qualitymanifest I will definitely check it out
what does regex stand for
greg
@wearenotgroot
Feb 14 2016 07:41
regular expression
Greg P
@gaperry
Feb 14 2016 07:41
I've been getting "Oops! Something went wrong. Try again later." messages all day. Anyone else getting the same?
Jason
@carpediem1213
Feb 14 2016 07:41
@pradeepce how do I PM you?
Greg P
@gaperry
Feb 14 2016 07:41
Happens when I try to access the Map
Pradeep CE
@cepradeep
Feb 14 2016 07:41
@carpediem1213 Lol, fancy doesn't count. I bet your code is more readable, as @wearenotgroot (?) said earlier.
greg
@wearenotgroot
Feb 14 2016 07:41
@gaperry it's ok the site is in a rehaul/guys and gals are working on it
Pradeep CE
@cepradeep
Feb 14 2016 07:42
@carpediem1213 I did :)
Meghana
@meghanasarikonda
Feb 14 2016 07:42
@gaperry yeah i think it is due to heavy load
E
@efhjones
Feb 14 2016 07:42

oy! I cannot figure out how to use a regex in .replace(). According to this:

str.replace(regexp|substr, newSubStr|function[, flags])

I would have thought this would work:

strIfy = lowCaseStr.replace([^a-z], '')

What am I missing?

Meghana
@meghanasarikonda
Feb 14 2016 07:42