These are chat archives for FreeCodeCamp/HelpJavaScript

8th
Mar 2016
Ariel
@ArielLeslie
Mar 08 2016 00:01
@Jchasee You can do it pretty easily with .reduce()
Danny McCollins
@dmccollins
Mar 08 2016 00:08

Having issues with Counting Cards…so far I have

function cc(card) {
  // Only change code below this line
  if(card==2){count++;return count + ' Bet';}
  else if(card==3){count++;return count + ' Bet';}
  else if(card==4){count++;return count + ' Bet';}
  else if(card==5){count++;return count + ' Bet';}
  else if(card==6){count++;return count + ' Bet';}
  else if(card==7){return count + ' Hold';}
  else if(card==8){return count + ' Hold';}
  else if(card==9){return count + ' Hold';}
  else {count--; return count + ' Hold';}

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

Everything works fine except for the second to last objective, which is supposed to return "1 Bet” for sequence 2, J, 9, 2, 7.

I suppose I’ll try using a switch statement
Ariel
@ArielLeslie
Mar 08 2016 00:17
@dmccollins You should be deciding between "Bet" and "Hold" based off what count is, not off of what card is
sethnejame
@sethnejame
Mar 08 2016 00:18
Anyone else feel like Record Collection lacks a little more description to the task at hand?
Danny McCollins
@dmccollins
Mar 08 2016 00:19
Thanks for the tip @ArielLeslie
CamperBot
@camperbot
Mar 08 2016 00:19
dmccollins sends brownie points to @arielleslie :sparkles: :thumbsup: :sparkles:
:star: 1239 | @arielleslie | http://www.freecodecamp.com/arielleslie
Ulises Rangel
@urangel
Mar 08 2016 00:19
I changed my Profile Lookup code a bit but it didn't seem to do the trick. Could someone nudge me in the right direction please?:
function lookUp(firstName, prop){
// Only change code below this line

for (var i=0; i<contacts.length; i++){
  if (firstName === contacts[i].firstName && prop === contacts[i].prop){
        return contacts[i].prop;
  }
  else if (firstName !== contacts[i].firstName){
    return "No such contact";
  }
  else if (prop !== contacts[i].prop){
    return "No such property";}
  }
// Only change code above this line
}
Marc
@wumpafruits
Mar 08 2016 00:19
Math.floor(Math.random() * (max - min + 1)) + min
Why + min at the end?
Anthony
@anthonybaulo
Mar 08 2016 00:20
Trying to write a switch statement, and I'm having trouble figuring out the syntax error at case 1
function myTest(val) {
  var answer = "";
  // Only change code below this line

  case 1:
    answer = "alpha";
    break;
  case 2:
    answer = "beta";
    break;
  case 3:
    answer = "gamma";
    break;
  case 4:
    answer = "delta";
    break;

  // Only change code above this line  
  return answer;  
}
Marc
@wumpafruits
Mar 08 2016 00:20
Generating Random #s within a range
@anthonybaulo I think you need to include switch(val) in there
Ariel
@ArielLeslie
Mar 08 2016 00:21
@urangel You can't use dot notation with variable names. Variable names must go in bracket notation.
@anthonybaulo is val going to be one of the numbers: 1,2,3, or 4?
Anthony
@anthonybaulo
Mar 08 2016 00:23
@wumpafruits That was it, thanks!
@ArielLeslie That's correct, it accepts 1,2,3, or 4
CamperBot
@camperbot
Mar 08 2016 00:23
anthonybaulo sends brownie points to @wumpafruits and @arielleslie :sparkles: :thumbsup: :sparkles:
:star: 257 | @wumpafruits | http://www.freecodecamp.com/wumpafruits
:star: 1240 | @arielleslie | http://www.freecodecamp.com/arielleslie
Laurent Harel
@Lornz-
Mar 08 2016 00:23
@anthonybaulo you miss the switch in your switch case
Snowysun
@Snowysun
Mar 08 2016 00:23
Can someone help me with Record Collection?```
Ulises Rangel
@urangel
Mar 08 2016 00:24
Thanks! @ArielLeslie . I had it with brackets to begin with but then was advised differently. Can you spot anything else by chance? I've changed all the variables from dot to bracket but it does not fix the issue
CamperBot
@camperbot
Mar 08 2016 00:24
urangel sends brownie points to @arielleslie :sparkles: :thumbsup: :sparkles:
:star: 1241 | @arielleslie | http://www.freecodecamp.com/arielleslie
Snowysun
@Snowysun
Mar 08 2016 00:24
```
Ariel
@ArielLeslie
Mar 08 2016 00:25
@anthonybaulo You forgot to declare your switch block. case only makes sense inside a switch
@urangel else if (prop !== contacts[i].prop){ I suspect that this is your issue. I'm guessing that you need to test whether contacts[i][prop] exists
Snowysun
@Snowysun
Mar 08 2016 00:26
Sorry I keep messing up with trying to paste my code. In Record Collection I know how to do the if statements but I don't get how to do the rest.
Ariel
@ArielLeslie
Mar 08 2016 00:26
@urangel Also, you will only ever test the first contact, because you always return in your for loop, so it will stop on i===0
explain format
CamperBot
@camperbot
Mar 08 2016 00:27

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Ariel
@ArielLeslie
Mar 08 2016 00:27
@Snowysun :point_up:
Ulises Rangel
@urangel
Mar 08 2016 00:27
ohh so i need a console.log instead of return
Snowysun
@Snowysun
Mar 08 2016 00:29
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

    return collection;
  }
  else if (value = "") {
     return collection;
  }
  else {
  return collection;
  }
}

// Alter values below to test your code
update(5439, "tracks", "ABBA");
Not sure what to do inside the if statements.
sethnejame
@sethnejame
Mar 08 2016 00:31
@Snowysun having trouble with this as well. . .we are supposed to take an ID, a PROP, and a VALUE, and do what with them?
Darwin RC
@darwinrc
Mar 08 2016 00:32
@Snowysun @sethnejame first correct the value = it should be ===
Ariel
@ArielLeslie
Mar 08 2016 00:33
@Snowysun What do the instructions tell you the function is supposed to do?
Darwin RC
@darwinrc
Mar 08 2016 00:33
@Snowysun @sethnejame and then if the prop is "tracks" you should add it to the collection object (check out the push method)
Snowysun
@Snowysun
Mar 08 2016 00:34
Update or set the value for the prop.
Darwin RC
@darwinrc
Mar 08 2016 00:34
@Snowysun @sethnejame otherwise set the value
lastly if the value is empty you should delete it from the object
sethnejame
@sethnejame
Mar 08 2016 00:35

@ArielLeslie 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.

"write a function which takes an id, property, and value"
So what does it do once it takes it? updates it? deletes it? Plays catch with it?
Ariel
@ArielLeslie
Mar 08 2016 00:36
@sethnejame I was asking @Snowysun to get them to look at the instructions carefully and see if they could find the answer themselves.
sethnejame
@sethnejame
Mar 08 2016 00:36
@ArielLeslie I'm on the same lesson
Just pointing out that it's a little confusing for a beginner without further clarification
:)
Ariel
@ArielLeslie
Mar 08 2016 00:38
@sethnejame It gives you three different things to do depending on what id, property, and value are.
sethnejame
@sethnejame
Mar 08 2016 00:38
@ArielLeslie Where is ID explained?
Ariel
@ArielLeslie
Mar 08 2016 00:39

@sethnejame

For the given id in collection:

sethnejame
@sethnejame
Mar 08 2016 00:40
@ArielLeslie I see that. . but are we adding more IDs? Removing them? Or only using the IDs that are already in the pre-written collection?
Changing IDs?
Ariel
@ArielLeslie
Mar 08 2016 00:40
@sethnejame If it doesn't tell you to change id, why would you?
sethnejame
@sethnejame
Mar 08 2016 00:40
@ArielLeslie I don't know
It's not clear if we're adding whole entries or what
So
I guess I'm lacking a bird's eye view
lol
Ariel
@ArielLeslie
Mar 08 2016 00:42
@sethnejame I suspect you might need to take a little time away from it and come back and read the entire instructions fresh.
sethnejame
@sethnejame
Mar 08 2016 00:42
@ArielLeslie quite possibly
@ArielLeslie thanks for trying to help :)
CamperBot
@camperbot
Mar 08 2016 00:43
sethnejame sends brownie points to @arielleslie :sparkles: :thumbsup: :sparkles:
:star: 1242 | @arielleslie | http://www.freecodecamp.com/arielleslie
Marc
@wumpafruits
Mar 08 2016 00:43
that's one of the hardest one imo
sethnejame
@sethnejame
Mar 08 2016 00:43
@wumpafruits tell me about it
Marc
@wumpafruits
Mar 08 2016 00:43
i just completed 102/105 challenges...that NOT being one of them
sethnejame
@sethnejame
Mar 08 2016 00:43
I don't blame you
Maybe I'll just do some other ones and come back
once I get some momentum
Marc
@wumpafruits
Mar 08 2016 00:44
yeah that helps me
Danny McCollins
@dmccollins
Mar 08 2016 00:44
Do bracket or dot notation have any advantage over the other when referencing object properties?
Ulises Rangel
@urangel
Mar 08 2016 00:46
bracket best when the properties have spaces @dmccollins
or when using variables but other than that i'm not sure if there is anything else
Danny McCollins
@dmccollins
Mar 08 2016 00:46
Makes sense. Thanks @urangel
CamperBot
@camperbot
Mar 08 2016 00:46
dmccollins sends brownie points to @urangel :sparkles: :thumbsup: :sparkles:
:star: 234 | @urangel | http://www.freecodecamp.com/urangel
rybka02
@rybka02
Mar 08 2016 00:53
Anyone can hel;p with steamroller?
Suprith Aireddy
@sup-rith
Mar 08 2016 00:55
Anyone on the check for palindromes challenge?
rybka02
@rybka02
Mar 08 2016 00:55
I've finished it.
You need help with it?
Suprith Aireddy
@sup-rith
Mar 08 2016 00:55
@rybka02 yes, how do i do it?
rybka02
@rybka02
Mar 08 2016 00:56
Are you familiar with .reverse() split() & join()'
You also need to know how to use regex
Suprith Aireddy
@sup-rith
Mar 08 2016 00:57
yes but i dont know how to take out the extra strings
rybka02
@rybka02
Mar 08 2016 00:57
That's where replace() comes into play
replace(regexhere, replacewithhere)
ie.
var re = /\s/g;
str.replace(re, "");
would replace all spaces with ""
Suprith Aireddy
@sup-rith
Mar 08 2016 00:58
ohh okay
ill go ahed and give it a try
rybka02
@rybka02
Mar 08 2016 00:59
gl!
Suprith Aireddy
@sup-rith
Mar 08 2016 00:59
how do i remove punctuation
rybka02
@rybka02
Mar 08 2016 00:59
\W
Suprith Aireddy
@sup-rith
Mar 08 2016 01:00
wait haha where do you know this info from?
rybka02
@rybka02
Mar 08 2016 01:00
Great place to experiment
Suprith Aireddy
@sup-rith
Mar 08 2016 01:00
okay cool thanks @rybka02
CamperBot
@camperbot
Mar 08 2016 01:00
sup-rith sends brownie points to @rybka02 :sparkles: :thumbsup: :sparkles:
:star: 373 | @rybka02 | http://www.freecodecamp.com/rybka02
rybka02
@rybka02
Mar 08 2016 01:01
Anytime.
Alessandra
@alessandrasp
Mar 08 2016 01:02
Hello everyone!!! Can someone help me with the Seek and Destroy lab?
Suprith Aireddy
@sup-rith
Mar 08 2016 01:02
also, what is the difference between capital W and lowercase w
Marc
@wumpafruits
Mar 08 2016 01:04
I can't help but the Seek and Destroy lab sounds awesome
Kyle Morton
@kmorton1988
Mar 08 2016 01:10
nesting for loops help
camperbot down?
rybka02
@rybka02
Mar 08 2016 01:11
I can help with seek & destroy
Kyle Morton
@kmorton1988
Mar 08 2016 01:12
help Nesting For Loops
CamperBot
@camperbot
Mar 08 2016 01:12

:point_right: challenge nesting for loops [wiki]

Challenge: Nesting For Loops

If you have a multi-dimensional array, you can use the same logic as the prior Challenge to loop through both the array and any sub-arrays. Here is an example:

    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]);
      }
    }

This outputs each sub-element in arr one at a time. Note that for the inner loop, we are checking the .length of arr[i], since arr[i] is itself an array.
:pencil: read more about challenge nesting for loops on the FCC Wiki

Kyle Morton
@kmorton1988
Mar 08 2016 01:12
there it is.
hmm. not quite as helpful as I'd have hoped.
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i=0; i < arr.length; i++){ 
    for (var j=0; j < arr[i].length; j++){
      product = arr[i][j] * arr[i][j] ;
    }

   }
  // Only change code above this line
  return product;
}
so where is my logic flawed here?
it seems to only be multiplyign the LAST item in the LAST array by itself.
which is obviously exactly what I"M telling it to do, but I'm not sure how to get it to go through each one and perform the multiplication on each iteration.
Taz
@bubbaxen
Mar 08 2016 01:17
I you think you need to remove the. Length from your second loop
Alessandra
@alessandrasp
Mar 08 2016 01:17
Hi, @rybka02 .... I don't know that is the problem with this code:

function destroyer(arr) {
var myArr;
myArr = arr.filter(checkValue,arguments1);
myArr = myArr.filter(checkValue,arguments2);
return myArr;
}
function checkValue(value){
return value !== this;
}

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

Kyle Morton
@kmorton1988
Mar 08 2016 01:18
No, it specifcally mentrions the need for the .length to stop the iteration from going on eternally, yet adjusting to how many indexes are in each sub-index
Moisés Man
@moigithub
Mar 08 2016 01:18
@kmorton1988
product = arr[i][j] * arr[i][j] ;
that is wrong
Kyle Morton
@kmorton1988
Mar 08 2016 01:18
yeah, I just can't figure out the logic to make it multiply EACH iteration.
Moisés Man
@moigithub
Mar 08 2016 01:19
@kmorton1988 u storing on product num (exp) 2
and replacing the product value on each iteration
Kyle Morton
@kmorton1988
Mar 08 2016 01:19
oh shit.
you're right.
Moisés Man
@moigithub
Mar 08 2016 01:20
u should
(1*2)
then on next iteration
(1*2)*3
((1*2)*3)*4
(((1*2)*3)*4)*5
Kyle Morton
@kmorton1988
Mar 08 2016 01:21
perfect! thanks that sorted it out.
Taz
@bubbaxen
Mar 08 2016 01:21
The first time stops it
Kyle Morton
@kmorton1988
Mar 08 2016 01:21
thanks @moigithub
CamperBot
@camperbot
Mar 08 2016 01:21
kmorton1988 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 735 | @moigithub | http://www.freecodecamp.com/moigithub
LuciusR11
@LuciusR11
Mar 08 2016 01:23
for (lookUp(firstName, prop); lookUp(firstName) == contacts.firstName && lookUp(prop) !== contacts.prop;){
return contacts.prop;
}
if (lookUp(firstName) !== contacts.firstName){
return "No such contact";
}else if (lookUp(prop) !== contacts.prop){
return "No such property";
}
why does it keep telling me I exceeded the stack size?
sorry it's a little hard to read I don't know how to put it into a code box on the chat.
Darwin RC
@darwinrc
Mar 08 2016 01:24
@LuciusR11 use 3 backticks
``` before and after your code
maybe your for is getting into an infinite loop, you need to check your out condition
LuciusR11
@LuciusR11
Mar 08 2016 01:25
Ok I'll try that.
Moisés Man
@moigithub
Mar 08 2016 01:26

@alessandrasp
add console.log to check if "this" on ur callback is the value u think it should...

function checkValue(value){
    console.log(this);  ////<<<<<<<<< add 
return value !== this;
}

... and probably u need to use an extra variable to hold those values...(2,3)

Darwin RC
@darwinrc
Mar 08 2016 01:27
@LuciusR11 ideally you shouldn't use those strange conditions in a for loop, it's normally used for iterate through a known set of values.
Alessandra
@alessandrasp
Mar 08 2016 01:28
@moigithub It doesn't work! =/
Moisés Man
@moigithub
Mar 08 2016 01:29
@alessandrasp u need to use an extra variable to hold those values...(2,3)
(and remove "this" on ur code)
bryarcole
@bryarcole
Mar 08 2016 01:30
IM at a complete loss at this array challenge
If somsone could please help me
LuciusR11
@LuciusR11
Mar 08 2016 01:30
@darwinrc, yeah I feel like I'm complicating it a bit.
George McCrary
@k8qm
Mar 08 2016 01:31
Help Make Object Properties Private
CamperBot
@camperbot
Mar 08 2016 01:31

:point_right: challenge make object properties private [wiki]

Objects have their own attributes, called properties_, and their own functions, called _methods.

You can use the this keyword to reference public properties and methods of the current objects. However, when You need to create private ones so they are not accessible from the outside of the object you just remove the keyword this from the object property or method declaration and declare it with var so that it is private outside its scope.

var Bike = function() {
  var speed = 100; // private
  function addUnit(value) { // private
    return value + "KM/H";
  }

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

};

Another example:

:pencil: read more about challenge make object properties private on the FCC Wiki

bryarcole
@bryarcole
Mar 08 2016 01:32
This si smy code.

// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray01;

var myData = myArray01;
It makes a hyper link out of the last part..
// Setup
 var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

 // Only change code below this line.
 var myData = myArray[0][2][1];
There!
Moisés Man
@moigithub
Mar 08 2016 01:33
@bryarcole how many elements myArray have ? (on the first level )
bryarcole
@bryarcole
Mar 08 2016 01:34
Haaaa
I miscounted
Sorry, got lost in the shiffule of the commas and brackets
Moisés Man
@moigithub
Mar 08 2016 01:35
sometimes arranging em on multiples lines.. helps
var myArray = [
     [1,2,3],
     [4,5,6],
     [7,8,9], 
     [[10,11,12], 13, 14]
];
Marc
@wumpafruits
Mar 08 2016 01:41
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.getGear = function(change) {
gear += change;};
this.setGear = function() {
return gear;};
};

var myCar = new Car();

var myBike = new Bike();

Now try it yourself! Modify the Bike constructor to have a private property called gear and two public methods called getGear and setGear to get and set that value.

Not sure what to set gear to

Darwin RC
@darwinrc
Mar 08 2016 01:44
@wumpafruits try 1
and remove the + from getGear
Pedro Abel Díaz Sánchez
@coderHook
Mar 08 2016 01:55
help No repeats please
CamperBot
@camperbot
Mar 08 2016 01:55

: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

Cameron
@PyroTheSlayer
Mar 08 2016 01:56

// Example
var firstLetterOfFirstName = "";
var firstName = "Ada";

firstLetterOfFirstName = firstName[0];

// Setup
var firstLetterOfLastName;
var lastName = "Lovelace";

// Only change code below this line
firstLetterOfLastName = lastName[0];

both do teh same thing but on the second one the var isnt set to ""
why does it need to be set to "" on the first one?
why did it put var firstLetterOfFirstName to var firstLetterOfFirstName = "";
Marc
@wumpafruits
Mar 08 2016 01:58
I bet it didn't have to...they just left it that way. but ya i remember wondering that
Cameron
@PyroTheSlayer
Mar 08 2016 01:59
@wumpafruits alright, good to know haha. thanks.
CamperBot
@camperbot
Mar 08 2016 01:59
pyrotheslayer sends brownie points to @wumpafruits :sparkles: :thumbsup: :sparkles:
:star: 259 | @wumpafruits | http://www.freecodecamp.com/wumpafruits
Kyle Morton
@kmorton1988
Mar 08 2016 02:04
got an odd question. Something I can't wrap my head around. In factorialize a number, this is my code:
function factorialize(num) {
  var product = 1;
  for (i = 1; i < num; i++) {
   product = (i +1) * product;
  }
  return product;
}

factorialize(5);
it works fine.
but if I change i=1 to i=0, it still works just fine. Why is that?
oh wait.
cause the first iteration it multplies by 1, not changing the end result...
nvm.
thanks anyway LOL
bitgrower
@bitgrower
Mar 08 2016 02:07
amazing how that works ... when you go to ask a question ... and then try to explain it ... and you go ... "oh duh!"
Kyle Morton
@kmorton1988
Mar 08 2016 02:08
right? haha
the process of asking the quesiton in a way that's understandable, it widens your understanding of the problem, and possibly gives you a method of solving it just by understanding it better
I keep kicking myself for not making an effort to pick up javascript earlier.
this language is amazing
bitgrower
@bitgrower
Mar 08 2016 02:09
which is why I tend to harp on having people try and solve the problem with pencil & paper before they try to code it ...
Kyle Morton
@kmorton1988
Mar 08 2016 02:09
oh man, I can't even imagine.
bitgrower
@bitgrower
Mar 08 2016 02:09
hey @kmorton1988 ... no time like the present ... and it's also improved as a language over time ...
Kyle Morton
@kmorton1988
Mar 08 2016 02:10
Yeah, no kidding. That's where I'm at now.
better late than never
bitgrower
@bitgrower
Mar 08 2016 02:10
"blinking cursor" disease ...
Kyle Morton
@kmorton1988
Mar 08 2016 02:10
And FreeCodeCamp has seriously made a huge difference in my motivation factor
bitgrower
@bitgrower
Mar 08 2016 02:10
"I just GOTTA put some code in there !!!!"
awesome @kmorton1988 ... :)
Mandeep Bhutani
@mandeep
Mar 08 2016 02:25
Hi all I think I'm having a problem with Local Scope and Functions in Javascript, and I'm not sure what I'm doing wrong.
The question is telling me no global myVar variable, however I still get the error even if I define one.
bitgrower
@bitgrower
Mar 08 2016 02:26
post your code @mandeepbhutani --> like this https://github.com/freecodecamp/freecodecamp/wiki/code-formatting
Mandeep Bhutani
@mandeep
Mar 08 2016 02:27

```
function myFunction() {
'use strict';

var myVar = 5;
console.log(myVar);
}
myFunction();

oops
bitgrower
@bitgrower
Mar 08 2016 02:28
good start !!!
Cameron
@PyroTheSlayer
Mar 08 2016 02:28
im having some trouble with the Word Blanks challenge because i dont know what im doing wrong?

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result="the";
result += myAdjective;
result += " ass";
result += myNoun;
result += myVerb;
result += " really";
result += myAdverb;
result += " through the forest";
result += " so as to not disturb the sleeping giant.";

// Your code above this line
return result;
}

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

devonwilson1
@devonwilson1
Mar 08 2016 02:28
can someone help me understand how to set remainder equal to the remainder of 11 divided by 3 using % operator?
Cameron
@PyroTheSlayer
Mar 08 2016 02:28
it says
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
Marc
@wumpafruits
Mar 08 2016 02:29
@PyroTheSlayer it should look something like "My " + myNoun + " " + myAdjective etc
Mandeep Bhutani
@mandeep
Mar 08 2016 02:31
function myFunction() {
  'use strict';

  var myVar = 5;
  console.log(myVar);
}
myFunction();
V Arun Kumar
@arunvkumr
Mar 08 2016 02:31
@PyroTheSlayer you have to make the senence with just the given variables. although you sentence is good, but challenge says only to use the four variables.
Mandeep Bhutani
@mandeep
Mar 08 2016 02:31
@devonwilson1 what problem are you having?
Kyle Morton
@kmorton1988
Mar 08 2016 02:32
var name = 11 % 3
I believe would do it.
Mandeep Bhutani
@mandeep
Mar 08 2016 02:32
@bitgrower im not sure why the question wont let me pass since it doesnt ask for a global var in the problem statement
Cameron
@PyroTheSlayer
Mar 08 2016 02:32

@arunkumrv function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result=myAdjective+myNoun+myVerb+myAdverb;

// Your code above this line
return result;
}

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

still wouldnt take it :/
V Arun Kumar
@arunvkumr
Mar 08 2016 02:32
@PyroTheSlayer you forgot the spaces :smile:
Mandeep Bhutani
@mandeep
Mar 08 2016 02:33
@PyroTheSlayer you need to add strings in there
Marc
@wumpafruits
Mar 08 2016 02:33
@mandeepbhutani do you have to code and then remove a piece of code to pass??
Mandeep Bhutani
@mandeep
Mar 08 2016 02:33
@wumpafruits yeah but i removed the code and still can
cant pass
Cameron
@PyroTheSlayer
Mar 08 2016 02:33

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result="my"+ myAdjective + myNoun + myVerb + myAdverb + " through the forest.";

// Your code above this line
return result;
}

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

Kyle Morton
@kmorton1988
Mar 08 2016 02:33
Help Check for Palindromes
CamperBot
@camperbot
Mar 08 2016 02:33

:point_right: algorithm check for palindromes [wiki]

Explanation:

Our goal for solving this problem is tidying up the string passed in, and checking whether it is in fact a palindrome.

  • If you are unsure of what a palindrome is, it is a word or phrase that when reversed spells the same thing forwards or backwards. A simple example is mom, when you reverse the letters, it spells the same thing! Another example of a palindrome is race car. When we take out anything that is not a character it becomes racecar which is the same spelled forwards or backwards!

Once we have determined whether it is a palindrome or not we want to return either true or false based on our findings.

:pencil: read more about algorithm check for palindromes on the FCC Wiki

Cameron
@PyroTheSlayer
Mar 08 2016 02:33
the spaces are in the WordBlanks variable down below
Marc
@wumpafruits
Mar 08 2016 02:34
@PyroTheSlayer you need a word in between each
V Arun Kumar
@arunvkumr
Mar 08 2016 02:34
@PyroTheSlayer something like.. result = firstWord + " " + secondWord'
for all the words
Mandeep Bhutani
@mandeep
Mar 08 2016 02:34
nevermind all. i refreshed my browser and was able to pass
must have been a bug
Marc
@wumpafruits
Mar 08 2016 02:34
"My " + myAdjective + " hairy " + myNoun ...etc.
Cameron
@PyroTheSlayer
Mar 08 2016 02:36

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result="my"+ myAdjective + " ass"+ myNoun + " really" + myVerb + " through the forest"+ myAdverb;

// Your code above this line
return result;
}

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

:(
Marc
@wumpafruits
Mar 08 2016 02:36
mind your spaces between words...beginning AND end of the word
Cameron
@PyroTheSlayer
Mar 08 2016 02:37
@wumpafruits thaaaaaaaaaaaanks
that shouldnt have been so painful lmao
cannelflow
@cannelflow
Mar 08 2016 02:37
@PyroTheSlayer you need to give spacing
like a+" "+b
Cameron
@PyroTheSlayer
Mar 08 2016 02:38
i guess it didnt account for teh spaces i put in the wordBlanks at the bottom?
Marc
@wumpafruits
Mar 08 2016 02:38
nope
Cameron
@PyroTheSlayer
Mar 08 2016 02:39
@wumpafruits @arunkumrv thanks again guys :)
CamperBot
@camperbot
Mar 08 2016 02:39
pyrotheslayer sends brownie points to @wumpafruits and @arunkumrv :sparkles: :thumbsup: :sparkles:
:warning: pyrotheslayer already gave wumpafruits points
:star: 307 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Marc
@wumpafruits
Mar 08 2016 02:39
@PyroTheSlayer i had the same problem initially and then redid the exercise 2-3 times for mastery.
also my advice is work within chrome's console "ctrl-shift-i" for added practice
make your variables "var myNoun =" etc and then practice with concatenating strings n shit
i suppose you could use notepad++ or codepen.io also
Cameron
@PyroTheSlayer
Mar 08 2016 02:41
@wumpafruits how much coding (like challenge wise) do you suggest i do every day? because without taking notes it feels like im not absorbing all of the information being thrown at me.
ive just been doing these lessons whenever i have time
Marc
@wumpafruits
Mar 08 2016 02:42
it helped me a lot to 1.) take notes and read through them every so often 2.) to code on my own...make my own functions, etc.
id recommend at least 1 hour per day of exercises and another hour of writing your own shit
Alex N.
@N0bl3
Mar 08 2016 02:48
do you think it is "safe" to use ES6 features in codepen?
Cameron
@PyroTheSlayer
Mar 08 2016 02:50
@wumpafruits so ive begun practicing in code pen and it seems that the writing isnt showing up on the right? like ive set my variables and everything but its not showing the console like the challenges do. is there an addon i have to use (like BootStrap in HTML)
Marc
@wumpafruits
Mar 08 2016 02:51
I actually don't know about codepen...haven't tried practicing in there since using just html&css.
I've just been using my browser for JS practice
Theresa
@decgal
Mar 08 2016 02:59
so, i'm doing the record collection challenge, and I got "range error: maximum call stack exceeded" um what?
Danny McCollins
@dmccollins
Mar 08 2016 03:00
@decgal Read this: http://goo.gl/idsvSb
Lucky charm
@luckycharm223
Mar 08 2016 03:01
What am I doing wrong ?
Alex N.
@N0bl3
Mar 08 2016 03:01
@wumpafruits and how is the support for the new standard in browser? is it fine to use it now? I use it on server a lot
Lucky charm
@luckycharm223
Mar 08 2016 03:01
'
'''
CamperBot
@camperbot
Mar 08 2016 03:01
:bulb: to format code use backticks! ``` more info
Lucky charm
@luckycharm223
Mar 08 2016 03:02
'''var remainder; 11 % 3= 2;
'''
CamperBot
@camperbot
Mar 08 2016 03:02
:bulb: to format code use backticks! ``` more info
Danny McCollins
@dmccollins
Mar 08 2016 03:02
@luckycharm223 The backtick is the button next to 1
``` != ‘''
Lucky charm
@luckycharm223
Mar 08 2016 03:03
@dmccollins lol I know, I'm on my phone
Danny McCollins
@dmccollins
Mar 08 2016 03:03
Ah. sorry ‘bout that
rybka02
@rybka02
Mar 08 2016 03:04
Anyone stuck?
bryarcole
@bryarcole
Mar 08 2016 03:04
Not right now lol
Lucky charm
@luckycharm223
Mar 08 2016 03:04
var remainder; 11 % 3= 2;
What am I missing here?
asaki444
@asaki444
Mar 08 2016 03:05
``` 

function titleCase(str) {
var string = str.split(' ');
var a;
var b;
var c;
var entire = "";

for (var i = 0; i < string.length;i++){
a = string[i].charAt(0).toUpperCase();
b = string[i].substring(1).toLowerCase();
c = a + b;
entire += c + " ";

}
return entire;
}

titleCase("sHoRt AnD sToUt") ;

``` it runs but it wont let me go to the next lesson
bryarcole
@bryarcole
Mar 08 2016 03:05
I think it should be
var remainder = 11 % 3;
asaki444
@asaki444
Mar 08 2016 03:05
i am on title case a sentence
Marc
@wumpafruits
Mar 08 2016 03:05
^
bryarcole
@bryarcole
Mar 08 2016 03:05
that will give you two inside of the remainder
Marc
@wumpafruits
Mar 08 2016 03:05
yeah u just do 11%3 or set the var to 11%3
bryarcole
@bryarcole
Mar 08 2016 03:05
remainder variable I mean
prestonk25
@prestonk25
Mar 08 2016 03:07
"Inside function fun1, assign 5 to oopsGlobal without using the var keyword." <-- Im confused at how I would do this?
rybka02
@rybka02
Mar 08 2016 03:07
@asaki444 Can you fix the code so it displays properly?
var is a keyword
var pres = 5;
prestonk25
@prestonk25
Mar 08 2016 03:08
But i can't use it?
rybka02
@rybka02
Mar 08 2016 03:08
or you can do pres = 5; (without var keyword)
prestonk25
@prestonk25
Mar 08 2016 03:08
This message was deleted
CamperBot
@camperbot
Mar 08 2016 03:08
:bulb: to format code use backticks! ``` more info
Theresa
@decgal
Mar 08 2016 03:08
@dmccollins so i don't really know what i'm looking at :/
prestonk25
@prestonk25
Mar 08 2016 03:08
```function fun1(oopsGlobal ) {
// Assign 5 to oopsGlobal Here
rybka02
@rybka02
Mar 08 2016 03:08
yes. Gobal is simply saying scope
So. Imagine this
Danny McCollins
@dmccollins
Mar 08 2016 03:09
@decgal The point was to direct you to an external resource. Have you tried Googling the error message and looking through the results?
rybka02
@rybka02
Mar 08 2016 03:09
Imagine a shopping cart.
With a box inside it.
Theresa
@decgal
Mar 08 2016 03:09
lol i've googled for days. nothing... i have no clue what i'm doing
prestonk25
@prestonk25
Mar 08 2016 03:09
When i set function fun1(oopsGlobal = 5) The editor flags it as wrong.
Lucky charm
@luckycharm223
Mar 08 2016 03:09
@bryarcole i tried, not working
rybka02
@rybka02
Mar 08 2016 03:10
Err.. ok--- nvm seems like im talking to myself---
Theresa
@decgal
Mar 08 2016 03:10
anyway, thanks, @dmccollins.
CamperBot
@camperbot
Mar 08 2016 03:10
decgal sends brownie points to @dmccollins :sparkles: :thumbsup: :sparkles:
:star: 90 | @dmccollins | http://www.freecodecamp.com/dmccollins
Theresa
@decgal
Mar 08 2016 03:10
@dmccollins thanks for helping
CamperBot
@camperbot
Mar 08 2016 03:10
decgal sends brownie points to @dmccollins :sparkles: :thumbsup: :sparkles:
:warning: decgal already gave dmccollins points
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:10
anyone done with the bonfire Friendly Date Ranges?
rybka02
@rybka02
Mar 08 2016 03:10
Who needs help?
Danny McCollins
@dmccollins
Mar 08 2016 03:12
No prob @decgal
asaki444
@asaki444
Mar 08 2016 03:13
function titleCase(str) {
  var string = str.split(' ');
  var a;
  var b;
  var c;
  var entire = "";

 for (var i = 0; i < string.length;i++){
    a = string[i].charAt(0).toUpperCase();
    b = string[i].substring(1).toLowerCase();
    c = a + b;
    entire += c + " "; 

  }
  return entire;
  }

titleCase("sHoRt AnD sToUt") ;
rybka02
@rybka02
Mar 08 2016 03:13
@prestonk25 Assign oopsGlobal a value inside and outside the function
Lucky charm
@luckycharm223
Mar 08 2016 03:14
Thanks @bryarcole
CamperBot
@camperbot
Mar 08 2016 03:14
luckycharm223 sends brownie points to @bryarcole :sparkles: :thumbsup: :sparkles:
:star: 179 | @bryarcole | http://www.freecodecamp.com/bryarcole
rybka02
@rybka02
Mar 08 2016 03:17
@asaki444 Your last loop adds an extra space at end
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:17
@rybka I need help
rybka02
@rybka02
Mar 08 2016 03:18
And your colon is one space over on titleCase("sHoRt AnD sToUt") ;
Sure., what's up Sid?
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:19
with the bonfire Friendly Date Ranges
Franco Talarico
@francotalarico
Mar 08 2016 03:19
Hi, i'm stuck in "Falsy bouncer", somebody can help
function bouncer(arr) {
        // Don't show a false ID to this bouncer.
        var remove = [];
        var counter = -1;
        for(var i = 0; i < arr.length; i++){
            if(arr[i] === ""){
              arr.splice(i, 1);
            }
          if(arr[i] === 0){
              arr.splice(i, 1);
            }
          if(typeof(arr[i]) == "object"){
              arr.splice(i, 1);
            }
            if(typeof(arr[i]) !== "number" && typeof(arr[i]) !== "string"){
              arr.splice(i, 1);
            }
        }

        console.log(arr);
        return arr;
    }

bouncer([7, "ate", "", false, 9]);
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:19
I will post my really long code here now:
function friendly(arr) {

  var date=["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"];
  var dateName=["1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th", "13th", "14th", "15th", "16th", "17th", "18th", "19th", "20th", "21st", "22nd", "23rd", "24th","25th", "26th", "27th", "28th", "29th", "30th", "31st"];

  var month=["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"];
  var monthName=["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "Nuvember", "December"];

  var arr1=[];
  var arr2=[];

  arr1=arr[0].split("-");
  var arr1y=arr1[0];
  var arr1m=arr1[1];
  var arr1d=arr1[2];

  arr2=arr[1].split("-");
  var arr2y=arr2[0];
  var arr2m=arr2[1];
  var arr2d=arr2[2];  

  var retdate1=[];
  var retdate2=[];

  var ret1d=dateName[date.indexOf(arr1d)];
  var ret2d=dateName[date.indexOf(arr2d)];
  var ret1m=monthName[month.indexOf(arr1m)];
  var ret2m=monthName[month.indexOf(arr2m)];
  var ret1y=arr1y;
  var ret2y=arr2y;

  retdate1=ret1m+" "+ret1d+", "+ret1y;
  retdate2=ret2m+" "+ret2d+", "+ret2y;

  if(arr1y==="2016" && arr2y==="2016") {
  retdate1=ret1m+" "+ret1d;
  retdate2=ret2d;
  }
  else if(arr1y==="2016" && arr2y==="2017") {
    retdate1=ret1m+" "+ret1d;
  retdate2=ret2m+" "+ret2d;
  }
  else if(arr1y===arr2y) {
    retdate1=ret1m+" "+ret1d+", "+ret1y;
  retdate2=ret2m+" "+ret2d;
  }

  else if(arr1d===arr2d||arr1m===arr2m||arr1y===arr2y) {
  retdate1=ret1m+" "+ret1d+", "+ret1y;
  }


  var retarr=[];
  retarr.push(retdate1);
  retarr.push(retdate2);


  return retarr;
}

friendly(["2022-09-05", "2023-09-05"]) ;
@rybka02
rybka02
@rybka02
Mar 08 2016 03:19
@francotalarico Try to learn filter()
Franco Talarico
@francotalarico
Mar 08 2016 03:20
@rybka02 I'll do that right now! thanks
CamperBot
@camperbot
Mar 08 2016 03:20
francotalarico sends brownie points to @rybka02 :sparkles: :thumbsup: :sparkles:
:star: 374 | @rybka02 | http://www.freecodecamp.com/rybka02
Amir Eskandari
@AmirEskandari87
Mar 08 2016 03:21
hey everybody - working on the "Check for Palindromes" problem and I just wanted to check and see if anybody can advise me on how to make my solution "better". It passed the challenge but I just wanted to make sure that this is the recommended way to solve the problem. Here is my code:
function palindrome(str) {
 str = str.toLowerCase();
 str = str.replace(/ |,|\.|\(|\)|-|:|_/g,"");
  var word = [];
 wordFlip = wordFlip = str.split("").reverse().join("");
 wordFlip = wordFlip.replace(/ |,|\.|\(|\)|-|:\_/g,"");
 wordFlip = wordFlip.toLowerCase();
  if (wordFlip === str){
  return true;
  } else {
    return false;
  }
}
rybka02
@rybka02
Mar 08 2016 03:23
@sidkrip So what's the problem?
Amir Eskandari
@AmirEskandari87
Mar 08 2016 03:23
removed typo in line 5 with duplicate wordFlip =.
Moisés Man
@moigithub
Mar 08 2016 03:24
u have some duplicated code there...
asaki444
@asaki444
Mar 08 2016 03:24
@AmirEskandari87 because i add a space
Moisés Man
@moigithub
Mar 08 2016 03:24
when ur code "reach" wordFlip.. it already IS replaced and lowercased... since its a copy of str @AmirEskandari87
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:24
some inputs are not giving the correct putputs
@rybka02
Amir Eskandari
@AmirEskandari87
Mar 08 2016 03:25
@asaki444 what?
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:25
wiki Inventory Update
CamperBot
@camperbot
Mar 08 2016 03:25

:point_right: algorithm inventory update [wiki]

Problem Explanation:

  • Look through an array of new products, in the format: [quantity, name]
  • Return an array containing updated quantities for each item that already existed, and any new products
:pencil: read more about algorithm inventory update on the FCC Wiki
Amir Eskandari
@AmirEskandari87
Mar 08 2016 03:25
@moigithub AH! you are right, I see that now..
rybka02
@rybka02
Mar 08 2016 03:26
@sidkrip I just tried it and I got September 5th, 2022,September 5th, 2023
Amir Eskandari
@AmirEskandari87
Mar 08 2016 03:26
@moigithub That entire line is redundant, it's been removed.
rybka02
@rybka02
Mar 08 2016 03:27
Is there supposed to be a space in there?
Amir Eskandari
@AmirEskandari87
Mar 08 2016 03:27
@moigithub That looks better to me now, thanks!
CamperBot
@camperbot
Mar 08 2016 03:27
amireskandari87 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 736 | @moigithub | http://www.freecodecamp.com/moigithub
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:27
@rybka02 I cant get two of the desired outputs from these inputs:
 friendly(["2018-01-13", "2018-01-13"]) should return ["January 13th, 2018"].
friendly(["2022-09-05", "2023-09-04"]) should return ["September 5th, 2022","September 4th"].
@rybka02 that one is correct
rybka02
@rybka02
Mar 08 2016 03:28
ok those are situational problems
same date and 2nd date is prior to first date
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:29
yep. I have included every case in the if else but some are not working I guess, because of the order of the if else statements maybe
rybka02
@rybka02
Mar 08 2016 03:29
so basically if [date1] = [date2] then just reply with [date1]
Alex N.
@N0bl3
Mar 08 2016 03:29
@rybka02 there is space everywhere
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:29
@rybka02 yep
and even though I included this case in the second last if else, I cant get the output
*last
rybka02
@rybka02
Mar 08 2016 03:31
make that if go first
it's because it's never reaching it
V Arun Kumar
@arunvkumr
Mar 08 2016 03:31
@AmirEskandari87 instead of str = str.replace(/ |,|\.|\(|\)|-|:\_/g,""); you can also use this str = str.replace(/[\s\W\d]/g,''); it removes all the whitespaces, numbers and special characters :smile:
rybka02
@rybka02
Mar 08 2016 03:31
you want specific examples to go first and catch all go last
Amir Eskandari
@AmirEskandari87
Mar 08 2016 03:32
@arunkumrv That's exactly what I was looking for!
rybka02
@rybka02
Mar 08 2016 03:33
\W doesn't include digits
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:33
@rybka02 cant get three desired outputs by placing that if in the first position.
V Arun Kumar
@arunvkumr
Mar 08 2016 03:33
@rybka02 thats why \d.
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:33
I guess I will have to try switch
rybka02
@rybka02
Mar 08 2016 03:35
the if works
Just place it before your other if statements
@sidkrip ```
 if(arr1y===arr2y) {
    retdate1=ret1m+" "+ret1d+", "+ret1y;
  retdate2=ret2m+" "+ret2d;
  }

  else if(arr1y==="2016" && arr2y==="2016") {
  retdate1=ret1m+" "+ret1d;
  retdate2=ret2d;
  }
  else if(arr1y==="2016" && arr2y==="2017") {
    retdate1=ret1m+" "+ret1d;
  retdate2=ret2m+" "+ret2d;
  }
It works, try it.
who elseis stuck
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:39
@rybka02 okay so I did this:
if(arr1d===arr2d||arr1m===arr2m||arr1y===arr2y) { 
    retdate1=ret1m+" "+ret1d+", "+ret1y; } 
  else if(arr1y===arr2y) { 
    retdate1=ret1m+" "+ret1d+", "+ret1y; 
    retdate2=ret2m+" "+ret2d; } 
  else if(arr1y==="2016" && arr2y==="2016") { 
    retdate1=ret1m+" "+ret1d; retdate2=ret2d; } 
  else //if(arr1y==="2016" && arr2y==="2017") 
  { 
    retdate1=ret1m+" "+ret1d; retdate2=ret2m+" "+ret2d; }
and it did not work
Franco Talarico
@francotalarico
Mar 08 2016 03:39
Guys, do you know why if I use a filter in an array that contain a null value; typeof(elem) !== "object" don't filter it?
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:40
@francotalarico which challenge are you stuck at?
Franco Talarico
@francotalarico
Mar 08 2016 03:40
@sidkrip in Falsy Bouncer! This is my code:
function bouncer(arr) {
        // Don't show a false ID to this bouncer.

        var newArr = arr.filter(function(elem){
         return (typeof(elem) == "string" || typeof(elem) == "number") && (elem !== "") && (elem !== 0) && (typeof(elem) !== "object");
        });

        return newArr;
    }

bouncer([1, null, null, null, NaN, 2, undefined]);
V Arun Kumar
@arunvkumr
Mar 08 2016 03:41
@AmirEskandari87 Take a look.
function palindrome(str) {
 str = str.toLowerCase().replace(/[\s\W\d]/g,'');
 var wordFlip = str.split('').reverse().join('');
    return wordFlip === str;
}
palindrome("A car, a man, a marca.");
rybka02
@rybka02
Mar 08 2016 03:42
@francotalarico Why all those returns? Just do return elem;
V Arun Kumar
@arunvkumr
Mar 08 2016 03:43
@francotalarico try with boolean objects it's much easier with them and also the challenge says you have to use boolean objects. :smiley:
here you can learn more about boolean objects.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:43
@francotalarico its unnecessarily long.
yes, as @arunkumrv said, read that up and you will know what to change exactly
@rybka02 code still not working
rybka02
@rybka02
Mar 08 2016 03:44
function friendly(arr) {

  var date=["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"];
  var dateName=["1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th", "13th", "14th", "15th", "16th", "17th", "18th", "19th", "20th", "21st", "22nd", "23rd", "24th","25th", "26th", "27th", "28th", "29th", "30th", "31st"];

  var month=["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"];
  var monthName=["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "Nuvember", "December"];

  var arr1=[];
  var arr2=[];

  arr1=arr[0].split("-");
  var arr1y=arr1[0];
  var arr1m=arr1[1];
  var arr1d=arr1[2];

  arr2=arr[1].split("-");
  var arr2y=arr2[0];
  var arr2m=arr2[1];
  var arr2d=arr2[2];  

  var retdate1=[];
  var retdate2=[];

  var ret1d=dateName[date.indexOf(arr1d)];
  var ret2d=dateName[date.indexOf(arr2d)];
  var ret1m=monthName[month.indexOf(arr1m)];
  var ret2m=monthName[month.indexOf(arr2m)];
  var ret1y=arr1y;
  var ret2y=arr2y;

  retdate1=ret1m+" "+ret1d+", "+ret1y;
  retdate2=ret2m+" "+ret2d+", "+ret2y;


 if(arr1y===arr2y) {
    retdate1=ret1m+" "+ret1d+", "+ret1y;
  retdate2=ret2m+" "+ret2d;
  }

  else if(arr1y==="2016" && arr2y==="2016") {
  retdate1=ret1m+" "+ret1d;
  retdate2=ret2d;
  }
  else if(arr1y==="2016" && arr2y==="2017") {
    retdate1=ret1m+" "+ret1d;
  retdate2=ret2m+" "+ret2d;
  }


  else if(arr1d===arr2d||arr1m===arr2m||arr1y===arr2y) {
  retdate1=ret1m+" "+ret1d+", "+ret1y;
  }


  var retarr=[];
  retarr.push(retdate1);
  retarr.push(retdate2);


  return retarr;
}
returns January 13th, 2018,January 13th
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:45
@rybka02 I just remembered, the last statement in an if else sequence should be an "else" and not an "else if"
that is one mistake
rybka02
@rybka02
Mar 08 2016 03:45
dont have to have else
Try the code i posted above.. which one does it fail?
Ammar Ali Shah
@AmmarAliShah
Mar 08 2016 03:46
A little starting guide for "Diif Two Arrays"?
rybka02
@rybka02
Mar 08 2016 03:46
i just moved that one if statement to top
Amir Eskandari
@AmirEskandari87
Mar 08 2016 03:46
@arunkumrv str.replace(/[\s\W\d]/g,'') doesn't grab the "" character, so I threw in a "| ":
Franco Talarico
@francotalarico
Mar 08 2016 03:46
I just tried with return elem like @rybka02, and it works, I will try to understand why! thanks
Amir Eskandari
@AmirEskandari87
Mar 08 2016 03:47
"|_"
CamperBot
@camperbot
Mar 08 2016 03:47
:warning: francotalarico already gave rybka02 points
rybka02
@rybka02
Mar 08 2016 03:47
it's simple franco
CamperBot
@camperbot
Mar 08 2016 03:47
francotalarico sends brownie points to @rybka02 :sparkles: :thumbsup: :sparkles:
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:47
@rybka02 it fails three inputs
rybka02
@rybka02
Mar 08 2016 03:47
which 3
@francotalarico filter returns either true or false
when you return elem (null) it returns false
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:48
@rybka02
friendly(["2016-07-01", "2016-07-04"]) should return ["July 1st","4th"]. 
friendly(["2018-01-13", "2018-01-13"])  should return ["January 13th, 2018"]
friendly(["2022-09-05", "2023-09-04"]) should return ["September 5th, 2022","September 4th"].
Amir Eskandari
@AmirEskandari87
Mar 08 2016 03:48
@arunkumrv Thank you for the advice!
CamperBot
@camperbot
Mar 08 2016 03:48
amireskandari87 sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 309 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Amir Eskandari
@AmirEskandari87
Mar 08 2016 03:49
@arunkumrv Weird that it doesn't get the underscore, but easy fix.
rybka02
@rybka02
Mar 08 2016 03:49
ok so your if statement works., it;s your output
you don't need the 2nd date
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:49
yes, if statements are correct. but i dont know why it isnt producing the correct output
V Arun Kumar
@arunvkumr
Mar 08 2016 03:50
@AmirEskandari87 ya i forgot about underscore, it doesn't take underscore and it should take " i dont know why it's not working ffor you. wierd
Sidharth Kriplani
@sidkrip
Mar 08 2016 03:50
@rybka02 and using my if else order, only two outputs are incorrect
V Arun Kumar
@arunvkumr
Mar 08 2016 03:51
@AmirEskandari87 for underscore you can use / inside [].. like [\d\s\W\].
Amir Eskandari
@AmirEskandari87
Mar 08 2016 03:51
@arunkumrv yeah. The succinct solution you sent is great. Thanks again.
CamperBot
@camperbot
Mar 08 2016 03:51
amireskandari87 sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:warning: amireskandari87 already gave arunkumrv points
rybka02
@rybka02
Mar 08 2016 03:52
sending you PM sid
V Arun Kumar
@arunvkumr
Mar 08 2016 03:52
ah wait a sec /_ inside [].. like [\d\s\W\_]
there you go @AmirEskandari87
you're welcome. happy coding :smile:
ah it should be /_ inside [].
Amir Eskandari
@AmirEskandari87
Mar 08 2016 03:53
@arunkumrv I used: replace(/[\s\W|_]/g
used the 'or'
is that not correct?
prestonk25
@prestonk25
Mar 08 2016 03:53

```// Declare your variable here
var myGlobal = 10

function fun1(oopsGlobal) {
// Assign 5 to oopsGlobal Here
}
fun1(5)
// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}
```

It's saying "oopsGlobal should have a value of 5"???
V Arun Kumar
@arunvkumr
Mar 08 2016 03:54
@AmirEskandari87 ya it's correct or you can just use _ instead of or| i think even that should work
Amir Eskandari
@AmirEskandari87
Mar 08 2016 03:54
@arunkumrv Awesome.
Daniel Bashir
@db7894
Mar 08 2016 04:00
Hi, I'm on the Profile Lookup challenge and can't really think of what conditions I should have in my function... Could anyone help me out?
V Arun Kumar
@arunvkumr
Mar 08 2016 04:01
@prestonk25 instead of function fun1(oopsGlobal) inside fun1 assign 5 to oopsGlobal.
@db7894 post you code
Daniel Bashir
@db7894
Mar 08 2016 04:04
I actually did put something in but it's not really working, I'll post it
//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
  if (firstName == contacts[firstName] && prop == contacts[prop]) {
    return prop;
  } else {
    return "No such property";
  }
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
V Arun Kumar
@arunvkumr
Mar 08 2016 04:07
@db7894 there are four entires in your contacts, you need to access all four one by one.
Daniel Bashir
@db7894
Mar 08 2016 04:07
Did something wrong with the loop, fixed it up:
  if (firstName == contacts[firstName] && prop == contacts[prop]) {
    return contacts[prop];
  } else if (firstName !== contacts[firstName]) {
    return "No such contact";
  } else if (prop !== contacts[prop]) {
    return "No such property";
V Arun Kumar
@arunvkumr
Mar 08 2016 04:07
@db7894 i dont see any loop :smile:
Sidharth Kriplani
@sidkrip
Mar 08 2016 04:07
wiki Friendly Date Ranges
CamperBot
@camperbot
Mar 08 2016 04:07

:point_right: algorithm friendly date ranges [wiki]

Problem Explanation:

  • Create a program that will take two dates and convert them into a more easy to understand date such as January 1st, 2017. It will also check the difference between them, and handles cases with no difference, more than a day, more than a month, more than a year, and more than a month and less than a year respectively.
:pencil: read more about algorithm friendly date ranges on the FCC Wiki
Daniel Bashir
@db7894
Mar 08 2016 04:07
*if statement
@arunkumrv I'm not sure what you mean by accessing them one by one. I'm just supposed to check if firstName and prop correspond to any valid properties
It's still not working though
V Arun Kumar
@arunvkumr
Mar 08 2016 04:10
@db7894 you have an array and you need to add all the elements in the array to calculate the sum. how would you do it? you need something which will automatically increment and get the next value.. same goes here you have four entries you need to access of them and compare with your variables.
^suppose you have*
Daniel Bashir
@db7894
Mar 08 2016 04:11
@arunkumrv I see what you're getting at, but I don't see how it can be utilized here.
Suprith Aireddy
@sup-rith
Mar 08 2016 04:12
Can someone help me with the check for palindromes challenge?
function palindrome(str) {
  // Good luck!
  var newString = str.replace(/\W+|_/g,"");

  var endIndex = newString.length -1;
  var backwards = "";
  for(var begin = endIndex; begin >=0; begin--){
    backwards += newString[begin];
  }
  if(backwards === newString){
    return true;
  }
  return false;
}



palindrome("eye");
V Arun Kumar
@arunvkumr
Mar 08 2016 04:15
@db7894 your second else-if condition says no such contact. you have to ask all the person's name to say that the contact doesn't exist. it's like you are asking 4 random strangers for their name and after asking just the first guy you said no such contact.
@db7894 use for loop to access the elements of array. :smile:
Daniel Bashir
@db7894
Mar 08 2016 04:16
@arunkumrv Yes, but there's nothing I can refer to so that I can check through the contacts that the information is stored under
@arunkumrv I see that I would have to check all 4 contacts for the properties but I don't have the remotest idea of what I would put in my loop in order to do that
@arunkumrv Would I use something like contacts.length?
Sidharth Kriplani
@sidkrip
Mar 08 2016 04:19
thanks @rybka02
CamperBot
@camperbot
Mar 08 2016 04:19
sidkrip sends brownie points to @rybka02 :sparkles: :thumbsup: :sparkles:
:star: 375 | @rybka02 | http://www.freecodecamp.com/rybka02
V Arun Kumar
@arunvkumr
Mar 08 2016 04:19
@db7894 ya.. we are here for your help
yes use contacts.length
@db7894 the array/JSON starts at index 0. so start form i = 0
and it ends at 3. but contacts.length returns total values in the array. it would return 4
Daniel Bashir
@db7894
Mar 08 2016 04:22
@arunkumrv This is what I have now:
for (var i = 0; i < contacts.length; i++) {
      if (firstName == contacts[firstName] && prop == contacts[prop]) {
        return contacts[prop];
      } else if (firstName !== contacts[firstName]) {
        return "No such contact";
      } else if (prop !== contacts[prop]) {
        return "No such property";
      }
    }
V Arun Kumar
@arunvkumr
Mar 08 2016 04:23
@db7894 looks great. now you see the array/JSON index starts at 0. so the first entry is in index 0
it is stored like. contacts[0]= { "firstName": "Akira", "lastName": "Laine", "number": "0543236543", "likes": ["Pizza", "Coding", "Brownie Points"] }
same for all the other entries
Daniel Bashir
@db7894
Mar 08 2016 04:24
@arunkumrv Yeah I see that. It still doesn't seem to be working though... I can't figure out what else it needs unless it's because "prop" isn't something I can search with
Wait I think I thought of something
DJ
@qualitymanifest
Mar 08 2016 04:25
@sup-rith idk if you're still working on it but, you just need to lowercase newString when you initialize it
Daniel Bashir
@db7894
Mar 08 2016 04:27
@arunkumrv Changed it to this but still won't work
function lookUp(firstName, prop){
// Only change code below this line
    for (var i = 0; i < contacts.length; i++) {
      if (firstName == contacts[firstName] && contacts[i].hasOwnProperty(prop)) {
        return contacts[prop];
      } else if (firstName !== contacts[firstName]) {
        return "No such contact";
      } else if (prop !== contacts[prop]) {
        return "No such property";
      }
    }
// Only change code above this line
}
Maddah Anass
@unlimiworks
Mar 08 2016 04:29
@db7894 Don't forget what the exact conditions are. you need to follow this logic :
If it has the property, then either return the value, or a 'no contact' message.
If it doesn't have the property, then you should return the appropriate message
V Arun Kumar
@arunvkumr
Mar 08 2016 04:29
@db7894 second if condition looks good. add contacts[i] in all the places where you have use contacts[firstname]. something like contacts[i][firstname];
Suprith Aireddy
@sup-rith
Mar 08 2016 04:30
@qualitymanifest thanks a lot homie!
CamperBot
@camperbot
Mar 08 2016 04:30
sup-rith sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1061 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Mar 08 2016 04:30
@sup-rith np :+1:
Daniel Bashir
@db7894
Mar 08 2016 04:31
@arunkumrv Just did that... I honestly have no clue what's wrong with it at this point
V Arun Kumar
@arunvkumr
Mar 08 2016 04:31
@db7894 repost your code
Daniel Bashir
@db7894
Mar 08 2016 04:32
function lookUp(firstName, prop){
// Only change code below this line
    for (var i = 0; i < contacts.length; i++) {
      if (firstName == contacts[i][firstName] && contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
      } else if (firstName !== contacts[i][firstName]) {
        return "No such contact";
      } else if (prop !== contacts[i][prop]) {
        return "No such property";
      }
    }
// Only change code above this line
}
Moisés Man
@moigithub
Mar 08 2016 04:33
u returning "too soon"
Maddah Anass
@unlimiworks
Mar 08 2016 04:33
This message was deleted
Mike Xie
@Mike-Xie
Mar 08 2016 04:34
This line fails the test "use bracket notation to access testObj". Help? :
var player = testObj[16];
Daniel Bashir
@db7894
Mar 08 2016 04:34
@moigithub Not sure how... I put the return statements where it looks like they should be
Maddah Anass
@unlimiworks
Mar 08 2016 04:34
Alright, you fixed that :)
I recommend trying Javascript debugger in Pythontutor
Moisés Man
@moigithub
Mar 08 2016 04:35
@db7894 if u have 10 pockets and on each u put some money... how many pockets u need to check before say how much money u got in total ?
V Arun Kumar
@arunvkumr
Mar 08 2016 04:35
@db7894 looks good. now next part... remember i told you about asking four random strangers
Maddah Anass
@unlimiworks
Mar 08 2016 04:35
@Mike-Xie Any value inside brackets should be inside quotes to be treated as a property's name
V Arun Kumar
@arunvkumr
Mar 08 2016 04:36
@db7894 when you are inside for loop you are still asking all the persons when you are done asking all of them you have to return no such contacts. so outside for you should return no such contact.
Daniel Bashir
@db7894
Mar 08 2016 04:37
@arunkumrv I don't understand... Shouldn't that be contained with the first "else if" statement?
@arunkumrv And I don't see how that would make a difference in my code working... It still has issues with returning the right things for anything that's put into the function
V Arun Kumar
@arunvkumr
Mar 08 2016 04:40
@db7894 nope... if it is inside for.. whenever the if fails it would go for next condition which will be in else-if and if it is true then it would return no such contact... Suppose you have four number 1,2,3,4 you are looking for number 4. you have to check the first three to reach 4. if you are putting it inside else-if you are asking 1 if he is 4 condition fails and it goes to else-if and that condition gets true and returns 4 doesn't exist.
Daniel Bashir
@db7894
Mar 08 2016 04:42
@arunkumrv But the else if is only returning "No such contact" if the first name isn't found in each contact for all 4 of them...
I don't think I understand what you're getting at or how to fix this...
Maddah Anass
@unlimiworks
Mar 08 2016 04:43
Can I ask you something @db7894 ?
Daniel Bashir
@db7894
Mar 08 2016 04:44
@UnlimiWorks Yes...?
Maddah Anass
@unlimiworks
Mar 08 2016 04:44
Can you tell me how to solve it without code ?
ie : Look for a person, check if it has the property, etc...
I believe you're just a bit lost
And if there's something wrong in your logic, we'll fix it instead, and leave you to transform it into code
AudioGen
@AudioGen
Mar 08 2016 04:46
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

// Change these values to test your function
lookUp("Akira", "likes");
What's wrong?
Daniel Bashir
@db7894
Mar 08 2016 04:47
@UnlimiWorks Look through all 4 of the contacts in the list. First check if the firstName is that of an actual contact and if the given property is a property of that contact and return what the property is if they're both true, return "no such contact" if there aren't any contacts with that first name and return "no such property" if there aren't any such properties
Maddah Anass
@unlimiworks
Mar 08 2016 04:47
@AudioGen It's a logic problem, you're not approaching it the righ way :)
V Arun Kumar
@arunvkumr
Mar 08 2016 04:48
@db7894 it will not look into each contact...
let's say i have 4 people A, B, C, D. and you are looking for the person D. the conditions are if(D is found) return D's name. else return no such contact and all the people A,B,C,D are sitting in order A to D. Now to search D.. you have to do is ask every person.
You asked A if he is D, he said no then you have else condition which say no such contact and you see that's true and it return no such contact. --- This is what your code is doing..
Mike Xie
@Mike-Xie
Mar 08 2016 04:48
@UnlimiWorks I am on this challenge: FreeCodeCamp/FreeCodeCamp#7376 I don't think it's the problem. My solution is var playerNumber = 16; var player = testObj[16]; I don't know what is wrong. This is one of the super easy ones.
AudioGen
@AudioGen
Mar 08 2016 04:50
@UnlimiWorks What do you mean?
Maddah Anass
@unlimiworks
Mar 08 2016 04:50
@db7894 Okay. the logic is there but a bit messed. Let me iterate over that :
Scroll through the contacts. If I find the right person, I check if he has the property i'm looking for. If he does, I'll it's value, else i'm returning a 'no property' message
And finally, if i don't find any contact, i'll just return a 'no contact' message
Mike Xie
@Mike-Xie
Mar 08 2016 04:51
@UnlimiWorks ok, nvm apparently I am suppose to do var player = testObj[playerNumber] not hard code 16, makes sense.
Daniel Bashir
@db7894
Mar 08 2016 04:51
@arunkumrv @UnlimiWorks I think I see. I have no idea how to fix my code to correspond with the logic, though (would I delete the else if statements?)...
Maddah Anass
@unlimiworks
Mar 08 2016 04:52
@Mike-Xie Alright. basically, you can only use variables with the bracket notation, because it replaces it by its value. Glad you found it yourself :)
V Arun Kumar
@arunvkumr
Mar 08 2016 04:52
@db7894 yes i think that would work and return no such contact out of loop.
then code will be like asked all the person but didn't find the person so return no such contact.
Daniel Bashir
@db7894
Mar 08 2016 04:53
@arunkumrv But then doesn't deleting those stop me from actually checking anything?
Maddah Anass
@unlimiworks
Mar 08 2016 04:53
@db7894 Just try to implement the logic as I reformulated (that means placing a if when you want to check for a condition etc..)
Or do what @arunkumrv said
But don't do anything without understanding why
Daniel Bashir
@db7894
Mar 08 2016 04:54
@UnlimiWorks I feel like that's what I did... But then I wouldn't be able to check if the firstName and properties match without if statements
I understand the logic but I still don't understand how to implement it
V Arun Kumar
@arunvkumr
Mar 08 2016 04:55
@db7894 repost your code again. :smile:
Daniel Bashir
@db7894
Mar 08 2016 04:55
function lookUp(firstName, prop){
// Only change code below this line
    for (var i = 0; i < contacts.length; i++) {
      if (firstName == contacts[i][firstName] && contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
      } else if (firstName !== contacts[i][firstName]) {
        return "No such contact";
      } else if (prop !== contacts[i][prop]) {
        return "No such property";
      }
    }
// Only change code above this line
}
Maddah Anass
@unlimiworks
Mar 08 2016 04:55
Okay. Here's something that will help. I highly recommend you copy your code and paste it there, then hit run. It will show you what your code does, step by step : http://pythontutor.com/javascript.html#mode=edit
V Arun Kumar
@arunvkumr
Mar 08 2016 04:56
@db7894 ya do that what @UnlimiWorks said. it will help you
Maddah Anass
@unlimiworks
Mar 08 2016 04:56
If you don't understand what's wrong after that, we'll still be here to help :)
AudioGen
@AudioGen
Mar 08 2016 04:57
@UnlimiWorks cool source but kind of hard to follow
Maddah Anass
@unlimiworks
Mar 08 2016 04:57
@AudioGen Sorry for the late answer. You have the same logic problem we're trying to fix
HoangTu34
@NgocTang
Mar 08 2016 04:58
myStr = "backslash tab tab carriage-return new-line ";
myStr should have the escape sequences for backslash tab tab carriage-return new-line separated by spaces
someone fix this
Maddah Anass
@unlimiworks
Mar 08 2016 04:58
@AudioGen Yes, just try to find where your code does something you don't expect, that will be where your code is wrong
cannelflow
@cannelflow
Mar 08 2016 04:58
@NgocTang which exercise?
Daniel Bashir
@db7894
Mar 08 2016 04:59
@UnlimiWorks I had the same problem as AudioGen, I have no clue what it's telling me... Maybe I should just try this another time
V Arun Kumar
@arunvkumr
Mar 08 2016 04:59
@NgocTang you have to use escape sequences not the string. :smile:
Maddah Anass
@unlimiworks
Mar 08 2016 04:59
@db7894 Hm. Do you know what return does ?
AudioGen
@AudioGen
Mar 08 2016 04:59
@UnlimiWorks I wrote something out similar on jsfiddle and it outputs perfectly fine
HoangTu34
@NgocTang
Mar 08 2016 04:59
@arunkumrv how?
AudioGen
@AudioGen
Mar 08 2016 05:00
@UnlimiWorks escapes the function
Daniel Bashir
@db7894
Mar 08 2016 05:00
@UnlimiWorks Stops a function and returns a value
HoangTu34
@NgocTang
Mar 08 2016 05:01
@arunkumrv thank u
CamperBot
@camperbot
Mar 08 2016 05:01
ngoctang sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 310 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Mar 08 2016 05:02
@NgocTang :smile: :+1:
Maddah Anass
@unlimiworks
Mar 08 2016 05:03
@db7894 Yes. Now look at return "No such contact";. It gets activated everytime firstName == contacts[i][firstName] or contacts[i].hasOwnProperty(prop) returns false.
Is that what you want to do ?
This message was deleted
@AudioGen You have a very similar problem with it too
AudioGen
@AudioGen
Mar 08 2016 05:06
@UnlimiWorks I have && though, that's and
|| is or
Maddah Anass
@unlimiworks
Mar 08 2016 05:08
@AudioGen the overall condition returns false if either of them returns false. That's what I was saying.
Basically, what we want to do is :
scroll through our contacts {
  if we find the contact {
    if he has the property {
      let us display it
    }
    if not, let us display an appropriate message
  }
}
If we finish scrolling, that means we did not find the person in our contacts. Let us display an appropriate message
AudioGen
@AudioGen
Mar 08 2016 05:11
@UnlimiWorks Don't both conditions need to be met to return it true?
Maddah Anass
@unlimiworks
Mar 08 2016 05:12
@AudioGen Yes, I was talking about returning false, that's why i was using or
Joseph Morse
@jnmorse
Mar 08 2016 05:13
for Symmetric Difference, can anyone tell me what I'm missing here, pass all but the last two sets of arrays, and can't figure out why I'm getting one less item then I'm suppose to on those
function sym(args) {
  var arrays = Array.prototype.slice.call(arguments);
  var result = [];

  result = arrays.reduce(function(a, b) {
    var temp = [];
    var aIndex = 0;
    var i = 0;

    for (i = 0; i < b.length; i++) {
      aIndex = a.indexOf(b[i]);

      if (aIndex === -1 && temp.indexOf(b[i]) === -1) {
        temp.push(b[i]);
      }

      else {
        a.splice(aIndex, 1);
      }
    }

    return a.concat(temp);
  }, []);

  return result.sort(function(a, b) { return a > b; });
}

sym([3, 3, 3, 2, 5], [2, 1, 5, 7], [3, 4, 6, 6], [1, 2, 3]);
V Arun Kumar
@arunvkumr
Mar 08 2016 05:13
@AudioGen if either of the condition fails then the whole condition fails. if( A && B) this will be only true is both are true, if either A fails or B fails or Both fails it would return false.
Daniel Bashir
@db7894
Mar 08 2016 05:14
@UnlimiWorks Something like this?
function lookUp(firstName, prop){
// Only change code below this line
    for (var i = 0; i < contacts.length; i++) {
      if (firstName == contacts[i][firstName] && contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
      } else return "No such property";
    }
  return "No such contact";
// Only change code above this line
}
V Arun Kumar
@arunvkumr
Mar 08 2016 05:15
@db7894 better.. but still not good, why are using else?
Maddah Anass
@unlimiworks
Mar 08 2016 05:15
I guess it's okay :)
Yes, it could be better without and else, but that is correct
My bad, sorry
It's 5 am, it's not, uhh
Daniel Bashir
@db7894
Mar 08 2016 05:16
@arunkumrv Because I need to return "no such property" if the conditions aren't true....
Maddah Anass
@unlimiworks
Mar 08 2016 05:16
As @arunkumrv said, it still is not, but you're muuuuuch closer to the answer
Daniel Bashir
@db7894
Mar 08 2016 05:17
@UnlimiWorks Right... No clue what else I can do with it, though...
Maddah Anass
@unlimiworks
Mar 08 2016 05:18
@db7894 When do you have to return "No such property" ?
V Arun Kumar
@arunvkumr
Mar 08 2016 05:18
@db7894 you should return no such property only when the person exists in contacts but doesn't have a property. your else would always no such property for all condition except if
AudioGen
@AudioGen
Mar 08 2016 05:19
@UnlimiWorks I think I'm falling off the rails with this one :D, I'm losing checked boxes :(
V Arun Kumar
@arunvkumr
Mar 08 2016 05:20
@db7894 you are really very close. just think why would you use else instead of else-if :smile:
Daniel Bashir
@db7894
Mar 08 2016 05:20
@arunkumrv @UnlimiWorks Changed to this
function lookUp(firstName, prop){
// Only change code below this line
    for (var i = 0; i < contacts.length; i++) {
      if (firstName == contacts[i][firstName] && contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
      } else if (firstName == contacts[i][firstName] && prop !== contacts[i][prop]) {
        return "No such property";
      }
    }
  return "No such contact";
// Only change code above this line
}
Maddah Anass
@unlimiworks
Mar 08 2016 05:21
@AudioGen Don't worry about that. It'll work out when you understand how to solve it
It's still a logic problem guys, your approach has some flaws :)
@db7894 And what did it do ?
@AudioGen Where are you at ? Can I see your code ?
V Arun Kumar
@arunvkumr
Mar 08 2016 05:25
@db7894 looks good :+1:
@db7894 did it work?
AudioGen
@AudioGen
Mar 08 2016 05:26
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

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

// Change these values to test your function
lookUp("Akira", "likes");
Maddah Anass
@unlimiworks
Mar 08 2016 05:28
@AudioGen In your current code, your else if will always execute even if it's not the contact we're looking for
Daniel Bashir
@db7894
Mar 08 2016 05:31
@UnlimiWorks @AudioGen Still doesn't work
Maddah Anass
@unlimiworks
Mar 08 2016 05:33
@db7894 Try using hasOwnProperty() instead of prop !== contacts[i][prop]
In your comparison, you're comparing prop with prop's value
V Arun Kumar
@arunvkumr
Mar 08 2016 05:33
@db7894 i see the problem. put firstName in quotes wherever you have use contacts[i][firstName]like.. contacts[i]["firstName"] or you can also use dot notation which is better contacts[i].firstName.
Maddah Anass
@unlimiworks
Mar 08 2016 05:33
@arunkumrv Good catch..
V Arun Kumar
@arunvkumr
Mar 08 2016 05:34
@UnlimiWorks thanks. :smile:
Daniel Bashir
@db7894
Mar 08 2016 05:35
@arunkumrv @UnlimiWorks Ah, silly me... Thank you both!
CamperBot
@camperbot
Mar 08 2016 05:35
db7894 sends brownie points to @arunkumrv and @unlimiworks :sparkles: :thumbsup: :sparkles:
:star: 311 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
:star: 321 | @unlimiworks | http://www.freecodecamp.com/unlimiworks
V Arun Kumar
@arunvkumr
Mar 08 2016 05:35
@db7894 you're welcome :smile: . happy coding.
AudioGen
@AudioGen
Mar 08 2016 05:36
I have the quotes and still not getting it
Maddah Anass
@unlimiworks
Mar 08 2016 05:36
Sorry if I made your head spin sometimes, I'm sleep depraved and should go ASAP :)
Daniel Bashir
@db7894
Mar 08 2016 05:36
I just want to try reexplaining this to make sure I understand... So basically what it does is I go through all 4 of the contacts. If I find one with the first name I'm looking for and the property then I can abort the program and return the property value, but if I only find the name and not the property than I return no such property; if the loop goes through without finding anything then it just returns no such contact
@UnlimiWorks I can imagine getting some sleep would be a good idea :smile:
V Arun Kumar
@arunvkumr
Mar 08 2016 05:39
haha you should sleep. night @UnlimiWorks
AudioGen
@AudioGen
Mar 08 2016 05:39
Got it now, but still don't really understand it, kind of worked off @db7894 code a bit
V Arun Kumar
@arunvkumr
Mar 08 2016 05:39
@db7894 you got it right :+1:
Daniel Bashir
@db7894
Mar 08 2016 05:40
@AudioGen I can try to help out (this might help me understand it better too...) Is there a specific part you're not getting?
@AudioGen Are you still at the same place as the code you posted above?
AudioGen
@AudioGen
Mar 08 2016 05:42
@db7894 Yah I'm not following how the return "No Such Contact" is getting declared outside of the brackets with the iteration
I completed the exercise actually, just don't really understand why :D
Daniel Bashir
@db7894
Mar 08 2016 05:44
@AudioGen Ah, good job! :smile: so I think the idea is (this is just the way I understand it) that you're having the for loop go through all of the different contacts and return stuff based on conditions. The "No such contact" return goes afterwards because the for loop might have gone through all of the stuff above and not have found anything that fulfills your conditions, so since it didn't find anything the function just aborts and shows "No such contact"
1ety
@1ety
Mar 08 2016 05:44
How is the output of the following code would look like?
Maddah Anass
@unlimiworks
Mar 08 2016 05:44
@db7894 If you find the one you're looking for, then you need to abort the loop and return something, depending if you find the property :)
1ety
@1ety
Mar 08 2016 05:44
var oldArray = [1,2,3,4,5];

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

var newArray =arrayThree;
Maddah Anass
@unlimiworks
Mar 08 2016 05:45
@AudioGen Your code doesn't work because of 2 things
Daniel Bashir
@db7894
Mar 08 2016 05:46
@UnlimiWorks Ah yes, should have mentioned that
I think I'm done for the night, but thank you all again for your help!
Maddah Anass
@unlimiworks
Mar 08 2016 05:46
1 - prop === contacts[i].hasOwnProperty(prop) would always return false
You're welcome, glad i helped :)
V Arun Kumar
@arunvkumr
Mar 08 2016 05:47
@1ety it would return arrayThree with value [4,5,6,7,8]
Kishan Patel
@pkishan1990
Mar 08 2016 05:47
Hello all
is there a way to create fixed size array in javascript?
var arr=[4,
["id",1],
["id",2],
["id",3],
["id",4]
]
like i want to insert only 4 elements in array
V Arun Kumar
@arunvkumr
Mar 08 2016 05:49
@pkishan1990 somthing like arr[4]=[1,2,3,4]?
AudioGen
@AudioGen
Mar 08 2016 05:49
@UnlimiWorks Because they are different data type and value?
Maddah Anass
@unlimiworks
Mar 08 2016 05:49
@AudioGen Yes
Kishan Patel
@pkishan1990
Mar 08 2016 05:49
ya @arunkumrv
Harmanan Kohli
@Harmanankohli
Mar 08 2016 05:49
1ety
@1ety
Mar 08 2016 05:50
Thank you @arunkumrv . However could you explain what map(function(val) does. I don't really understand it.
CamperBot
@camperbot
Mar 08 2016 05:50
1ety sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 312 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Maddah Anass
@unlimiworks
Mar 08 2016 05:50
2- contacts[i].hasOwnProperty(prop) === false will get activated even for contacts other than the one we're looking for. You need to check this for the one person we're trying to find
Kishan Patel
@pkishan1990
Mar 08 2016 05:51

@arunkumrv var arr[4]=[4,
^

SyntaxError: Unexpected token [

V Arun Kumar
@arunvkumr
Mar 08 2016 05:52
@1ety map function takes one element at a time and does the operation you provide in the function. you can refer here.. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
@pkishan1990 instead of var arr[4] = [1,2,3,4] you can directly write var arr = [1,2,3,4]
AudioGen
@AudioGen
Mar 08 2016 05:53
@UnlimiWorks Yah that was a change I made from my original code, knew I was kind of reaching there
Kishan Patel
@pkishan1990
Mar 08 2016 05:55
but i want to fix the size of array so no one can do push operation
AudioGen
@AudioGen
Mar 08 2016 05:55
@UnlimiWorks Thanks for the help
CamperBot
@camperbot
Mar 08 2016 05:55
audiogen sends brownie points to @unlimiworks :sparkles: :thumbsup: :sparkles:
:star: 322 | @unlimiworks | http://www.freecodecamp.com/unlimiworks
Maddah Anass
@unlimiworks
Mar 08 2016 05:55
@AudioGen Glad I helped you :)
Well. Time to call it a night
Have a good one everyone. Happy coding :)
1ety
@1ety
Mar 08 2016 05:56
Thank you @arunkumrv . Got it!
CamperBot
@camperbot
Mar 08 2016 05:56
1ety sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:warning: 1ety already gave arunkumrv points
Richard Corbett
@reacorbett
Mar 08 2016 05:57
help random quote
CamperBot
@camperbot
Mar 08 2016 05:57
no wiki entry for: random quote
Richard Corbett
@reacorbett
Mar 08 2016 05:57
help random quote generator
CamperBot
@camperbot
Mar 08 2016 05:57
no wiki entry for: random quote generator
V Arun Kumar
@arunvkumr
Mar 08 2016 05:57
@pkishan1990 you can try var arr = new Array(10);
Richard Corbett
@reacorbett
Mar 08 2016 05:58
help random quote machine
CamperBot
@camperbot
Mar 08 2016 05:58
no wiki entry for: random quote machine
Richard Corbett
@reacorbett
Mar 08 2016 05:58
help JSON API
CamperBot
@camperbot
Mar 08 2016 05:58

:point_right: front end project use the twitchtv json api [wiki]

If you're trying to tackle this challenge with jQuery's $.getJSON() method, chances are you'll get an error message concerning Cross-Origin Resource Sharing (CORS).

The easiest way to resolve this is to use jQuery's JSONP capabilities. From the Twitch API's readme page:

All API methods support JSON-P by providing a callback parameter with the request.

Also the jQuery documentation states:

If the URL includes the string "callback=?" (or similar, as defined by the server-side API), the request is treated as JSONP instead.

Here's an example call to fetch Free Code Camp's Twitch channel data:

$.getJSON('https://api.twitch.tv/kraken/streams/freecodecamp?callback=?', function(data) {
  console.log(data);
});

JSONP is considered insecure according to Wikipedia, but should be sufficient for our purposes. For a detailed discussion on Twitch's CORS restriction, please read justintv/Twitch-API#133 on the Twitch-API repository.
:pencil: read more about front end project use the twitchtv json api on the FCC Wiki

Supreeth
@hallidude
Mar 08 2016 06:02
Guys, I need help with Stand in Line Javascript challenge
unable to read the code right
so function queue (arr, item){} has created teh function right?
Kishan Patel
@pkishan1990
Mar 08 2016 06:03
@arunkumrv thanks
Supreeth
@hallidude
Mar 08 2016 06:04
Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed.
help?
CamperBot
@camperbot
Mar 08 2016 06:04

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. ex: find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • Algorithm BONFIRENAME info on a Algorithm

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Supreeth
@hallidude
Mar 08 2016 06:04
find stand in line
CamperBot
@camperbot
Mar 08 2016 06:04
find stand in line
nothing found
Supreeth
@hallidude
Mar 08 2016 06:04
find js
Supreeth
@hallidude
Mar 08 2016 06:05
find js
Supreeth
@hallidude
Mar 08 2016 06:05
find js
find js
V Arun Kumar
@arunvkumr
Mar 08 2016 06:07
@pkishan1990 JS doesn't support fixed array i searched for it but didn't find it. there might be some way to do it i'll keep searching and if i find anything i'll let you know.
Richard Corbett
@reacorbett
Mar 08 2016 06:07
@hallidude what challenge?
V Arun Kumar
@arunvkumr
Mar 08 2016 06:09
kangyao
@kay78
Mar 08 2016 06:09
Need some help on the "Validate US Telephone Numbers"
function telephoneCheck(str) {
  // Good luck!

  var nonSpace = /\S/g; //find all character that in not white space
  var strTrim = str.match(nonSpace).join("");  //remove space from str

  //defined an array of US phone number regex"  
  var USformat = ["/\\d\\d\\d-\\d\\d\\d-\\d\\d\\d\\d/","/\(\\d\\d\\d\)\\d\\d\\d-\\d\\d\\d\\d/","/\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d/","/1\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d/","/1\\d\\d\\d-\\d\\d\\d-\\d\\d\\d\\d/","/1\(\\d\\d\\d\)\\d\\d\\d-\\d\\d\\d\\d/"]; 


  for (var x in USformat) {
    var result =  USformat[x].test(strTrim);
    return result;
  }  

  return false;
}


telephoneCheck("555-555-5555");
The result shows TypeError: USformat[x].text is not a function
I saw some other camper solution that just write a oneline Regexp to test against the input, but somehow i got dizzy with such long regexp, thus trying to break it into groups of regexp... yet i failed....
V Arun Kumar
@arunvkumr
Mar 08 2016 06:18
@kay78 try creating a RegExp object and then storing your regexp in the object.
something like var USformat = new RegExp(/reg-expression/);
help regexp
CamperBot
@camperbot
Mar 08 2016 06:19
no wiki entry for: regexp
V Arun Kumar
@arunvkumr
Mar 08 2016 06:19
help reg
CamperBot
@camperbot
Mar 08 2016 06:19

:point_right: challenge find numbers with regular expressions [wiki]

Find Numbers with Regular Expressions

We can use special selectors in Regular Expressions to select a particular type of value.

One such selector is the digit selector \d which is used to grab the numbers in a string.

It is used like this: /\d+/g.

:pencil: read more about challenge find numbers with regular expressions on the FCC Wiki

Travis LaDuke
@laduke
Mar 08 2016 06:21
how would you define an array of RegExp
V Arun Kumar
@arunvkumr
Mar 08 2016 06:23
@laduke instead of putting it in an array you can just combine them all seperated by |(or). that would work i think
Kristoforus Rua
@kru
Mar 08 2016 06:23
hello all
Richard Corbett
@reacorbett
Mar 08 2016 06:24
hello
V Arun Kumar
@arunvkumr
Mar 08 2016 06:24
@kay78 visit here you can learn basic regex --- > http://regexone.com/
Travis LaDuke
@laduke
Mar 08 2016 06:25
can you just just like [/regex1/, /regex2/]
Kristoforus Rua
@kru
Mar 08 2016 06:25
I have a problem here, it's about FCC challenges
Richard Corbett
@reacorbett
Mar 08 2016 06:25
@krua what is your problem?
Richard Corbett
@reacorbett
Mar 08 2016 06:27
@laduke what are you using it for?
Travis LaDuke
@laduke
Mar 08 2016 06:27
oh i was replying to someone else above
V Arun Kumar
@arunvkumr
Mar 08 2016 06:27
@laduke i have never done something like that, but using | is better imo.
Richard Corbett
@reacorbett
Mar 08 2016 06:27
oh ok
V Arun Kumar
@arunvkumr
Mar 08 2016 06:32
@laduke thanks for the link. now i know how to use them :smile:
CamperBot
@camperbot
Mar 08 2016 06:32
arunkumrv sends brownie points to @laduke :sparkles: :thumbsup: :sparkles:
:star: 148 | @laduke | http://www.freecodecamp.com/laduke
Kristoforus Rua
@kru
Mar 08 2016 06:35

I opened 2 browser which is Chrome and Firefox , and I login to my FCC account in both of them. Then, I finished 'Diff Two Arrays' in Firefox and 'Where art thou' in Chrome.

My problem is I can't see solutions for 'Diff Two Arrays' in Chrome and 'Where art thou' in Firefox even when I restart my computer and do logout then login again.

dltaylor
@dltaylor
Mar 08 2016 06:36
var Bike = function() {
// Only change code below this line.
  var gear = 0;

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

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

var myCar = new Car();

var myBike = new Bike();
Can someone tell me why this is not passing? It works right but not passing the test?
Brian
@sludge256
Mar 08 2016 06:36
You're incrementing gear not setting gear
dltaylor
@dltaylor
Mar 08 2016 06:37
Thanks @sludge256
CamperBot
@camperbot
Mar 08 2016 06:37
dltaylor sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
:star: 1780 | @sludge256 | http://www.freecodecamp.com/sludge256
Richard Corbett
@reacorbett
Mar 08 2016 06:37
@krua Can you see Where art thou in Chrome and Diff Two Arrays in Firefox?
Kristoforus Rua
@kru
Mar 08 2016 06:38
@reacorbett Yes, I can
Brian
@sludge256
Mar 08 2016 06:38
Code exists in local storage
If you pass they will show up when you access the solutions from the profile page
Richard Corbett
@reacorbett
Mar 08 2016 06:38
@krua If you really want to see them in the oposite browser, just copy and paste.
GodChildJoy
@GodChildJoy
Mar 08 2016 06:38
hello everyone
Richard Corbett
@reacorbett
Mar 08 2016 06:39
hello @GodChildJoy
Kristoforus Rua
@kru
Mar 08 2016 06:39
I have passed the challenges with success
Brian
@sludge256
Mar 08 2016 06:39
about @krua
CamperBot
@camperbot
Mar 08 2016 06:39
:star: 353 | @krua | http://www.freecodecamp.com/krua
GodChildJoy
@GodChildJoy
Mar 08 2016 06:39
for the rot13 exe
how can I make the str[i]!==[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\s]
Kristoforus Rua
@kru
Mar 08 2016 06:39
And the problem is remain
Brian
@sludge256
Mar 08 2016 06:39
visit the link
Travis LaDuke
@laduke
Mar 08 2016 06:40
huh
Kristoforus Rua
@kru
Mar 08 2016 06:41
I did it 3 times then, restart my computer and do login but the problem still exist
GodChildJoy
@GodChildJoy
Mar 08 2016 06:41
basically, test the one char of a string not equal to any punctuation?
Richard Corbett
@reacorbett
Mar 08 2016 06:41
@krua click the caperbot link up top.
Travis LaDuke
@laduke
Mar 08 2016 06:42
help rot13
CamperBot
@camperbot
Mar 08 2016 06:42
no wiki entry for: rot13
Kristoforus Rua
@kru
Mar 08 2016 06:42
@reacorbett what is caperbot? Sorry, i'm a newbie here :)
Richard Corbett
@reacorbett
Mar 08 2016 06:43
about @krua
CamperBot
@camperbot
Mar 08 2016 06:43
:star: 353 | @krua | http://www.freecodecamp.com/krua
Richard Corbett
@reacorbett
Mar 08 2016 06:43
right here @krua
Travis LaDuke
@laduke
Mar 08 2016 06:43
does it explain about ascii codes anywhere?
Richard Corbett
@reacorbett
Mar 08 2016 06:43
ight abouve my last post
Kristoforus Rua
@kru
Mar 08 2016 06:43
ok
Richard Corbett
@reacorbett
Mar 08 2016 06:43
@GodChildJoy can you post your whole code?
GodChildJoy
@GodChildJoy
Mar 08 2016 06:45
I am new here, what's the best way to post my whole code nicely
Richard Corbett
@reacorbett
Mar 08 2016 06:45
help format
CamperBot
@camperbot
Mar 08 2016 06:45

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Richard Corbett
@reacorbett
Mar 08 2016 06:45
read that @GodChildJoy
Kristoforus Rua
@kru
Mar 08 2016 06:45
Thanks, @reacorbett I can see them right now.
CamperBot
@camperbot
Mar 08 2016 06:45
krua sends brownie points to @reacorbett :sparkles: :thumbsup: :sparkles:
:star: 298 | @reacorbett | http://www.freecodecamp.com/reacorbett
Richard Corbett
@reacorbett
Mar 08 2016 06:46
@krua Thank @sludge256. I was just passing on his advise.
CamperBot
@camperbot
Mar 08 2016 06:46
reacorbett sends brownie points to @krua and @sludge256 :sparkles: :thumbsup: :sparkles:
:star: 354 | @krua | http://www.freecodecamp.com/krua
:star: 1781 | @sludge256 | http://www.freecodecamp.com/sludge256
Matthew Stettner
@mstettner
Mar 08 2016 06:47
hello. hows everyone doing tonightS?
Gaurav Prabhu
@Gauravp15
Mar 08 2016 06:47
Hello guys. Is anyone stuck on Profile Lookup?
for(var i = 0; i < contacts.length; i++){
    if(firstName == contacts[i][firstName] && prop == contacts[i].hasOwnProperty()){
      return contacts[i][prop];
    }
    else if(firstName !== contacts[i][firstName]){
      return "No such contact";
    }
    else if(prop !== contacts[i].hasOwnProperty()){
      return "No such property";
    }
  }
Where am I going wrong? Can anyone please help?
kangyao
@kay78
Mar 08 2016 06:48
@ladyke thanks
CamperBot
@camperbot
Mar 08 2016 06:48
kay78 sends brownie points to @ladyke :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for ladyke
kangyao
@kay78
Mar 08 2016 06:49
@laduke thanks
CamperBot
@camperbot
Mar 08 2016 06:49
kay78 sends brownie points to @laduke :sparkles: :thumbsup: :sparkles:
:star: 149 | @laduke | http://www.freecodecamp.com/laduke
Richard Corbett
@reacorbett
Mar 08 2016 06:50
@Gauravp15 can you post the full code?
Gaurav Prabhu
@Gauravp15
Mar 08 2016 06:51
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

// Change these values to test your function
lookUp("Akira", "address");
Claire Walker
@kjarva
Mar 08 2016 06:51
@Gauravp15 this if(firstName == contacts[i][firstName] && prop == contacts[i].hasOwnProperty()){ should be if(firstName == contacts[i].firstName && prop == contacts[i].hasOwnProperty()){
GodChildJoy
@GodChildJoy
Mar 08 2016 06:51
function rot13(str) { // LBH QVQ VG!
  for (var i=0; i<str.length; i++ ){
    if (str[i]!==[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~\s]) {
      //str.charCodeAt(i)+13;
    }

  }
  return str;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
let me try again
sorry
Gaurav Prabhu
@Gauravp15
Mar 08 2016 06:53
Hey @kjarva Can you please explain me exactly as to when we should use bracket and dot notation?
Like we are taking the firstName as a parameter so shouldn't we use it in the bracket notation?
Richard Corbett
@reacorbett
Mar 08 2016 06:53
I would start by looking at your first if statement @Gauravp15
Travis LaDuke
@laduke
Mar 08 2016 06:54
@GodChildJoy I just blocked characters outside of the capital letter range from being rotated. http://www.ascii-code.com/
GodChildJoy
@GodChildJoy
Mar 08 2016 06:55
it works, my question is how I test str[i] not equal to any punctuation?
Travis LaDuke
@laduke
Mar 08 2016 06:55
help regexp
CamperBot
@camperbot
Mar 08 2016 06:55
no wiki entry for: regexp
Claire Walker
@kjarva
Mar 08 2016 06:55
As far as I understand you use bracket notation when you don't know the exact input of the thing, so for example the argument 'prop' could haveone of several values. with firstName you know exactly what you are looking for, no matter which object you search they all have a firstName in the object, so in this instance you use dot. That's how someone explained it to me day before last @Gauravp15
Travis LaDuke
@laduke
Mar 08 2016 06:55
help reg
CamperBot
@camperbot
Mar 08 2016 06:55

:point_right: challenge find numbers with regular expressions [wiki]

Find Numbers with Regular Expressions

We can use special selectors in Regular Expressions to select a particular type of value.

One such selector is the digit selector \d which is used to grab the numbers in a string.

It is used like this: /\d+/g.

:pencil: read more about challenge find numbers with regular expressions on the FCC Wiki

Travis LaDuke
@laduke
Mar 08 2016 06:56
@GodChildJoy `if charCodeAt >= 70 ...
Richard Corbett
@reacorbett
Mar 08 2016 06:56
@GodChildJoy the unicode for alpha characters falls between 65-90. I would really take a look at using .charCodeAt() and .fromCharCode(). they both will make that challenge a whole lot easier. Aslo .map() method as well.
Travis LaDuke
@laduke
Mar 08 2016 06:57
why did i write 70?
65 sorry
Gaurav Prabhu
@Gauravp15
Mar 08 2016 06:57
Oh okay @kjarva . Still unable to get the solution. -_- First 3 cases not getting satisfied
GodChildJoy
@GodChildJoy
Mar 08 2016 06:58
cool
thanks for the guide
I have read them but did not realise I can use this way
will go through again
Thank you all of you
Greg
@madcoyote
Mar 08 2016 07:01
Ok, so this seems easy but I can't figure out what I am doing wrong
Claire Walker
@kjarva
Mar 08 2016 07:02
@Gauravp15 here's a good tool where you can actually figure out where your code is going wrong: http://pythontutor.com/javascript.html#mode=display I'm still not brilliant at working my way through other peoples code yet, so I am just running your code through it to see if I can spot what is wrong
Gaurav Prabhu
@Gauravp15
Mar 08 2016 07:02
Alright thanks a lot @kjarva
CamperBot
@camperbot
Mar 08 2016 07:02
gauravp15 sends brownie points to @kjarva :sparkles: :thumbsup: :sparkles:
:star: 249 | @kjarva | http://www.freecodecamp.com/kjarva
Richard Corbett
@reacorbett
Mar 08 2016 07:04
@guaravp15
try the code review room. I think i know what is going on with your code. I just cant exactly explain it the way some other people can. @Gauravp15
kirbyedy
@kirbyedy
Mar 08 2016 07:05
@kjarva wow, that site is cool, thanks
CamperBot
@camperbot
Mar 08 2016 07:05
kirbyedy sends brownie points to @kjarva :sparkles: :thumbsup: :sparkles:
:star: 250 | @kjarva | http://www.freecodecamp.com/kjarva
Claire Walker
@kjarva
Mar 08 2016 07:10
@reacorbett same - I know that first if statement isn't returning a value when it should but Ican't explain why. no problem @kirbyedy I can't remember who sent me it originally on here but it's been enormously helpful when it came to array looping :)
carlosuson
@carlosuson
Mar 08 2016 07:11
cant seem to find the solution to this. Modify the Bike constructor to have a private property called gear and two public methods called getGear and setGear to get and set that value.
kirbyedy
@kirbyedy
Mar 08 2016 07:11
life saver :)
Richard Corbett
@reacorbett
Mar 08 2016 07:11
@kjarva I think it is the $$. I had deivided that into two if statements.
AudioGen
@AudioGen
Mar 08 2016 07:11
How do you return the string with the first letter of each word capitalized for this exercise?
function titleCase(str) {
  return str;
}

titleCase("I'm a little tea pot");
Claire Walker
@kjarva
Mar 08 2016 07:12
@reacorbett me too, that's how I solved it but Idon't actually understand why that worked and not the way @Gauravp15 (and me originally) had it
Emil Aasa
@emilaasa
Mar 08 2016 07:12
@AudioGen How would you return just one word with the first letter capitalised?
Richard Corbett
@reacorbett
Mar 08 2016 07:12
I also didnt use .hasOwnProperty() @kjarva
Claire Walker
@kjarva
Mar 08 2016 07:12
I didn't either @reacorbett we probably have the same code lol
Richard Corbett
@reacorbett
Mar 08 2016 07:13
I think it is because the if statement has to return true before it move on to that part of the code.
AudioGen
@AudioGen
Mar 08 2016 07:13
@emilaasa Store the word string in a variable and word.toUpperCase();
Emil Aasa
@emilaasa
Mar 08 2016 07:13
So now you need to only do that to the first letter
Claire Walker
@kjarva
Mar 08 2016 07:13
you're right - the problem states it needs to check first if contact firstName returns true THEN check for prop if I remember right @reacorbett
Emil Aasa
@emilaasa
Mar 08 2016 07:14
if you can figure out how to do it for the first letter only in every word then you are almost there
Greg
@madcoyote
Mar 08 2016 07:15
​1 var myStr = "I am a \"double quoted" string inside "double quotes" \"; // Change this line
2
3
I am really new to this site, sorry if I'm using the help wrong
I don't get why its saying Expected ';' I have the semicolon there...err
AudioGen
@AudioGen
Mar 08 2016 07:15
@emilaasa I think I'm supposed to split the sentence into an array but I don't know how to then just select the initial letter of each word in the array
Emil Aasa
@emilaasa
Mar 08 2016 07:15
var myArray = str.split(“ “);
AudioGen
@AudioGen
Mar 08 2016 07:16
k then what?
Emil Aasa
@emilaasa
Mar 08 2016 07:16
will split a string into an array and use whitespace as a delimiter
then you have an array of words which you should be able to loop thru
Richard Corbett
@reacorbett
Mar 08 2016 07:16
@kjarva I sent you my code in a pm.
Emil Aasa
@emilaasa
Mar 08 2016 07:16
now you figure out what to put in the loop to make the first char in every word capital and you are almost done
AudioGen
@AudioGen
Mar 08 2016 07:17
ok
Claire Walker
@kjarva
Mar 08 2016 07:18
@reacorbett lol we do have the same code except you used x where I used i :)
Ankit Panwar
@coderNoob
Mar 08 2016 07:18
This message was deleted
Kristoforus Rua
@kru
Mar 08 2016 07:18
@Gauravp15 are you still there?
your code
'''
CamperBot
@camperbot
Mar 08 2016 07:20
:bulb: to format code use backticks! ``` more info
Michael Aubrey
@mca62511
Mar 08 2016 07:21

Oh my goodness. Been trying "Where art thou" on and off for the past few hours. I came up with this.

function where(collection, source) {
    var arr = [];
    var propCheck = Object.keys(source);
    for (j = 0; j < collection.length; j++) {
        for (i = 0; i < propCheck.length; i++) {
            if (collection[j].hasOwnProperty(propCheck[i]) && collection[j][propCheck[i]] == source[propCheck[i]]) {
                if (i == propCheck.length - 1) {
                    arr.push(collection[j]);
                }
            } else {
                break;
            }
        }
    }
    return arr;
}

where([{ first: "Romeo", last: "Montague", b: "Capulet" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Montague", b: "Capulet" });

And it works! ... but its so inelegant. I've never felt so disappointed at successfully finishing a challenge >.<

Kristoforus Rua
@kru
Mar 08 2016 07:21
prop == contacts[i].hasOwnProperty() is not evaluates same value, since prop have type of string and contacts[i].hasOwnProperty() is Boolean
Richard Corbett
@reacorbett
Mar 08 2016 07:21
@kjarva yeah, I shouldhave used i for index i guess.
Claire Walker
@kjarva
Mar 08 2016 07:23
@krua thanks for explaining that - I wasn't sure how that worked as I haven't ever used hasOwnProperty()
CamperBot
@camperbot
Mar 08 2016 07:23
kjarva sends brownie points to @krua :sparkles: :thumbsup: :sparkles:
:star: 355 | @krua | http://www.freecodecamp.com/krua
Supreeth
@hallidude
Mar 08 2016 07:25
@reacorbett stand in line
Kristoforus Rua
@kru
Mar 08 2016 07:25
@kjarva You're welcome
@mca62511 I've more inelegent solution than yours, lol
I think your solution is very good.
Claire Walker
@kjarva
Mar 08 2016 07:29
@krua so in idiot terms (me, not anyone else lol) hasOwnProperty() is simply checking boolean true or false if prop is there, whereas what we actually want it to do is check to see if the value of the string prop is there? Just checking I fully understand correctly
Richard Corbett
@reacorbett
Mar 08 2016 07:29
Working on my Random Quote Machine and I am lost.
Michael Aubrey
@mca62511
Mar 08 2016 07:30
@krua thanks :p 
CamperBot
@camperbot
Mar 08 2016 07:30
mca62511 sends brownie points to @krua :sparkles: :thumbsup: :sparkles:
:star: 356 | @krua | http://www.freecodecamp.com/krua
Richard Corbett
@reacorbett
Mar 08 2016 07:30
@hallidude I'm a rebel
Gaurav Prabhu
@Gauravp15
Mar 08 2016 07:31
Yeah I'm still trying different ways
:D
Richard Corbett
@reacorbett
Mar 08 2016 07:31
@Gauravp15 read @kjarva a few lines up.
Kristoforus Rua
@kru
Mar 08 2016 07:32
@kjarva yeah, You've seem fully understand it.
Claire Walker
@kjarva
Mar 08 2016 07:33
perfect :D I love the help channel. Helping other people in here has actually helped me learn so much
Gaurav Prabhu
@Gauravp15
Mar 08 2016 07:34
So should I use 2 if conditions in the beginning?
I don't understand if its logically right then why I'm I not getting the answer. Damn! :P
Richard Corbett
@reacorbett
Mar 08 2016 07:35
@Gauravp15 try using an if statement inside an if statement instead of &&.
Gaurav Prabhu
@Gauravp15
Mar 08 2016 07:36
I did that too still unsuccessful :(
Richard Corbett
@reacorbett
Mar 08 2016 07:38
@Gauravp15 post your code again. but not the contact list part
Matthew Stettner
@mstettner
Mar 08 2016 07:38
Im stuggling on the challenge "GLobal Scope and function"
any pointers?
// Declare your variable here
var myGlobal = [10];

function fun1(5) {
  // Assign 5 to oopsGlobal Here
 function oopsGlobal(5); 
}
Richard Corbett
@reacorbett
Mar 08 2016 07:39
What part are you struggling with?
@mstettner
Elbert Cortez
@trip16661
Mar 08 2016 07:40

Fix the variable declarations and assignments so their names use camelCase.// Declarations
var StUdLyCapVaR;
var properCamelCase;
var TitleCaseOver;

// Assignments
STUDLYCAPVAR = 10;
PRoperCAmelCAse = "A String";
tITLEcASEoVER = 9000;

Matthew Stettner
@mstettner
Mar 08 2016 07:40
@reacorbett I'm not to familar with all the lingo
Archi
@Archiess
Mar 08 2016 07:40
how to send code here?
Elbert Cortez
@trip16661
Mar 08 2016 07:40
what should i do there? I'm kinda noob D:
Vantrav
@vantrav
Mar 08 2016 07:40
help format
CamperBot
@camperbot
Mar 08 2016 07:40

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Matthew Stettner
@mstettner
Mar 08 2016 07:40
so im not sure exactly how to set everything up @reacorbett
Richard Corbett
@reacorbett
Mar 08 2016 07:40
var myGlobal = [10]. ten is an array the way it is right now.
help global scope
CamperBot
@camperbot
Mar 08 2016 07:41

:point_right: challenge global scope and functions [wiki]

Challenge: Global Scope and Functions

In JavaScript, scope refers to the visibility of variables. Variables which are defined outside of a function block have Global scope. This means, they can be seen everywhere in your JavaScript code.

Variables which are used without the var keyword are automatically created in the global scope. This can create unintended consequences elsewhere in your code or when running a function again. You should always declare your variables with var.
:pencil: read more about challenge global scope and functions on the FCC Wiki

Richard Corbett
@reacorbett
Mar 08 2016 07:41
@mstettner read that
Matthew Stettner
@mstettner
Mar 08 2016 07:41
k reading
Gaurav Prabhu
@Gauravp15
Mar 08 2016 07:42
```
Claire Walker
@kjarva
Mar 08 2016 07:42
@Gauravp15 if you're struggling with the nested loops, this might help. I made it for myself when learning them so I understood it properly https://drive.google.com/file/d/0B-Oo8VaE4o9mSG14eGNwVllCZlU/view?usp=sharing
Gaurav Prabhu
@Gauravp15
Mar 08 2016 07:42
for(var i = 0; i < contacts.length; i++){
    if(firstName == contacts[i].firstName){
      if(contacts[i].hasOwnProperty(prop)){
        return contacts[i].prop;        
      }
    }
    else if(firstName !== contacts[i].firstName){
      return "No such contact";
    }
    else if(!contacts[i].hasOwnProperty(prop)){
      return "No such property";
    }
  }
Her you go @reacorbett
Matthew Stettner
@mstettner
Mar 08 2016 07:42
@reacorbett yeah Ive read that before its in the instructions
Richard Corbett
@reacorbett
Mar 08 2016 07:43
@mstettner do you understand what global scope is?
Matthew Stettner
@mstettner
Mar 08 2016 07:43
@reacorbett ```js
// Declare your variable here
myGlobal = [10];

function fun1(5) {
  // Assign 5 to oopsGlobal Here
 function oopsGlobal(5); 
}
its without the var
Archi
@Archiess
Mar 08 2016 07:43
don't worj
work*
Elbert Cortez
@trip16661
Mar 08 2016 07:43

3backticks
// Declarations
var StUdLyCapVaR;
var properCamelCase;
var TitleCaseOver;

// Assignments
STUDLYCAPVAR = 10;
PRoperCAmelCAse = "A String";
tITLEcASEoVER = 9000;
3backticks

can anyone help me ? I can't understand what should i do D:

Richard Corbett
@reacorbett
Mar 08 2016 07:44
@Gauravp15 .hasOwnProperty() is checking for Boolean. try using [prop] instead
Matthew Stettner
@mstettner
Mar 08 2016 07:44
what does initialize mean? instructions want me to Initialize myGlobal to have a value of 10
how would I do that? @reacorbett
Richard Corbett
@reacorbett
Mar 08 2016 07:44
no. remove the brackets around 10. @mstettner and read this to understand what global scope is.
http://www.w3schools.com/js/js_scope.asp
Matthew Stettner
@mstettner
Mar 08 2016 07:45
should a Global be colored white?
Richard Corbett
@reacorbett
Mar 08 2016 07:45
When you put brackets around an variable it becomes an array. @mstettner