These are chat archives for FreeCodeCamp/HelpJavaScript

28th
Jan 2016
venit2
@venit2
Jan 28 2016 00:02
@saffront why is your askForAddress function inside your takeOrder function?
Jia Shern Tan
@saffront
Jan 28 2016 00:03
@venit2 no idea, the aim of the exercise is just to solve the reference error problem
venit2
@venit2
Jan 28 2016 00:04
@saffront I am new but I don't think the function call can see the function because of scope
Jocelyn
@jocelyn-ong
Jan 28 2016 00:06
@saffront you didn't call the takeOrder() function, so askForAddress() can't be called
theesaltines
@theesaltines
Jan 28 2016 00:08
I'm on "Accessing Objects Properties with Variables" and I don't seem to be doing the right thing
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;       // Change this Line
var player = "Montana";   // Change this Line
testObj[16];
Jia Shern Tan
@saffront
Jan 28 2016 00:10
@jocelyn-ong I call the function like so? takeOrder.askForAddress();
venit2
@venit2
Jan 28 2016 00:10
@saffront dont forget brackets () after takeOrder... i think lol
Jia Shern Tan
@saffront
Jan 28 2016 00:10
@venit2 I kinda understand it, it's not visible in the global scope.. but not sure where to place it
Jocelyn
@jocelyn-ong
Jan 28 2016 00:11
@saffront or you can call askForAddress() inside takeOrder(), then just set your var address = takeOrder()
venit2
@venit2
Jan 28 2016 00:11
@saffront you should be able to call it i think like outSideFunctionName().insideFunctionName()
Aleksander Gębicki
@Takumar
Jan 28 2016 00:11

@theesaltines try to do something with that lines:

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

make one of these two, add playerNumber variable to it ;-)

Jocelyn
@jocelyn-ong
Jan 28 2016 00:12
@saffront like so
deliverProduct();

function deliverProduct() {
  var address = askForAddress();
}

function takeOrder() {
  function askForAddress() {
    var address = {
      houseNumber: '20',
      street: 'Bond Street',
      city: 'London',
      country: 'United Kingdom'
    };

    return address;
  }
}
sorry
entered too fast!
deliverProduct();

function deliverProduct() {
  var address = takeOrder();
}

function takeOrder() {
  function askForAddress() {
    var address = {
      houseNumber: '20',
      street: 'Bond Street',
      city: 'London',
      country: 'United Kingdom'
    };

    return address;
  }
   askForAddress();
}
Jia Shern Tan
@saffront
Jan 28 2016 00:14
@jocelyn-ong ah I get it! Because askForAddress isn't in the global scope, it's within a function. Thanks for your help! @venit2
CamperBot
@camperbot
Jan 28 2016 00:14
saffront sends brownie points to @jocelyn-ong and @venit2 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for venit2
:star: 440 | @jocelyn-ong | http://www.freecodecamp.com/jocelyn-ong
Enrique Cahua
@enriquecahua
Jan 28 2016 00:15
@theesaltines you're not using the bracket notation the problem is asking for when referring to player
theesaltines
@theesaltines
Jan 28 2016 00:15

@theesaltines try to do something with that lines:

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

make one of these two, add playerNumber variable to it ;-)

Can anyone translate this into working English?

@enriquecahua Here are the instructions "Use the playerNumber variable to lookup player 16 in testObj using bracket notation."
JackeL
@jackel27
Jan 28 2016 00:20
Finished
took an hour?
@Takumar ?
Enrique Cahua
@enriquecahua
Jan 28 2016 00:22
@theesaltines
This message was deleted
var playerNumber;       //var playerNumber = NumberYouWantToLookUp
var player = testObj;   // use bracket notation to refer testObj[WhateverYouWantToLookUp];
JackeL
@jackel27
Jan 28 2016 00:23
@Takumar took 45 min... I think I had a nice creative edge on this one..
Who out there that's willing to criticize some code?
Aleksander Gębicki
@Takumar
Jan 28 2016 00:24
@theesaltines sorry I have to go :sleeping: I see that I am tired already I wanted to write that the other way :-) but I hope you know what to do now.
@jackel27 congratulations! :thumbsup:
JackeL
@jackel27
Jan 28 2016 00:25
@Takumar take care!
theesaltines
@theesaltines
Jan 28 2016 00:26
@enriquecahua The last condition to passing the waypoint is not complete. It still says I need to "use bracket notation to access testObj "
Aleksander Gębicki
@Takumar
Jan 28 2016 00:27
@theesaltines I wanted to give you a hint, that you should create one line of code: var player = ...
testObj[16]; gives you name of the player from thetestObj object, so you have to assign this to the player variable.
But there is also one more point. You shouldn't use 16 as name of property, because you sometimes want to get access to other players, so use playerNum variable as key.
Enrique Cahua
@enriquecahua
Jan 28 2016 00:28
@theesaltines yes, use testObj[] and insert the variable you created the line above it, the variable with the number you want to look up
theesaltines
@theesaltines
Jan 28 2016 00:30
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;       // Change this Line
var player = testObj[16];   // Change this Line
seems like that's what you guys are asking me to do.
still: "You should use bracket notation to access testObj "
Enrique Cahua
@enriquecahua
Jan 28 2016 00:30
@theesaltines don't insert the actual number, insert the variable name that you just assigned that number
theesaltines
@theesaltines
Jan 28 2016 00:32
@enriquecahua thanks, I swear to Jeebus I tried that already
CamperBot
@camperbot
Jan 28 2016 00:32
theesaltines sends brownie points to @enriquecahua :sparkles: :thumbsup: :sparkles:
:star: 312 | @enriquecahua | http://www.freecodecamp.com/enriquecahua
Enrique Cahua
@enriquecahua
Jan 28 2016 00:32
@theesaltines np
Ishan Jain
@ishanjain28
Jan 28 2016 00:48
I am stuck on factorialize a number.
here is the code I have written and I need help.
function factorialize(num) {
var i = 1;
  if(num === 0)  {
  return 1;
} else {
  for(i = 1; i < num; i++)  {
    var product;
    product *= i;
    return product;
  }
 }
}

factorialize(5);
Enrique Cahua
@enriquecahua
Jan 28 2016 00:51
@ishanjain28 I used a recursive function, and passed num-1, unless the num was 0
venit2
@venit2
Jan 28 2016 00:51
@ishanjain28 lets walk through the code with 5 as parameter....
Ishan Jain
@ishanjain28
Jan 28 2016 00:52
@enriquecahua I tried to do it via recursion. and it gave me an internal error: too much recursion.
venit2
@venit2
Jan 28 2016 00:53
@ishanjain28 If check fails, checks else, creates var product... but not initialized
Ishan Jain
@ishanjain28
Jan 28 2016 00:54

@venit2 THANKS! that solved the problem.. Here is the corrected version..

function factorialize(num) {
var i = 1;
  var product =1;
  if(num === 0)  {
  return 1;
} else {
  for(i = 1; i <= num; i++)  {

    product *= i;
  }
 }
  return product;
}

factorialize(5);

i realised that if I pass 5 through it. it was going to jump out at the return statement and the for loop would be useless.. so I changed it a bit. and it worked! thanks for that!

CamperBot
@camperbot
Jan 28 2016 00:54
ishanjain28 sends brownie points to @venit2 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for venit2
venit2
@venit2
Jan 28 2016 00:54
then you * by i (which is 1) and set it back to product, and return product (which stops the loop
@ishanjain28 gj
Enrique Cahua
@enriquecahua
Jan 28 2016 00:55
@ishanjain28 strange that it did not work for you
return (num > 0) ? num * factorialize(num-1) : 1;
Ishan Jain
@ishanjain28
Jan 28 2016 00:56
@enriquecahua Oops.. I was doing
num * factorialize(num);
James
@dev15firkin
Jan 28 2016 00:57

```js
var Bike = function(getGear, setGear) {

// Only change code below this line.
var gear = 0;
this.setGear = function(change){
gear += change;
};
this.getGear = function(){
return gear;
};
};

var myCar = new Car();

var myBike = new Bike();

``` I'm not sure why this runs and works. I'm on make object properties private.

var Bike = function(getGear, setGear) {

  // Only change code below this line.
var gear = 0;
  this.setGear = function(change){
    gear += change;
  };
  this.getGear = function(){
   return gear; 
  };
};

var myCar = new Car();

var myBike = new Bike();
Ishan Jain
@ishanjain28
Jan 28 2016 00:58
@dev15firkin change the line
gear += change to gear = change
because you are not doing a increment in gear you are just changing it to the new value
James
@dev15firkin
Jan 28 2016 00:59
ok I see, it just threw me off a good bit when it ran and passed
@ishanjain28 thanks
CamperBot
@camperbot
Jan 28 2016 01:00
dev15firkin sends brownie points to @ishanjain28 :sparkles: :thumbsup: :sparkles:
:star: 254 | @ishanjain28 | http://www.freecodecamp.com/ishanjain28
stacyHere
@stacyHere
Jan 28 2016 01:16

Hi everyone, I could really use some help figuring out why this code only seems to run twice.

function chunk(arr, size) {
  var arrNew = [];
  for(var i=0;i<arr.length;i++){
    var arrS = arr.splice(0,size);
    arrNew.push(arrS);
  }
  return arrNew;
}
chunk([0, 1, 2, 3, 4, 5, 6], 3);

```

Brendan Kinahan
@BKinahan
Jan 28 2016 01:21
@stacyHere you’re changing the length of arr within the loop, reducing the number of times it can loop
@stacyHere splice() changes the content of the array you call it on
stacyHere
@stacyHere
Jan 28 2016 01:23
I was thinking that's what I so that it slowly dwindles down from arr and goes into arrNew? What am I missing in my thought process?
Brendan Kinahan
@BKinahan
Jan 28 2016 01:24
@stacyHere by the time i=2, it’s longer than the single element remaining in arr (arr.length = 1 which i is greater than)
@stacyHere so the remaining 6 at the end of arr isn’t processed because the contents of the loop just don’t get looked at.
venit2
@venit2
Jan 28 2016 01:25
@stacyHere you might want to use a while loop... while not empty
Brendan Kinahan
@BKinahan
Jan 28 2016 01:26
@stacyHere or consider starting i at zero but increasing by size each time through the loop, and using some method that does not change the original array.
stacyHere
@stacyHere
Jan 28 2016 01:26
/lurk thanks @BKinahan and thanks @venit2
CamperBot
@camperbot
Jan 28 2016 01:26
stacyhere sends brownie points to @bkinahan and @venit2 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for venit2
:star: 754 | @bkinahan | http://www.freecodecamp.com/bkinahan
stacyHere
@stacyHere
Jan 28 2016 01:28
@BKinahan so you're saying splice is changing arr.length that is in the actual for loop? I'm jsut trying to let this sink in
@venit2 the while loop works
roserob
@roserob
Jan 28 2016 01:33

hey all, I dont understand why this isn't working. The question is:* Assign the value 7 to variable a.

Assign the contents of a to variable b.*

why is the answer not: "a = 7;"

b = a
Enrique Cahua
@enriquecahua
Jan 28 2016 01:34
@roserob
a =7;
b = a;
@roserob forgot the semi-colon?
Edward Choi
@eddiechoii
Jan 28 2016 01:36
Hi guys Im working with javascript and had a question
if a global variable is declared outside a function
while writing the function can i reference the global variable?

var count = 0;

function cc(card) {
// Only change code below this line
if (card ){
var count = count + 1

just an example function but if i were to try and add or subtract from the gobal var count how do i reference it in the function
Enrique Cahua
@enriquecahua
Jan 28 2016 01:40
@eddiechoii I see no issue
Brian
@sludge256
Jan 28 2016 01:41
just reference it by name
but don't declare a local variable with the same name
Enrique Cahua
@enriquecahua
Jan 28 2016 01:41

```JS var carName = "Volvo";
myFunction();

function myFunction() {
document.getElementById("demo").innerHTML =
"I can display " + carName;

Ken Haduch
@khaduch
Jan 28 2016 01:55
@eddiechoii - if you have declared the variable as a global, you can reference it from within the functions, but you do not want to use the var keyword within the function, because that declares a new variable within the scope of the function. Why don't you try that and see if it works?
JackeL
@jackel27
Jan 28 2016 01:56
woo, made it to the chunky monkey. This is where I will pause until tomorrow. Thanks for all the criticism everyone.
Pete Considine
@pjconsidine
Jan 28 2016 01:56
hi everyone
wondering if anyone can help me understand the "divide and conquer" approach I see mentioned on StackOverflow for testing array values
(specifically, I'm working on the Lowest Common Multiple challenge and not passing all the tests)
(most, but not the last one)
JackeL
@jackel27
Jan 28 2016 01:59
@pjconsidine divide and conquer, split ?
Pete Considine
@pjconsidine
Jan 28 2016 01:59
I actually don't know. People just say "use divide and conquer" without really explaining how to do that
so I'm totally clueless
my current code:
function smallestCommons(arr) {
    var i = Math.min(arr[0], arr[1]);
    var j = Math.max(arr[0], arr[1]);
    var sourceArray = [];

    while (i <= j) {
        sourceArray.push(i);
        i++;
    }

    var LCM = sourceArray[sourceArray.length-1] * sourceArray[sourceArray.length-2];

    for (var k = sourceArray.length - 2; k >= 0; k--) {
        if (Math.floor((LCM/sourceArray[k])% LCM) === (LCM/sourceArray[k])% LCM) {
            LCM = LCM;
        } else {
            LCM = LCM * sourceArray[k];
        }
    }
    return LCM;
}
Basically, it takes the biggest two numbers, multiplies them, and then tests to see if it's divisible by the rest of the numbers in the range
JackeL
@jackel27
Jan 28 2016 02:02
@pjconsidine okay, give me a few to see whats going on
you could try to use map and modulus?
Pete Considine
@pjconsidine
Jan 28 2016 02:03
yeah, I had thought about map
JackeL
@jackel27
Jan 28 2016 02:03
modulus takes the remainder correct?
or am I thinking of php...
Pete Considine
@pjconsidine
Jan 28 2016 02:03
no, I think you're right
or something like that. you can use it to see if a number is evenly divisible by another
Edward Choi
@eddiechoii
Jan 28 2016 02:04
@enriquecahua @sludge256 @khaduch thank you all!
CamperBot
@camperbot
Jan 28 2016 02:04
eddiechoii sends brownie points to @enriquecahua and @sludge256 and @khaduch :sparkles: :thumbsup: :sparkles:
:star: 316 | @enriquecahua | http://www.freecodecamp.com/enriquecahua
:star: 440 | @khaduch | http://www.freecodecamp.com/khaduch
:star: 1100 | @sludge256 | http://www.freecodecamp.com/sludge256
JackeL
@jackel27
Jan 28 2016 02:04
right
@pjconsidine so, could create a for loop, or map and check boolean of modulus?
Pete Considine
@pjconsidine
Jan 28 2016 02:04
basically, the problem I'm having is that I can find a common multiple, but it doesn't test to see if there's a smaller one
JackeL
@jackel27
Jan 28 2016 02:05
ahh
Pete Considine
@pjconsidine
Jan 28 2016 02:05
the for loop I have tests divisibility
but it doesn't know how to return a smaller one and I'm blanking on a way to rewrite it to work from smallest to largest instead of largest to smallest
JackeL
@jackel27
Jan 28 2016 02:06
@pjconsidine what about sending common multiples to array, then you could .. organize your array
Ken Haduch
@khaduch
Jan 28 2016 02:06

@jackel27

modulus takes the remainder correct?

Just to make the point that the % operator, technically called the "remainder" operator (I've learned, because it does not work for negative numbers, or has some problem with negative numbers) does give you the remainder of a positive number divided by another number. There is a modulus operator in other languages, too.

JackeL
@jackel27
Jan 28 2016 02:06
@pjconsidine sort it perhaps?
@pjconsidine then use pop() to retrieve lowest number in array, (which is last after sort)
Pete Considine
@pjconsidine
Jan 28 2016 02:07
@jackel27 do you know what I would do to create that array?
right now, my test just throws out numbers
JackeL
@jackel27
Jan 28 2016 02:07
well, lets say you had multiples
new array = array[].push(x); x being your new multiple
Pete Considine
@pjconsidine
Jan 28 2016 02:09
actually, I might have thought of a way
if I talk through the logic, you can let me know if I'm missing something.
take the first two numbers and multiply them. Then, test to see if the result is divisible by the next number in the array. If it is, cool. If not, multiply the result by the next number and repeat the process.
JackeL
@jackel27
Jan 28 2016 02:12
This message was deleted
  array = [];
  x = 25;
  array.push(x);
  return array;
Pete Considine
@pjconsidine
Jan 28 2016 02:12
yeah, I get that, @jackel27 . what I'm wondering is how to get the values to push onto the array
JackeL
@jackel27
Jan 28 2016 02:12
@pjconsidine let me look at your code again..
JackeL
@jackel27
Jan 28 2016 02:18
@pjconsidine what problem are you on?
Pete Considine
@pjconsidine
Jan 28 2016 02:20
Smallest Common Multiple
JackeL
@jackel27
Jan 28 2016 02:22
ah, thought it was familiar. I did this one.. let me check out what i did again
@pjconsidine This is my approach
function smallestCommons(arr) {
    for (i = Math.max(...arr); i >= Math.min(...arr); i--) arr.push(i);
    return arr.slice(2).reduce(function(x, y) {
        var a = x,
            b = y,
            t = 0;
        while (a % b) {
            a = a % b;
            t = a;
            a = b;
            b = t;
        }
        return x / b * y;
    });
}
smallestCommons([1, 5]);
JackeL
@jackel27
Jan 28 2016 02:30
@pjconsidine I hope it helps somewhat. I wish I had more time to spend on this, but I gotta get going.
Brian
@Brian984
Jan 28 2016 02:30
I'm working on the 'Title Case a Sentence' Challenge. And I can't seem to figure out/google why this isn't working. Can anyone lend a hand?
function titleCase(str) {
  var myArray = str.split(' ');

  for (var i = 0; i < myArray.length; i++) {
    for (var x = 0; x < myArray[i].length; x++) {
      if (myArray[i][0]) {
        myArray[i][0] = myArray[i][0].toUpperCase();
      }
      else {
        myArray[i][x] = myArray[i][x].toLowerCase();
      }
    }
  }

  var finalString = myArray.join(' ');

  return finalString;

}

titleCase("I'm a little tea pot");
Pete Considine
@pjconsidine
Jan 28 2016 02:31
@jackel27 So let me see if I understand what you did.
Sue
@Sueswebdesign
Jan 28 2016 02:32
result = "myAdjective "; + "myNoun "; + "myVerb "; + "myAdverb ";
Pete Considine
@pjconsidine
Jan 28 2016 02:33
Actually, can you explain what the "while" statement is doing?
rphares
@rphares
Jan 28 2016 02:33
close, @Sueswebdesign
Sue
@Sueswebdesign
Jan 28 2016 02:33
the above code is not working.
rphares
@rphares
Jan 28 2016 02:33
but, those don't go in quotes, @Sueswebdesign :blush:
quotes are for the string parts that you add,
Nathan Jensby
@nathanjensby
Jan 28 2016 02:33
What's a better way to do this?

function lookUp(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {

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

    return contacts[i][prop];

  }
    return "No such property";
    }
}
  if (contacts[0].firstName !== firstName && contacts[1].firstName !== firstName && contacts[2].firstName !== firstName && contacts[3].firstName !== firstName) {
    return "No such contact";
  }
// Only change code above this line
}
// Change these values to test your function
lookUp("Harry", "address");
by "this" I mean the "No such contract" part.
Pete Considine
@pjconsidine
Jan 28 2016 02:34
@jackel27 Sorry, but I have to go. if you don't mind, I'll grab your code and try to understand it on my own, okay?
thanks @jackel27
CamperBot
@camperbot
Jan 28 2016 02:34
pjconsidine sends brownie points to @jackel27 :sparkles: :thumbsup: :sparkles:
:star: 266 | @jackel27 | http://www.freecodecamp.com/jackel27
rphares
@rphares
Jan 28 2016 02:34
you will need to use some " " to put the spaces in between the myNoun, myAdjective.... but they themselves don't need them, it makes them strings :) @Sueswebdesign
JackeL
@jackel27
Jan 28 2016 02:34
@pjconsidine no problem, I also gotta head out
Tridev
@TridevGuha
Jan 28 2016 02:35
how to share freecodecamp challenges and solutions with github as repository?
JackeL
@jackel27
Jan 28 2016 02:35
@TridevGuha Screenshot commit :D
@TridevGuha I don't think they want to make it easy to do that.
Tridev
@TridevGuha
Jan 28 2016 02:37
:)
@jackel27 no way to create a repository of all my codes?
Sue
@Sueswebdesign
Jan 28 2016 02:39
I am afraid I am stuck.
Jocelyn
@jocelyn-ong
Jan 28 2016 02:39
@nathanjensby if you're already checking if contacts[i].firstname === firstName, you should be able to just to an (ELSE), without having to create a new (IF)
Nicole Borgaard
@Borgaard
Jan 28 2016 02:39
@TridevGuha you can create a repo with your FCC code
rphares
@rphares
Jan 28 2016 02:40
@Sueswebdesign , lets try an example,
matthew3454
@matthew3454
Jan 28 2016 02:40
If someone can help me on the Waypoint: Record Collection that would be appreciated. I'm at a loss.
Nicole Borgaard
@Borgaard
Jan 28 2016 02:40
@TridevGuha do you know how to use Git? are you comfortable with terminal?
rphares
@rphares
Jan 28 2016 02:40
you already have yours in result, so... @Sueswebdesign
result = "My" + " " + myNoun + " " + myAdjective + " " ... etc
Parts of that you want to use as a string (that WONT change, no matter what you give the function) need quotes. For example, the spaces. Parts that will change depending on what you give the function (myNoun, myAdjective, etc) can't have quotes. If you put them in quotes, they become strings... :)
Kelsey
@kcdilla
Jan 28 2016 02:42
I'm having some trouble with Stand in Line
Bill
@kirah1314
Jan 28 2016 02:43
@Brian984 your codes are trying to mutate a string but strings are immutable (you can't change the "h" in "hello"), you have to replace the whole array's element with a new string (change "hello" with "jello"). Does that make sense?
Kelsey
@kcdilla
Jan 28 2016 02:43
I managed to push the number onto the end of the array, and shift off the first item in the array
Pandarati
@Pandarati
Jan 28 2016 02:43
@matthew3454 @kcdilla Sure, can you guys post your code?
help formatting code
CamperBot
@camperbot
Jan 28 2016 02:43
no wiki entry for: formatting code
Kelsey
@kcdilla
Jan 28 2016 02:43

function queue(arr, item) {
// Your code here
$(arr).push(item).shift();
return ; // Change this line
}

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

rphares
@rphares
Jan 28 2016 02:43
explain format
CamperBot
@camperbot
Jan 28 2016 02:43

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

CharmedSatyr
@CharmedSatyr
Jan 28 2016 02:43
wiki seek and destroy
CamperBot
@camperbot
Jan 28 2016 02:43

:point_right: bonfire seek and destroy [wiki]

Explanation:

This problem is a bit tricky because you have to familiarize yourself with Arguments, as you will have to work with two or more but on the script you only see two. Many people hardcode this program for three arguments. You will remove any number from the first argument that is the same as any other other arguments.

:pencil: read more about bonfire seek and destroy on the FCC Wiki

Kelsey
@kcdilla
Jan 28 2016 02:44
function queue(arr, item) {
  // Your code here
  $(arr).push(item).shift();
  return ;  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];
I'm stuck on how to return just that first item i shifted off
Mike Baker
@Bakermg
Jan 28 2016 02:44
help profile lookup
CamperBot
@camperbot
Jan 28 2016 02:44

:point_right: checkpoint profile lookup [wiki]

Checkpoint: Profile Lookup

Instructions

We have an array of objects representing different people in our contacts lists.

A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you.

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

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

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

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

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

:pencil: read more about checkpoint profile lookup on the FCC Wiki

Jocelyn
@jocelyn-ong
Jan 28 2016 02:44
@kcdilla you can either return array.shift() or set var x = array.shift() and return x
Pandarati
@Pandarati
Jan 28 2016 02:45
When you use arr.shift() it returns the item shifted
Kelsey
@kcdilla
Jan 28 2016 02:45
i tried returning array.shift() but it just gave me the whole array, minus the first item
hmm maybe i did it wrong
thanks @jocelyn-ong i'll try again
CamperBot
@camperbot
Jan 28 2016 02:45
kcdilla sends brownie points to @jocelyn-ong :sparkles: :thumbsup: :sparkles:
:star: 442 | @jocelyn-ong | http://www.freecodecamp.com/jocelyn-ong
Pandarati
@Pandarati
Jan 28 2016 02:45
@kcdilla The arr.shift() method returns the item deleted
Mike Baker
@Bakermg
Jan 28 2016 02:45
help Profile Lookup
CamperBot
@camperbot
Jan 28 2016 02:45

:point_right: checkpoint profile lookup [wiki]

Checkpoint: Profile Lookup

Instructions

We have an array of objects representing different people in our contacts lists.

A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you.

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

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

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

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

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

:pencil: read more about checkpoint profile lookup on the FCC Wiki

Nicole Borgaard
@Borgaard
Jan 28 2016 02:46
@kcdilla break that up into two sections: pushing the num onto the array, then shifting the front of the array.
Bill
@kirah1314
Jan 28 2016 02:46
@kcdilla about 10 challenges before the one you're working on now are challenges about the push and shift methods, maybe refresh yourself by looking through them again?
Brian
@Brian984
Jan 28 2016 02:46
@kirah1314 If I split the initial string up into an array for each individual character, would i be able to change it then?
Sue
@Sueswebdesign
Jan 28 2016 02:46
var myStr = "big "; "dog "; "ran "; "quickly ";
result = myAdjective, + myNoun, + myVerb, + myAdverb;
```
Nicole Borgaard
@Borgaard
Jan 28 2016 02:46
@kirah1314 it's okay to give a helpful reminder here...
Jocelyn
@jocelyn-ong
Jan 28 2016 02:47
@Sueswebdesign the objective of the exercise is to create a sentence with more than X number of words, and with spaces between each word
Pandarati
@Pandarati
Jan 28 2016 02:47
@Sueswebdesign For that challenge, you are creating a string and you are concating, you use "+", your variables into the string according to their name. myVerb will go where the verb belongs and etc
Jocelyn
@jocelyn-ong
Jan 28 2016 02:47
@Sueswebdesign currently, your result does not have other words, and neither does it have any spaces between the existing words
Bill
@kirah1314
Jan 28 2016 02:47
@Brian984 yes because then each array is a single letter string element but you'll be over complicating the challenge
Mike Baker
@Bakermg
Jan 28 2016 02:48
//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[0].length; i ++) {

    if (firstName == contacts[i].firstName) {
      return contacts[i][prop];
    }
}

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

// Only change code above this line


// Change these values to test your function
lookUp("Akira", "likes");
Nathan Jensby
@nathanjensby
Jan 28 2016 02:48
@jocelyn-ong Ahhh it was where I was putting the "return 'No such contract'" when I tried that way. Thanks @jocelyn-ong
CamperBot
@camperbot
Jan 28 2016 02:48
nathanjensby sends brownie points to @jocelyn-ong and @jocelyn-ong :sparkles: :thumbsup: :sparkles:
:star: 443 | @jocelyn-ong | http://www.freecodecamp.com/jocelyn-ong
:star: 443 | @jocelyn-ong | http://www.freecodecamp.com/jocelyn-ong
Mike Baker
@Bakermg
Jan 28 2016 02:48
trying to get this to work with no luck
Bill
@kirah1314
Jan 28 2016 02:48
@Borgaard I'm not sure I understand what you mean?
Mike Baker
@Bakermg
Jan 28 2016 02:49
has anyone solved this that could give me some insight
Brian
@Brian984
Jan 28 2016 02:49
@kirah1314 Yea now that I think about it, that would be overcomplicating things. I'll think about it some more. What you said makes sense though. Thanks!
CamperBot
@camperbot
Jan 28 2016 02:49
brian984 sends brownie points to @kirah1314 :sparkles: :thumbsup: :sparkles:
:star: 883 | @kirah1314 | http://www.freecodecamp.com/kirah1314
Bill
@kirah1314
Jan 28 2016 02:49
@Brian984 would you like some hints or play around with it some more?
@Brian984 you really just need one loop
Ishan Jain
@ishanjain28
Jan 28 2016 02:49
@Bakermg remove the contacts[0].length in for loop and replace it with contacts.length. and there should be no spaces in 'i++'. your's has a space there.
Brian
@Brian984
Jan 28 2016 02:50
@kirah1314 I'm going to try to use .charAt instead. I'll play around with that.
Pandarati
@Pandarati
Jan 28 2016 02:50
@Bakermg A cool little tip is to "sift" the info and have a certain string as you default return
Bill
@kirah1314
Jan 28 2016 02:50
@Brian984 sounds good, gl :thumbsup:
Mike Baker
@Bakermg
Jan 28 2016 02:53
so when i remove the contacts[0].length to contacts.length and change the i++ it iterates through the names but now fails the other test for no such contact and no such property
@Pandarati what do you mean "sift"
Pandarati
@Pandarati
Jan 28 2016 02:55
@Bakermg You have the right idea. Just go through the information. If nothing triggered, setup a default return.
Ishan Jain
@ishanjain28
Jan 28 2016 02:56
@Bakermg your if/else statements are not properly written. conditions are okay. and the for loop is now okay. fix the if/else statements..
Kelsey
@kcdilla
Jan 28 2016 02:56
I'm back! Still haven't figured out Stand in Line. I keep getting "RangeError: Maximum call stack size exceeded"
Bill
@kirah1314
Jan 28 2016 02:56
@kcdilla refresh your browser
Kelsey
@kcdilla
Jan 28 2016 02:57
function queue(arr, item) {
  // Your code here
  $(arr).push(item);

  return $(arr).shift();  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
ok
Pandarati
@Pandarati
Jan 28 2016 02:57
@kcdilla Refresh your brower. If that didn't work, clear your cache
Kelsey
@kcdilla
Jan 28 2016 02:57
clearing cache.... @Pandarati
Bill
@kirah1314
Jan 28 2016 02:58
@kcdilla you'll have to remove $( ) since arr isn't jQuery
Kelsey
@kcdilla
Jan 28 2016 02:59
@kirah1314 gotcha... thanks
CamperBot
@camperbot
Jan 28 2016 02:59
kcdilla sends brownie points to @kirah1314 :sparkles: :thumbsup: :sparkles:
:star: 884 | @kirah1314 | http://www.freecodecamp.com/kirah1314
Pandarati
@Pandarati
Jan 28 2016 02:59
@kirah1314 is right, you're getting this error from personal code. It's not your browser.
However, if you get the error again and your code is correct. Do consider refreshing and clearing cache
Kelsey
@kcdilla
Jan 28 2016 03:01

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

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

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

sorry here:
function queue(arr, item) {
  // Your code here
  arr.push(item);
  return arr.shift();  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Bill
@kirah1314
Jan 28 2016 03:01
@kcdilla that looks good :thumbsup:
Kelsey
@kcdilla
Jan 28 2016 03:02
@kirah1314 Still can't get it to work though, and I refreshed and cleared the cache
Bill
@kirah1314
Jan 28 2016 03:02
@kcdilla refresh again, it has errors when the code is incorrect and you click run tests
Kelsey
@kcdilla
Jan 28 2016 03:03
@kirah1314 omg it worked
Jeremy Roe
@jeremyroe
Jan 28 2016 03:03
anyone have a minute to look over my smallestCommons code? My array for each seems to be skipping elements and I can’t figure out why
Bill
@kirah1314
Jan 28 2016 03:03
@kcdilla :)
Ishan Jain
@ishanjain28
Jan 28 2016 03:03
@jeremyroe sure, go ahead.
Kelsey
@kcdilla
Jan 28 2016 03:04
still not sure why - i might stare at it some more til I understand. but thanks @kirah1314 !
CamperBot
@camperbot
Jan 28 2016 03:04
kcdilla sends brownie points to @kirah1314 :sparkles: :thumbsup: :sparkles:
:warning: kcdilla already gave kirah1314 points
Jeremy Roe
@jeremyroe
Jan 28 2016 03:04
function smallestCommons(arr) {  
  var start;
  var end;
  var mult1 = [];
  var mult2 = [];
  var pendings = [];
  var betweens = [];

  if(arr[0] > arr[1]){
    start = arr[1];
    end = arr[0];
  } else {
    start = arr[0];
    end = arr[1];
  }

  for(var i = 0; i <= end; i++){
    if(i > start && i < end){
      betweens.push(i);
    }
  }

  for(var m1 = 1; m1 <= 10000; m1++){
    mult1.push(arr[0] * m1);
  }

  for(var m2 = 1; m2 <= 10000; m2++){
    mult2.push(arr[1] * m2);
  }

  mult1.forEach(function(val){
    if(mult2.indexOf(val) !== -1){
      pendings.push(val);
    }
  });

  console.log(pendings);

  pendings.forEach(function(pen){
    if(pendings.indexOf(pen) !== -1){
    console.log("Pending " + pen);
    betweens.forEach(function(bet){
      if(pendings.indexOf(pen) !== -1){
        console.log("Between " + bet);
        if(pen % bet !== 0){
            console.log("Removing " + pen);
            pendings.splice(pendings.indexOf(pen),1);
        }
      }
    });
    }
  });

  console.log(betweens);
  console.log(pendings);
}


smallestCommons([1,5]);
Kelsey
@kcdilla
Jan 28 2016 03:04
ok so every time I tell someone thanks I give brownie points?
I'm new.
jpg8127
@jpg8127
Jan 28 2016 03:04
yeah
rphares
@rphares
Jan 28 2016 03:04
kinda, you can only thank the same person once per hour, @kcdilla
CamperBot
@camperbot
Jan 28 2016 03:04
rphares sends brownie points to @kcdilla :sparkles: :thumbsup: :sparkles:
:star: 179 | @kcdilla | http://www.freecodecamp.com/kcdilla
Bill
@kirah1314
Jan 28 2016 03:04
@kcdilla the maximum stack error is a commonly known issue right now, it has nothing to do with your codes though
Jeremy Roe
@jeremyroe
Jan 28 2016 03:04
whats happening is that every time my forEach on line 39 runs it’s running through my array checking each element - but it seems to skip 10’s,20’s,30’s etc
so my result is bad because of it
rphares
@rphares
Jan 28 2016 03:04
and only when you tag the by name, @kcdilla
if i say thanks jpg8127, jpg8127 gets nothing,
thank you, @jpg8127 , however :)
CamperBot
@camperbot
Jan 28 2016 03:05
rphares sends brownie points to @jpg8127 :sparkles: :thumbsup: :sparkles:
:star: 322 | @jpg8127 | http://www.freecodecamp.com/jpg8127
jpg8127
@jpg8127
Jan 28 2016 03:05
lol
rphares
@rphares
Jan 28 2016 03:06
(oh, c'mon, @cbot, don't be slow when demonstrating!)
jpg8127
@jpg8127
Jan 28 2016 03:06
why when I paste someone's code in it is almost never pastes new lines
Jeremy Roe
@jeremyroe
Jan 28 2016 03:06
what do you mean @jpg8127?
rphares
@rphares
Jan 28 2016 03:06
what do you mean?
Jeremy Roe
@jeremyroe
Jan 28 2016 03:06
you need to put code between ``` to format it right
jpg8127
@jpg8127
Jan 28 2016 03:06
I mean into the editor thing
on the lessons
@jeremyroe I tried to paste your code but its all on like 4 lines
Jeremy Roe
@jeremyroe
Jan 28 2016 03:07
oh . . . yeah it’s funny even when I copy paste lines it indents them odd
Ishan Jain
@ishanjain28
Jan 28 2016 03:07
@jeremyroe umm.. no Idea about your code. haven't reached there yet.
jpg8127
@jpg8127
Jan 28 2016 03:07
function smallestCommons(arr) { var start; var end; var mult1 = []; var mult2 = []; var pendings = []; var betweens = []; if(arr[0] > arr[1]){ start = arr[1]; end = arr[0]; } else { start = arr[0]; end = arr[1]; } for(var i = 0; i <= end; i++){ if(i > start && i < end){ betweens.push(i); } } for(var m1 = 1; m1 <= 10000; m1++){ mult1.push(arr[0] * m1); } for(var m2 = 1; m2 <= 10000; m2++){ mult2.push(arr[1] * m2); } mult1.forEach(function(val){ if(mult2.indexOf(val) !== -1){ pendings.push(val); } }); console.log(pendings); pendings.forEach(function(pen){ if(pendings.indexOf(pen) !== -1){ console.log("Pending " + pen); betweens.forEach(function(bet){ if(pendings.indexOf(pen) !== -1){ console.log("Between " + bet); if(pen % bet !== 0){ console.log("Removing " + pen); pendings.splice(pendings.indexOf(pen),1); } } }); } }); console.log(betweens); console.log(pendings); } smallestCommons([1,5]);
Jeremy Roe
@jeremyroe
Jan 28 2016 03:07
thanks for try @ishanjain28
CamperBot
@camperbot
Jan 28 2016 03:07
jeremyroe sends brownie points to @ishanjain28 :sparkles: :thumbsup: :sparkles:
jpg8127
@jpg8127
Jan 28 2016 03:07
that is what I see...
CamperBot
@camperbot
Jan 28 2016 03:07
:star: 255 | @ishanjain28 | http://www.freecodecamp.com/ishanjain28
Jeremy Roe
@jeremyroe
Jan 28 2016 03:08
weird @jpg8127 - maybe it’s how I copied it out? ALthough it formats right on gitter . . . what editor do you have a prettify function?
rphares
@rphares
Jan 28 2016 03:08
hmm, that is odd, i can do it... (sometimes indexing is off, but def not less lines...)
jpg8127
@jpg8127
Jan 28 2016 03:08
hmm.......
Jeremy Roe
@jeremyroe
Jan 28 2016 03:08
maybe I’ll try and use for iterator instead of foreach . . could be some weird bug
jpg8127
@jpg8127
Jan 28 2016 03:09
well I found out a way to fix the code faster at least
I copy and paste it into codepen then press the tidy button then copy and paste it into freecode camp
Kevin Lorincz
@kevinlorincz
Jan 28 2016 03:09
Hey im having trouble with the "Accessing Objects Properties with Variables" waypoint it says i need to use bracket notation to access testObj but i am
jpg8127
@jpg8127
Jan 28 2016 03:10
@kevinlorincz what do you have
Kevin Lorincz
@kevinlorincz
Jan 28 2016 03:10
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;       // Change this Line
var player = testObj[16];   // Change this Line
Andrew Bales
@agbales
Jan 28 2016 03:10
Hi all-- any thoughts on how to proceed with this?
function steamroller(arr) {
  var stringy = arr.toString('');
  var roller = [];

  for (var i=0; i < stringy.length; i+=2) {
    roller.push(stringy.charAt(i));
  }


  return roller.map(Number);  // works for nums, but not letter, char, or null
}

steamroller([1, [], [3, [[4]]]]);
Jeremy Roe
@jeremyroe
Jan 28 2016 03:10
nice @jpg8127 - they do have a good pretty function
jpg8127
@jpg8127
Jan 28 2016 03:11
@kevinlorincz you need to use the varaible in brackets not a number
Jeremy Roe
@jeremyroe
Jan 28 2016 03:12
Hi @agbales - where are you stuck? They are trying to get you to flatten nested arrays if I recall
Kevin Lorincz
@kevinlorincz
Jan 28 2016 03:12
@jpg8127 ohhhhhhhhh yeah i just got it now i put playerNumber instead of 16 on the last line thanks man!
CamperBot
@camperbot
Jan 28 2016 03:12
kevinlorincz sends brownie points to @jpg8127 :sparkles: :thumbsup: :sparkles:
:star: 323 | @jpg8127 | http://www.freecodecamp.com/jpg8127
Andrew Bales
@agbales
Jan 28 2016 03:13
@jeremyroe Yes, that's the one. So this is able to put it into a simple string, then push it to an array. The return maps it to Number rather than a "string"... but that doesn't solve the issues for letters or characters.
(removing map allows "a", "b", etc... but then numbers don't work!)
Tyler Hughes
@tylerbhughes
Jan 28 2016 03:13
Hey everyone...I'm working on the spinal tap case and I'm trying to do a replace the regex string with a hyphen plus a lowercase version of the original letter..after doing some googling I came across the RegEx $1 $2 $3, etc..is there another way of doing this? Because MDN says the feature is not standard.
Jeremy Roe
@jeremyroe
Jan 28 2016 03:13
Which challenge number is this one @agbales? I’ll refresh my memory
Andrew Bales
@agbales
Jan 28 2016 03:14
@jeremyroe It's called Steamroller. Near the end of  Intermediate Algorithm Scripting
Jeremy Roe
@jeremyroe
Jan 28 2016 03:14
Yeah @RandomlyKnighted I used 3 regex replaces and a couple splits + joins in order to get it right - I had to mess with getting the in the correct order in order to handle each use case - does that help?
jpg8127
@jpg8127
Jan 28 2016 03:15
@RandomlyKnighted are you asking if there is another way of doing spinal case without that $1 method?
Tyler Hughes
@tylerbhughes
Jan 28 2016 03:15
@jeremyroe sorta
@jpg8127 yes
Jocelyn
@jocelyn-ong
Jan 28 2016 03:15
@RandomlyKnighted here's a reference on regexp http://regexone.com/ hopefully this will help
jpg8127
@jpg8127
Jan 28 2016 03:15
@RandomlyKnighted well.. I did it without that method the first time but with that method I finished it in 1 line, without it it took me like 20 lines
Sidharth Kriplani
@sidkrip
Jan 28 2016 03:16
I have a problem in "Nesting For Loops". This code return null:
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i=0; i<arr.length; i++) {
    for(var j=0; j<arr[i].length; j++) {
      product=product*arr[j];
    }
  }  
  // Only change code above this line
  return product;
}
will someone help?
Jeremy Roe
@jeremyroe
Jan 28 2016 03:16
You might @agbales look at the underscore library source code for their flatten function - that’s exactly what it’s doing http://underscorejs.org/#flatten - I’m a couple away from hitting this challenge it looks like so I’ve not done it yet
Tyler Hughes
@tylerbhughes
Jan 28 2016 03:16
@jpg8127 I'm just having a hard time wrapping my mind around the $1, $2 stuff
Bill
@kirah1314
Jan 28 2016 03:16
@RandomlyKnighted you can use a bunch of replace methods
jpg8127
@jpg8127
Jan 28 2016 03:17
@RandomlyKnighted you mean.. like how to use it?
Tyler Hughes
@tylerbhughes
Jan 28 2016 03:17
yeah and just how it works in general..I got a bit confused when looking at the MDN example
Jocelyn
@jocelyn-ong
Jan 28 2016 03:17
@sidkrip check your inner for loop "j<arr[i].length"
Andrew Bales
@agbales
Jan 28 2016 03:17
@jeremyroe Wow! This looks much cleaner than the mozilla documentation I've been prowling around on. Thank you!
CamperBot
@camperbot
Jan 28 2016 03:17
agbales sends brownie points to @jeremyroe :sparkles: :thumbsup: :sparkles:
:star: 436 | @jeremyroe | http://www.freecodecamp.com/jeremyroe
Jeremy Roe
@jeremyroe
Jan 28 2016 03:18
@RandomlyKnighted I used a global regex replace 3 times and used split to normalize the inputs first
jpg8127
@jpg8127
Jan 28 2016 03:18
@RandomlyKnighted oh I still have both my methods
Jeremy Roe
@jeremyroe
Jan 28 2016 03:18
happy to have helped @agbales
jpg8127
@jpg8127
Jan 28 2016 03:18
function spinalCase(str) {

  //method 1
  return str.replace(/([a-z])([A-Z])/g,'$1 $2').replace(/[\s_]/g,'-').toLowerCase();

 //method 2
 var newStr = [];

 if(str.search(" ")<0 && str.search("_")<0){
  str = str.replace(/[\s_]/g,'-').split("");
  for(var i = 0; i<str.length;i++){
    if(str[i].charCodeAt()>=65 && str[i].charCodeAt()<=91){
      newStr.push("-");
      newStr.push(str[i]);
    }
    else{
      newStr.push(str[i]);
    }

  }
   str = newStr.join("");

  }
else{

 str = str.replace(/[\s_]/g,'-');
}

  return str.toLowerCase();

}
Tyler Hughes
@tylerbhughes
Jan 28 2016 03:18
here's what I have at the moment:
function spinalCase(str) {

  // Finds all capital letters
  var pattern = /[A-Z]/g;


  // Replaces spaces, and underscores with a hyphen
  var punctuationPattern = /\s|\_/ig;
  str = str.replace(punctuationPattern, "-");

  return str.toLowerCase();
}
jpg8127
@jpg8127
Jan 28 2016 03:19
str.replace(/([a-z])([A-Z])/g,'$1 $2') <<<<<<<< ([a-Z]) is $1 and then the next () is $2 its pretty simple
Tyler Hughes
@tylerbhughes
Jan 28 2016 03:19
what I currently have solves all but the one with no spaces or hyphens
Jeremy Roe
@jeremyroe
Jan 28 2016 03:19
@agbales a link to the annotated source of rhte actual code http://underscorejs.org/docs/underscore.html also
@RandomlyKnighted what I did for that one was split it on capital letters and add in the spaces on a join then send it thorugh the same regex replace as my others
Tyler Hughes
@tylerbhughes
Jan 28 2016 03:20
alright
Andrew Bales
@agbales
Jan 28 2016 03:22
@jeremyroe :) :+1:
James
@JamesR93
Jan 28 2016 03:23
Can someone help me with a problem?
rphares
@rphares
Jan 28 2016 03:23
What's up, @JamesR93 ?
People will certainly try :)
segun osinusi
@TheShogun
Jan 28 2016 03:24
@kcdilla I had the same issue. I ended up assigning arr.shift to a variable and returning said variable (sorry, I'm not sure how to copy/paste the code screen)
cannelflow
@cannelflow
Jan 28 2016 03:25
@prashcr thank you
CamperBot
@camperbot
Jan 28 2016 03:25
cannelflow sends brownie points to @prashcr :sparkles: :thumbsup: :sparkles:
:star: 388 | @prashcr | http://www.freecodecamp.com/prashcr
James
@JamesR93
Jan 28 2016 03:25
I'm on the "Profile Lookup" problem and I can't decide whether i need to use a nested if statement in a for loop or not? Confused.
Tyler Hughes
@tylerbhughes
Jan 28 2016 03:26
// Split on capitals
var pattern = /[A-Z]/g;
str = str.split(pattern);
// Joined using a space
str = str.join(" ");
So when I split on that it gives me this ["this", "s", "pinal", "ap"] is it possible to split at that point without actually removing the letter?
Andrew Bales
@agbales
Jan 28 2016 03:26
@jeremyroe Understand if you don't have the time-- but still trying to figure out how this would be applied in this case.
  _.flatten = function(array, shallow) {
    return flatten(array, shallow, false);
  };
For instance, you can't simply do...
return arr.flatten;
Jeremy Roe
@jeremyroe
Jan 28 2016 03:27
@agbales flatten is part of the underscore library - so flatten won’t work unless you add it’s source to your code - in this case I’d look at their source code to see what they are doing under the hood to flatten arrays and implement it
Andrew Bales
@agbales
Jan 28 2016 03:28
Ah! That makes a lot more sense. Thanks again.
@jeremyroe thanks.
Jeremy Roe
@jeremyroe
Jan 28 2016 03:29
@agbales you’ll notice in the code that _.flatten is calling the flatten var right above it - that’s the part ot pay attention to
you can likely boil it down to a much simpler bit of code than they use - if this is too complex let me know and I’ll look for a simpler alternative
Andrew Bales
@agbales
Jan 28 2016 03:30
I'll give it a closer look for a bit.
Chris Burros
@cburros
Jan 28 2016 03:33
@JamesR93 Just a moment and I'll take a look at it to refresh my memory
Tyler Hughes
@tylerbhughes
Jan 28 2016 03:33
@jeremyroe any suggestions on that last code i posted?
James
@JamesR93
Jan 28 2016 03:34
@cburros Thank you!
CamperBot
@camperbot
Jan 28 2016 03:34
jamesr93 sends brownie points to @cburros :sparkles: :thumbsup: :sparkles:
:star: 264 | @cburros | http://www.freecodecamp.com/cburros
Jeremy Roe
@jeremyroe
Jan 28 2016 03:35
standby @RandomlyKnighted
KWallac3
@KWallac3
Jan 28 2016 03:35
Hi-how do post code in chat?
Tyler Hughes
@tylerbhughes
Jan 28 2016 03:35
alright
help format
CamperBot
@camperbot
Jan 28 2016 03:35

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Tyler Hughes
@tylerbhughes
Jan 28 2016 03:35
there ya go
KWallac3
@KWallac3
Jan 28 2016 03:35
thanks
Tyler Hughes
@tylerbhughes
Jan 28 2016 03:36
no problem
Jeremy Roe
@jeremyroe
Jan 28 2016 03:37
@RandomlyKnighted that might work - it’s at least very close - What I used was
```
str = str.split(/(?=[A-Z])/).join(“ “);
Chris Burros
@cburros
Jan 28 2016 03:37
You will need an if statement nested in a for loop
@JamesR93 , yes, My code used two if statements in one for loop. I don't want to completely give it away though
James Thomas
@Grizzlr
Jan 28 2016 03:38

Hi all, I'm having a a bit a trouble with the queue section. Kind of felt like it jumped me ahead too quick. Not too sure where to even begin:
'''
function queue(arr, item) {
// Your code here

return item; // Change this line
}

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

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

'''

Sorry I thought I had the markdown figured out
Chris Burros
@cburros
Jan 28 2016 03:39
@JamesR93 It's a bit tricky so you'll want to pay attention to where you place return statements in relationship to your for loop and if statements
Jay Stretter
@Afrodisiac
Jan 28 2016 03:39
function convert(celsius) {
  // Only change code below this line
  var fahrenheit = celsius * 9/5 + 32;

  // Only change code above this line
  if ( typeof fahrenheit !== 'undefined' ) {
    return fahrenheit;
  } else {
    return 'fahrenheit not defined';
  }
}

// Change the inputs below to test your code
convert(30);
Jeremy Roe
@jeremyroe
Jan 28 2016 03:39
@Grizzlr you want to do ``` rather than ‘’’ and I find I need it each on it’s own line before and after my code
James
@JamesR93
Jan 28 2016 03:39
@cburros -- Okay that's perfect. I've been so close to solving it, but i'm just missing a few things. I just wanted to be sure I wasn't completely wrong.
Jay Stretter
@Afrodisiac
Jan 28 2016 03:40
So, my algorithm passed. I would like to know if there's any other way of completing this exercise, if you can call it that.
Tyler Hughes
@tylerbhughes
Jan 28 2016 03:40
@jeremyroe ah I see you used a lookahead to split at that point without actually pulling the delimiter
that's awesome
daiwik
@daiwik
Jan 28 2016 03:40

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

  return collection;
}

// Alter values below to test your code
update(2548, "artist", "");
how is this wrong
James Thomas
@Grizzlr
Jan 28 2016 03:40
@jeremyroe Thanks that makes sense
CamperBot
@camperbot
Jan 28 2016 03:40
grizzlr sends brownie points to @jeremyroe :sparkles: :thumbsup: :sparkles:
:star: 437 | @jeremyroe | http://www.freecodecamp.com/jeremyroe
daiwik
@daiwik
Jan 28 2016 03:40
for record collection
Jeremy Roe
@jeremyroe
Jan 28 2016 03:40
happy to help @RandomlyKnighted and @Grizzlr
Chris Burros
@cburros
Jan 28 2016 03:40
@JamesR93 I have found that writing the code down on paper and thinking through each step as the computer would has helped me figure some of this stuff out.
Tyler Hughes
@tylerbhughes
Jan 28 2016 03:40
I had to look up that regular expression in order to figure out the question mark part..i didnt even know something like a lookahead was possible
AlonzaThompson
@alonzathompson
Jan 28 2016 03:42

return-largest-numbers-in-arrays
myCode:
function largestOfFour(arr) {
// You can do this!
var myArr = [];
var temp = 0;
for (var i = 0; i < arr.length; i++)
{
for (var j = 0; j < arr[i].length; j++)
{
if(arr[i][j] > temp)
{
temp = arr[i][j];
}
}
myArr.push(temp);
}
return myArr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

can't figure out what i'm doing wrong

sorry about that don't know how to screenshot
Jeremy Roe
@jeremyroe
Jan 28 2016 03:43
@alonzothompson just paste your code with a ``` before and after it and it will format it
Chris Burros
@cburros
Jan 28 2016 03:43
@daiwik off the bat, it looks like in your else if line you have "track" instead of "tracks" let me look further though
AlonzaThompson
@alonzathompson
Jan 28 2016 03:45

thanks @jeremyroe
```function largestOfFour(arr) {
// You can do this!
var myArr = [];
var temp = 0;
for (var i = 0; i < arr.length; i++)
{
for (var j = 0; j < arr[i].length; j++)
{
if(arr[i][j] > temp)
{
temp = arr[i][j];
}
}
myArr.push(temp);
}
return myArr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
```

CamperBot
@camperbot
Jan 28 2016 03:45
alonzothompson sends brownie points to @jeremyroe :sparkles: :thumbsup: :sparkles:
:star: 438 | @jeremyroe | http://www.freecodecamp.com/jeremyroe
James Thomas
@Grizzlr
Jan 28 2016 03:45
I am completely lost here. I don't even know where to begin:
function queue(arr, item) {
  // Your code here

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Jeremy Roe
@jeremyroe
Jan 28 2016 03:45
Which challenge is this @Grizzlr
AlonzaThompson
@alonzathompson
Jan 28 2016 03:45
whats the challenge @Grizzlr
rphares
@rphares
Jan 28 2016 03:46
stand in line, i think
James Thomas
@Grizzlr
Jan 28 2016 03:46
@jeremyroe "Stand in Line"
Jeremy Roe
@jeremyroe
Jan 28 2016 03:46
ok - what would you say your stuck on with it @Grizzlr
you’ll want to look at the array methods - specifically push and shift if that helps https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
James Thomas
@Grizzlr
Jan 28 2016 03:48
I've gotten as far as something like arr. push(item).unshift();
But I'm not sure where to even go with that. Not sure what I'm supposed to change in the return line either
I'll check out the array methods again
Jeremy Roe
@jeremyroe
Jan 28 2016 03:49
In my case @Grizzlr I used shift rather than unshift - - when you use many of those methods like shift and splice it returns the element you worked on - try storing that in a variable or returning it

so like

var thing = array.shift();

now thing stores whatever it shifted

James Thomas
@Grizzlr
Jan 28 2016 03:51
Ah that makes more sense!
James
@dev15firkin
Jan 28 2016 03:52
I'm a little confused on check for Palindromes
James Thomas
@Grizzlr
Jan 28 2016 03:52

Could I do something like

var x = arr.push();
return x;

?

shift* not push
STEFF GRUENWALD
@planesteff
Jan 28 2016 03:53
question @ anyone with regards to Escaping Literal Quotes in Strings.
Jeremy Roe
@jeremyroe
Jan 28 2016 03:53
@Grizzlr that’s the first half of the solution - push is putting something in your array (queue) - but you still need to do the removal part of it and return what was removed
rphares
@rphares
Jan 28 2016 03:53
@planesteff , what have you tried so far?
Tridev
@TridevGuha
Jan 28 2016 03:53
@Borgaard ya I know how to use git and comfortable with terminal
Jeremy Roe
@jeremyroe
Jan 28 2016 03:53
look for a method that removes the first element on the array
James
@dev15firkin
Jan 28 2016 03:54
function palindrome(str) {
  var str1 = str.replace(/ |_|-|,|./g, '').toLowerCase();
  if (str1 === str1.split('').reverse().join('')){
  return true;}
  else {
    return false;
  }
}



palindrome("1 eye for of 1 eye.");
STEFF GRUENWALD
@planesteff
Jan 28 2016 03:54
ty rphares this is my code and i cant seem to get it right
var myStr = "I am a \"double quoted\" string inside \"double quotes\"."; // Change this line
rphares
@rphares
Jan 28 2016 03:54
oh, you are quite close, @planesteff
STEFF GRUENWALD
@planesteff
Jan 28 2016 03:54
is a face palm?
rphares
@rphares
Jan 28 2016 03:55
was there a period in that sentence, @planesteff ?
James
@dev15firkin
Jan 28 2016 03:55
ok so, on the check for palindromes bonfire, this lands me all the ones that should be true correct, but none that should be false.
Tridev
@TridevGuha
Jan 28 2016 03:55
@Borgaard but to use git from my local machine and sharing fcc with github, Need to get all the codes of every individual challenges to my local machine, right? how to do that? :)
STEFF GRUENWALD
@planesteff
Jan 28 2016 03:55
ahhhhh nope
James Thomas
@Grizzlr
Jan 28 2016 03:55
@jeremyroe shift()?
Jeremy Roe
@jeremyroe
Jan 28 2016 03:56
exactly @Grizzlr - then return the results of shift
rphares
@rphares
Jan 28 2016 03:56
trying to look closely, hard when that one isn't formatter, but i think that may be it, @planesteff ? :)
STEFF GRUENWALD
@planesteff
Jan 28 2016 03:56
you rock !! thank you rphares!
rphares
@rphares
Jan 28 2016 03:56
anytime :)
DJ
@qualitymanifest
Jan 28 2016 03:56
@dev15firkin by replacing . you are replacing everything
@dev15firkin you could escape it like \.
Satchmo37
@Satchmo37
Jan 28 2016 03:57
```
```
James
@dev15firkin
Jan 28 2016 03:58
@qualitymanifest ok thanks a bunch
CamperBot
@camperbot
Jan 28 2016 03:58
dev15firkin sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 843 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Satchmo37
@Satchmo37
Jan 28 2016 03:58
This message was deleted
Tyler Hughes
@tylerbhughes
Jan 28 2016 03:58

Ok so I adjusted my regular expression to use the forward lookup which fixed the issue with the one i was struggling with but it created another issue with adding multiple space so I adjusted my other expression and now I'm getting -- in between the words but I can't for some reason adding |- to my expression didn't replace the double hyphen with a single one...here's what I got.

function spinalCase(str) {

  // Finds all capital letters
  var pattern = /(?=[A-Z])/g;
  str = str.split(pattern);
  str = str.join(" ");

  // Replaces spaces, and underscores with a hyphen
  var punctuationPattern = /\s+|\_|\-/ig;
  str = str.replace(punctuationPattern, "-");

  return str.toLowerCase();
}

I'm beginning to hate regular expressions..they are super useful but such a pain

Satchmo37
@Satchmo37
Jan 28 2016 03:58
function where(collection, source) {
  var arr = [];
  // Store the key value from the object source, if there are multiple values
  //they are stored in an array
  var key = Object.keys(source);

  //Create a loop to itterate through the collection
  for(var i = 0; i < collection.length; i++){

    //Create a loop to itterate through the keys that have been stored
    //in an array
    for(var k = 0; k <key.length; k++){

      //Check to see if the key value from collection matches the source
      //This will fail if there is more than 1 key value
      if (collection[i][key] === source[key]){
       arr.push(collection[i]);

        //This is where I've gone wrong....so so very wrong
      } else if (collection[i] === source[key[k]]){
        arr.push(collection[i]);
      }
    }
  }
  return arr;
}

where([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
I'm passing the test where the source parameter only has one value, I still haven't figured out how to compare multiple keys against the collection objects
Herman Fassett
@HermanFassett
Jan 28 2016 03:59
@RandomlyKnighted that's possible with one line with regex btw xd
James Thomas
@Grizzlr
Jan 28 2016 03:59
@jeremyroe I get a Maximum call stack size error when i use this
function queue(arr, item) {
  // Your code here

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
oops i didn't copy it sorry just a sec
Tyler Hughes
@tylerbhughes
Jan 28 2016 04:00
@HermanFassett I'm sure it is I've seen patterns that do it during my googling but I'm trying to make sure I understand it
Jeremy Roe
@jeremyroe
Jan 28 2016 04:00
@RandomlyKnighted I had to use some if statements to sort of filter which regex applied to which - order came into play also
James Thomas
@Grizzlr
Jan 28 2016 04:01
function queue(arr, item) {
  // Your code here
  var add = arr. push(item);
var remove = arr.shift();
  return remove;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Jeremy Roe
@jeremyroe
Jan 28 2016 04:02
@Grizzlr you don’t need your push to be a variable - I’m not sure what push returns if anything but that would be a problem I think
that’s the only issue I can see
James Thomas
@Grizzlr
Jan 28 2016 04:03
I get the same error when I remove the entire push() variable
jpg8127
@jpg8127
Jan 28 2016 04:03
@jeremyroe did you finish smallest common multiple?
Jeremy Roe
@jeremyroe
Jan 28 2016 04:03
this is my code that passed @Grizzlr
function queue(arr, item) {
  // Your code here
  arr.push(item);
  var removed = arr.shift();
  return removed;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
it could be you need to refresh or reset your code (copy first so you can pasteit back in)
@jpg8127 nope still stuck on it
jpg8127
@jpg8127
Jan 28 2016 04:04
@jeremyroe i just finished it
Jeremy Roe
@jeremyroe
Jan 28 2016 04:04
@jpg8127 it’s failing to remove 10,20,30 etc on me . . . I may have to take a different tact and use an array.filter instead of splice - did you do a very different method than me?
function smallestCommons(arr) {  
  var start;
  var end;
  var mult1 = [];
  var mult2 = [];
  var pendings = [];
  var betweens = [];

  if(arr[0] > arr[1]){
    start = arr[1];
    end = arr[0];
  } else {
    start = arr[0];
    end = arr[1];
  }

  for(var i = 0; i <= end; i++){
    if(i > start && i < end){
      betweens.push(i);
    }
  }

  for(var m1 = 1; m1 <= 100; m1++){
    mult1.push(arr[0] * m1);
  }

  for(var m2 = 1; m2 <= 100; m2++){
    mult2.push(arr[1] * m2);
  }

  mult1.forEach(function(val){
    if(mult2.indexOf(val) !== -1){
      pendings.push(val);
    }
  });

  console.log(pendings);


  pendings.forEach(function(pen){
    if(pendings.indexOf(pen) !== -1){
    console.log("Pending " + pen);
    betweens.forEach(function(bet){
      if(pendings.indexOf(pen) !== -1){
        console.log("Between " + bet);
        if(pen % bet !== 0){
            console.log("Removing " + pen);
            pendings.splice(pendings.indexOf(pen),1);
        }
      }
    });
    }
  });

  console.log(betweens);
  console.log(pendings);
}


smallestCommons([1,5]);
jpg8127
@jpg8127
Jan 28 2016 04:05
@jeremyroe yeah I did it different
function smallestCommons(arr) {

  var multiArray = [];
  var base = 2;
  var done = false;
  var stepTwoRepeat = false;
  var total = 0;

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

  for (var i = arr[0]+1; i < arr[1]; i++) {
    arr.push(i);
  }

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




  while (done === false)
  {
    stepTwoRepeat = false;

    for(var z in arr)
    {
      if(arr[z]%base === 0)
      {

        arr[z]=arr[z]/base;

        if(stepTwoRepeat === false){
        multiArray.push(base);}
        stepTwoRepeat = true;
      }
    }
    if(stepTwoRepeat === false){
      base+=1;
    }
    done = true;

    for(var x in arr)
    {
      if(arr[x]>1){
        done=false;
      }
    }
  }
  total = multiArray[0];
  for(var t=1;t< multiArray.length;t++){
    total*=multiArray[t];
  }
  return total;



}
smallestCommons([5, 1]);
Jeremy Roe
@jeremyroe
Jan 28 2016 04:06
I don’t want the answer but any tips on the direction you went - I might just be tunnel visioned?
jpg8127
@jpg8127
Jan 28 2016 04:06
well
I went to wikipedia to see how to do it
Jeremy Roe
@jeremyroe
Jan 28 2016 04:06
lol - no worreis _ i’ll read it over
thanks @jpg8127
CamperBot
@camperbot
Jan 28 2016 04:06
jeremyroe sends brownie points to @jpg8127 :sparkles: :thumbsup: :sparkles:
:star: 325 | @jpg8127 | http://www.freecodecamp.com/jpg8127
jpg8127
@jpg8127
Jan 28 2016 04:07
@jeremyroe https://en.wikipedia.org/wiki/Least_common_multiple#A_method_using_a_table that is what I did. I just put that into code
Jeremy Roe
@jeremyroe
Jan 28 2016 04:07
cool thanks
James Thomas
@Grizzlr
Jan 28 2016 04:08
@jeremyroe refreshed and have the same code letter for letter and still a dang error. So confused haha
Jeremy Roe
@jeremyroe
Jan 28 2016 04:08
hmm - try another browser maybe? I’ve had some tests only pass in certain browsers due to small oddities
I’m on chrome for mac and it passes
James Thomas
@Grizzlr
Jan 28 2016 04:10
There it goes. Switched over to Chrome. I guess Safari still has it's kinks. Thanks @jeremyroe
CamperBot
@camperbot
Jan 28 2016 04:10
grizzlr sends brownie points to @jeremyroe :sparkles: :thumbsup: :sparkles:
:warning: grizzlr already gave jeremyroe points
Jeremy Roe
@jeremyroe
Jan 28 2016 04:10
anytime
alice3217
@alice3217
Jan 28 2016 04:20

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.

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

  return item;  // Change this line
}

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

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

what should i do?

Tyler Hughes
@tylerbhughes
Jan 28 2016 04:20
thansk @jeremyroe @jpg8127
jpg8127
@jpg8127
Jan 28 2016 04:20
np
Tyler Hughes
@tylerbhughes
Jan 28 2016 04:20
thanks @jeremyroe @jpg8127
CamperBot
@camperbot
Jan 28 2016 04:20
randomlyknighted sends brownie points to @jeremyroe and @jpg8127 :sparkles: :thumbsup: :sparkles:
:star: 439 | @jeremyroe | http://www.freecodecamp.com/jeremyroe
:star: 326 | @jpg8127 | http://www.freecodecamp.com/jpg8127
Tyler Hughes
@tylerbhughes
Jan 28 2016 04:20
there we go lol
cannelflow
@cannelflow
Jan 28 2016 04:30
@alice3217 worked?
alice3217
@alice3217
Jan 28 2016 04:31
@cannelflow nope?
cannelflow
@cannelflow
Jan 28 2016 04:32
can you show your code @alice3217
alice3217
@alice3217
Jan 28 2016 04:32
function queue(arr, item) {
  // Your code here

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Matt Leonard
@matty22
Jan 28 2016 04:33
Can anyone assist with Everything Be True?
function every(collection, pre) {
  // Is everyone being true?

  var isTrue = true;

  for (var i = 0; i < collection.length; i++) {
    if (collection[i].hasOwnProperty(pre) && collection[i][pre] === null || collection[i][pre] === 0 || collection[i][pre] === "" || collection[i][pre] === undefined || isNaN(collection[i][pre])) {
      isTrue = false;
    }
  }
  return isTrue;
}

every([{"single": "yes"}], "single");
This passes all tests but two. If I do !isNaN(collection[i][pre]) the two that don't pass do, but two others then fail.
Garrett
@grrttmrtn
Jan 28 2016 04:34

Can someone explain why this doesn't work? ```js
function convert(celsius) {
// Only change code below this line
var fahrenheit = celsius * (9/5 +32);
// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

// Change the inputs below to test your code
convert(0);
```

rphares
@rphares
Jan 28 2016 04:35
you don't need the parentheses, @grrttmrtn
Garrett
@grrttmrtn
Jan 28 2016 04:35
Figured my own out
Thanks!
rphares
@rphares
Jan 28 2016 04:35
cool, congrats and happy coding :)
Garrett
@grrttmrtn
Jan 28 2016 04:36
I realized I was forcing it to add the 32 before doing the multiplication and division :facepalm
Jeremy Roe
@jeremyroe
Jan 28 2016 04:37
@alice3217 look at array methods - one will put the item in the array and one will remove it from teh front - that will get you started https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
rphares
@rphares
Jan 28 2016 04:38
we all do it :blush:
Kevin Myrick
@aphextwin234
Jan 28 2016 04:50
@rphares are you good with bubble sorts?
in arrays?
Armine
@Arminemash
Jan 28 2016 04:51
Hi guys, plse help me, after wrong code my browser is irresponsible.an d now i can't change anything in my code. I refresed 100 times, nothing hapens.How fix that? Who knows?
Bill
@kirah1314
Jan 28 2016 04:52
help local storage
CamperBot
@camperbot
Jan 28 2016 04:52

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

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

In Chrome:

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

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

Bill
@kirah1314
Jan 28 2016 04:52
@Arminemash :point_up_2:
Armine
@Arminemash
Jan 28 2016 04:54
@kirah1314 thanks!
CamperBot
@camperbot
Jan 28 2016 04:54
arminemash sends brownie points to @kirah1314 :sparkles: :thumbsup: :sparkles:
:star: 885 | @kirah1314 | http://www.freecodecamp.com/kirah1314
Bill
@kirah1314
Jan 28 2016 04:55
@Arminemash you're welcome, hope that helps!
Josh Lumley
@JWLumley
Jan 28 2016 05:02
Can anyone help, can't seem to find the issue here with JSON
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1993,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }];
  // Add record here
 [{
    "artist": "Pearl Jam",
    "title": "Animal",
    "release_year": 1994,
    "formats": [
      "CD",
      "Vinyl",
      "MP3"],
    "platinum": true
  }
];
Astha Sharma
@asthas
Jan 28 2016 05:03
@JWLumley What exactly do you have to do for this challenge?
Josh Lumley
@JWLumley
Jan 28 2016 05:04
It's the INtroducting JavaScript Object Notation JSON @asthas It has a lot of things
Astha Sharma
@asthas
Jan 28 2016 05:04
@JWLumley You had to create an array of objects
Josh Lumley
@JWLumley
Jan 28 2016 05:05
@asthas Yes among other things
Astha Sharma
@asthas
Jan 28 2016 05:05
But insted you have closed the rray after inserting the first object
Josh Lumley
@JWLumley
Jan 28 2016 05:05
Okay, how did I close the array? With the bracket?
Astha Sharma
@asthas
Jan 28 2016 05:06
yup
closing bracket above the comment Add record here
moreover after }, And remove the closing bracket and the terminator
Josh Lumley
@JWLumley
Jan 28 2016 05:06
@asthas that's what I thought it was, but when I do it like this, still doesn't work.
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1993,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  // Add record here
  {
    "artist": "Pearl Jam",
    "title": "Animal",
    "release_year": 1994,
    "formats": [
      "CD",
      "Vinyl",
      "MP3"],
    "platinum": true
  }
];
Astha Sharma
@asthas
Jan 28 2016 05:07
add a comma before the comment
},
like that
Josh Lumley
@JWLumley
Jan 28 2016 05:08
@asthas thanks so much. It was simple
CamperBot
@camperbot
Jan 28 2016 05:08
jwlumley sends brownie points to @asthas :sparkles: :thumbsup: :sparkles:
:star: 279 | @asthas | http://www.freecodecamp.com/asthas
Astha Sharma
@asthas
Jan 28 2016 05:08
Exactly @JWLumley
Cam
@CamMakoJ
Jan 28 2016 05:18
so im working on stand in line
and i have this
function queue(arr, item) {
  // Your code here
  arr.push([item]);
  var pop = arr.pop();
  return pop;  // Change this line
}
im supposed to take an array, add a number (item), then remove the first element
then reutnr the element removed
Ishan Jain
@ishanjain28
Jan 28 2016 05:20
you should use arr.shitft(); because you want to remove the first element. and inside the arr.push() there should not be any square brackets. just a simple arr.push(item);
@CamMakoJ
oops. @CamMakoJ use arr.shift();
Cam
@CamMakoJ
Jan 28 2016 05:21
thanks @ishanjain28
CamperBot
@camperbot
Jan 28 2016 05:21
cammakoj sends brownie points to @ishanjain28 :sparkles: :thumbsup: :sparkles:
:star: 256 | @ishanjain28 | http://www.freecodecamp.com/ishanjain28
Minhazul Islam
@Minhazul-islam
Jan 28 2016 05:34
Hi! I'm on counting card. I didn't got the question. Plz help
Astha Sharma
@asthas
Jan 28 2016 05:35
please elaborate your problem @Minhazul-islam
if possible send the url
jeevitha
@jeevithajeev
Jan 28 2016 05:37
could someone help me with wordblanks
Astha Sharma
@asthas
Jan 28 2016 05:37
var count = 0;

function cc(card) {
  // Only change code below this line
  switch(card){

    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count +=1 ;
      return count,"Bet";

    case 7:
    case 8:
    case 9:
      count =0;
      return "count Hold" ;

    case 10:
    case "j":
    case "Q":
    case "k":
    case "A":
      count -=1;
      return "count Hold";


  }


  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
@rajesh304 @Minhazul-islam That's the snippet. If you have queries regarding the logic pls do ask
rajesh304
@rajesh304
Jan 28 2016 05:38
how to send like this astha?
Astha Sharma
@asthas
Jan 28 2016 05:38
@jeevithajeev Send your url and elaborate on your problem
@rajesh304 use backticks like this ```
And place your code within these bacticks
and press ctrl+enter to send
rajesh304
@rajesh304
Jan 28 2016 05:40

'
var count = 0;

function cc(card) {
// Only change code below this line
switch(card){

case 2:
case 3:
case 4:
case 5:
case 6:
  count +=1 ;
  return count,"Bet";

case 7:
case 8:
case 9:
  count =0;
  return "count Hold" ;

case 10:
case "j":
case "Q":
case "k":
case "A":
  count -=1;
  return "count Hold";

}

// Only change code above this line
}

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

Minhazul Islam
@Minhazul-islam
Jan 28 2016 05:40
@asthas Thnx for response
CamperBot
@camperbot
Jan 28 2016 05:40
minhazul-islam sends brownie points to @asthas :sparkles: :thumbsup: :sparkles:
:star: 280 | @asthas | http://www.freecodecamp.com/asthas
Astha Sharma
@asthas
Jan 28 2016 05:40
:) @Minhazul-islam
jeevitha
@jeevithajeev
Jan 28 2016 05:41

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

// Your code above this line
return result;
}

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

Astha Sharma
@asthas
Jan 28 2016 05:41
send the challenge url @jeevithajeev
rajesh304
@rajesh304
Jan 28 2016 05:41
oops sorry
Astha Sharma
@asthas
Jan 28 2016 05:42
:+1: @rajesh304
jeevitha
@jeevithajeev
Jan 28 2016 05:43
@asthas basic javascript
Astha Sharma
@asthas
Jan 28 2016 05:45
@jeevithajeev
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  result += myAdjective + " ";
  result += myNoun + " ";
  result += myVerb + " ";
  result += myAdverb;

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
@jeevithajeev Hope this helps!
jeevitha
@jeevithajeev
Jan 28 2016 05:48
@asthas thank you it worked!.......
Jean-Alexander
@MasterJDnc
Jan 28 2016 05:56
anybody here that may be able to give me some advice?
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  myObj.hasOwnProperty("gift");
  myObj.hasOwnProperty("pet");
  myObj.hasOwnProperty("bed");

}

// Test your code by modifying these values
checkObj("pet");
Instructions
Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  myObj.hasOwnProperty("gift");
  myObj.hasOwnProperty("pet");
  myObj.hasOwnProperty("bed");
  return "Not Found";
}

// Test your code by modifying these values
checkObj("pet");
Tabitha Blagdon
@tabithablagdon
Jan 28 2016 05:59
@MasterJDnc Sure. Couple things - first of, you need to use if/else to write the checkObj function
And the paramenter "checkProp" should be used not the "gift" or "pet" argument. Let me know if that helps.
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:00
ok thanks for not giving me the answer...I appreciate that....This is the first one i've been stuck on in a while lol
Tabitha Blagdon
@tabithablagdon
Jan 28 2016 06:01
No worries! Give it another whirl and let me know if you're still stuck!
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:02
ok thanks @tabithablagdon
CamperBot
@camperbot
Jan 28 2016 06:02
masterjdnc sends brownie points to @tabithablagdon :sparkles: :thumbsup: :sparkles:
:star: 143 | @tabithablagdon | http://www.freecodecamp.com/tabithablagdon
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:02
real quick....i'm using IF ELSE statement becuase it's a function right?
Cam
@CamMakoJ
Jan 28 2016 06:03
@MasterJDnc its not a function its a statement
@MasterJDnc a conditional statement
@MasterJDnc or logical operator that returns boolean (true/false)
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:05
function is something that can be executed at any time and it can also be changed right? I may be misunderstanding this lesson but I thought it was asking me to double check to see if the properties come back as true or false??
Cam
@CamMakoJ
Jan 28 2016 06:06
@MasterJDnc could you paste teh question?
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:07
yessirrrr @CamMakoJ Instructions
Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".
Cam
@CamMakoJ
Jan 28 2016 06:07
@MasterJDnc i think you need to use if/else
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:08
yeah, upon my research I came across this on a instructional web page

o = new Object();
o.prop = 'exists';

function changeO() {
o.newprop = o.prop;
delete o.prop;
}

o.hasOwnProperty('prop'); // returns true
changeO();
o.hasOwnProperty('prop'); // returns false

and I think this is on the right track
Cam
@CamMakoJ
Jan 28 2016 06:08
@MasterJDnc ahh perfect glad you found a solution
Tabitha Blagdon
@tabithablagdon
Jan 28 2016 06:09
@MasterJDnc You're writing an if/else because the exercise is asking you to test myObj for checkProp. IF the property is found, return that property's value. ELSE, return "Not Found". The conditional statement or test is held in a function MyObj so that you can access it to test different property arguments like "gift" without having to re-write if/else over and over again.
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:09
lol I found that like 30 mins ago
David
@DavidPhan1992
Jan 28 2016 06:09
bonfine caesars cipher
bf cassars cipher
CamperBot
@camperbot
Jan 28 2016 06:09
Sorry, can't find a bonfire called cassars cipher. [ Check the map? ]
Astha Sharma
@asthas
Jan 28 2016 06:10
@DavidPhan1992 I did that
Though my solution is a bit too verbose
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:22
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

return "Not Found" ; 
}
// Test your code by modifying these values
checkObj("gift");
I feel like I am sooooooo clooosseeeeeee
i ASSUMED this was it but it's not :(
Astha Sharma
@asthas
Jan 28 2016 06:23
@MasterJDnc That's a big glitch!
Vick003
@Vick003
Jan 28 2016 06:24
(function() {
       console.log(test);
})(); // just testing here folks
Astha Sharma
@asthas
Jan 28 2016 06:24
you are using a variable within double quites @MasterJDnc
Enrique Cahua
@enriquecahua
Jan 28 2016 06:24
@MasterJDnc take the quotes out of the method
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:25
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

  return myObj(checkProp);
}

return "Not Found" ; 
}
// Test your code by modifying these values
checkObj("gift");
Astha Sharma
@asthas
Jan 28 2016 06:25
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");
chaitanya ashtekar
@chaitanyaashtekar
Jan 28 2016 06:25
@MasterJDnc so it will be .""gift"" .remove double quotes
Astha Sharma
@asthas
Jan 28 2016 06:25
@MasterJDnc Here is the sleeker version of the code
Hope that helps!
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:26
maybe i should refresh my browser :(
i've been getting no feedback from this lesson
lol
Astha Sharma
@asthas
Jan 28 2016 06:26
@MasterJDnc ok
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:27
lol I had that code earlier, and if only I would've refreshed!!!
thank you guys sooo much @asthas
CamperBot
@camperbot
Jan 28 2016 06:27
masterjdnc sends brownie points to @asthas :sparkles: :thumbsup: :sparkles:
:star: 281 | @asthas | http://www.freecodecamp.com/asthas
Astha Sharma
@asthas
Jan 28 2016 06:27
:)
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:27
first glitch encountered in 224 lessons
not bad
Astha Sharma
@asthas
Jan 28 2016 06:28
@MasterJDnc You are doing well!
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:28
@asthas I was looking at your profile...i'm just wondering....how long did it take you to get comfortable with coding?
Enrique Cahua
@enriquecahua
Jan 28 2016 06:32
 return myObj.hasOwnProperty(checkProp) ? myObj[checkProp] :"Not Found";
who can get it smaller than that?
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:33
@enriquecahua Would that line work??
Enrique Cahua
@enriquecahua
Jan 28 2016 06:33
try it
nnlearn
@nnlearn
Jan 28 2016 06:35

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

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.

Astha Sharma
@asthas
Jan 28 2016 06:35
@MasterJDnc Was that snarky?
@nnlearn Are you having problems implementing that?
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:37
@asthas The question I asked you? Not at all!! I just wanted to know how long it took you to become comfortable with coding.
Astha Sharma
@asthas
Jan 28 2016 06:37
@MasterJDnc 6 days at codecamp
:D
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:38
@asthas You seem to know a lot about it by answering a lots of peoples question...
:clap: :O
YOUR NUTSSSS
lol
Astha Sharma
@asthas
Jan 28 2016 06:38
@MasterJDnc That was white lies
My git hub repo must have already answered your question
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:39
soooo....i'm new to coding....like a week ago new....and i haven't learned GitHun yet...
like I look up there and i'm like "yeahhhh..all these forks and repositories"......
Astha Sharma
@asthas
Jan 28 2016 06:40
@enriquecahua I have fell in love with ternary operators. They make your code look sleek n sexy
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:40
still have no idea what they are
lol
Enrique Cahua
@enriquecahua
Jan 28 2016 06:40
@asthas thanks :) you're making me blush
CamperBot
@camperbot
Jan 28 2016 06:40
enriquecahua sends brownie points to @asthas :sparkles: :thumbsup: :sparkles:
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:40
I'll learn GitHub by this weekend though
CamperBot
@camperbot
Jan 28 2016 06:40
:star: 282 | @asthas | http://www.freecodecamp.com/asthas
Astha Sharma
@asthas
Jan 28 2016 06:41
@MasterJDnc Github will indeed steepen your learning curve
You're going at a good pace @MasterJDnc
@enriquecahua :)
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:41
@asthas GITHUB TOMORROW IT ISSSSS THEN
Astha Sharma
@asthas
Jan 28 2016 06:42
:+1: @MasterJDnc
docsoul
@docsoul
Jan 28 2016 06:42

```function titleCase(str) {
str = str.toLowerCase();
console.log(str);
var convert;

var alone = str.split(" ");
for(i=0; i < alone.length - 1; i++){

convert[i] = alone[i].atChar(0).toUpperCase();

}
return convert;
}

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

Jean-Alexander
@MasterJDnc
Jan 28 2016 06:42
@asthas Thank you for all your help tonight again....everybody have a good night!!
CamperBot
@camperbot
Jan 28 2016 06:42
masterjdnc sends brownie points to @asthas :sparkles: :thumbsup: :sparkles:
:warning: masterjdnc already gave asthas points
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:43
@enriquecahua That code worked....and it's crazy man
docsoul
@docsoul
Jan 28 2016 06:43
function titleCase(str) {
str  = str.toLowerCase(); 
 console.log(str);
  var convert;

var alone = str.split(" ");
  for(i=0; i < alone.length - 1; i++){

    convert[i] = alone[i].atChar(0).toUpperCase();
  }
  return convert;
}


titleCase("I'm a little tea pot");
Im trying to capitalize each word
But it says alone[i].atChar is not a function
ANy help?
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:43
looking at it , I feel like I understand it....but i coudn't use it myself
Astha Sharma
@asthas
Jan 28 2016 06:44
@docsoul You have to think for a logic to get "AN OLD MAN" to"An Old Man"
Enrique Cahua
@enriquecahua
Jan 28 2016 06:44
@MasterJDnc @asthas is right, ternary operators make your code sleek
Jean-Alexander
@MasterJDnc
Jan 28 2016 06:44
can't wait til I learn that
looks a lot better on one line than 4-5
makes it easier to read also
Astha Sharma
@asthas
Jan 28 2016 06:45
@docsoul Moreover it is charAt()
not atChar() :)
Kevin Myrick
@aphextwin234
Jan 28 2016 06:45
<script type="javascript">

function allStarArray(){

allStarTeams = new Array(10);

names[0]="McLain";names[1]="Freehan";names[2]="Cash";names[3]="McAuliffe";names[4]="Stanley";names[5]="Wertz";names[6]="Horton";names[7]="Northrup";names[8]="Kaline";names[9]="Brown";

for (var i = 0; i < allStarTeams.Length; i++)
{

Document.write(allstarteams[i]);
}
}
}
</script>
</head>

<body>

<form name="allstarForm">
<input type="button" onclick="allStarArray()"/>Get Array<button>
</form>
can anyone help me with this
im getting an un defined array on my on click
docsoul
@docsoul
Jan 28 2016 06:45
@asthas Wo my gwaad!! :smile:
Astha Sharma
@asthas
Jan 28 2016 06:47
@aphextwin234 Mind your 'l' in Length
Well jokes apart length
Brian
@Brian984
Jan 28 2016 06:47
Where's the best place to learn about ternary operators? FCC doesn't cover that topic do they?
Astha Sharma
@asthas
Jan 28 2016 06:48
@aphextwin234 send the url of your challenge?
docsoul
@docsoul
Jan 28 2016 06:48
@asthas I still dont get it. I looped in array. Trying to capitalize each word by using alone[i].charAt(0).toUpperCase();
Where is the problem? Any idea?
I mean whats wrong with my code?
Markus Kiili
@Masd925
Jan 28 2016 06:49
@docsoul Strings are immutable. Do: alone[i]=alone[i].charAt(0).toUpperCase()+...
Enrique Cahua
@enriquecahua
Jan 28 2016 06:49
@aphextwin234 shouldn't it be allStarTeams[0]="",
allStarTeams1="" and so on
names is not defined
Astha Sharma
@asthas
Jan 28 2016 06:50
@docsoul
function titleCase(str) {
  var elem = str.split(' ');
  console.log(elem);
  var arr = [];
  console.log(elem.length);
  for (var i = 0; i < elem.length; i++) {
     arr[i] = elem[i].charAt(0).toUpperCase() + elem[i].substr(1).toLowerCase();
     console.log(arr[i]);
  }

  return arr.join(' ');

}

titleCase("I'm a little tea pot");
Markus Kiili
@Masd925
Jan 28 2016 06:50
@docsoul Or declare convert as an array.
Astha Sharma
@asthas
Jan 28 2016 06:50
@docsoul That's how I did it
docsoul
@docsoul
Jan 28 2016 06:51
@asthas Kyaa baath hey!
@asthas Thanks
CamperBot
@camperbot
Jan 28 2016 06:51
docsoul sends brownie points to @asthas :sparkles: :thumbsup: :sparkles:
:star: 283 | @asthas | http://www.freecodecamp.com/asthas
docsoul
@docsoul
Jan 28 2016 06:51
@Masd925 Thanks bruh!
CamperBot
@camperbot
Jan 28 2016 06:51
docsoul sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 835 | @masd925 | http://www.freecodecamp.com/masd925
Astha Sharma
@asthas
Jan 28 2016 06:51
@docsoul :)
Kevin Myrick
@aphextwin234
Jan 28 2016 06:53
Chrome debugger says allStarTeams is not defined
and it did not show up in my intellisense when i made the onclick
Astha Sharma
@asthas
Jan 28 2016 06:54
@aphextwin234 You have mixed up to many languages
Kevin Myrick
@aphextwin234
Jan 28 2016 06:56
@asthas I do not understand. I'm just using JS.
Astha Sharma
@asthas
Jan 28 2016 06:56
@aphextwin234 Can you send the url of your challenge
Astha Sharma
@asthas
Jan 28 2016 07:04
@Brian984 MDN is the best source to learn anything and everything about javascript
Rajesh Moguloju
@rajeshmoguloju
Jan 28 2016 07:18
how can retrieve the contents of the object if the variable name had space in between?
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};
This is the sample code
and I would like to retrieve the value of glove box
eeflores
@eeflores
Jan 28 2016 07:20
@rajeshmoguloju you'll have to use bracket notation
Astha Sharma
@asthas
Jan 28 2016 07:20
@rajeshmoguloju myStorage["glove box"]
eeflores
@eeflores
Jan 28 2016 07:20
@rajeshmoguloju obj["some val"]
Enrique Cahua
@enriquecahua
Jan 28 2016 07:21
@asthas myObj.NestedObject["propertyIWant"]
@rajeshmoguloju
Astha Sharma
@asthas
Jan 28 2016 07:22
@enriquecahua Thanks for the correction
CamperBot
@camperbot
Jan 28 2016 07:22
asthas sends brownie points to @enriquecahua :sparkles: :thumbsup: :sparkles:
:star: 318 | @enriquecahua | http://www.freecodecamp.com/enriquecahua
Enrique Cahua
@enriquecahua
Jan 28 2016 07:22
sorry I tagged wrong person
ty!
Jay
@lantiwonka
Jan 28 2016 07:24

var myStr="\backslash\ \ttab tab\t \rcarriage-return\r \nnew-line\n"; // Change this line

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

help! kind of stuck here
CamperBot
@camperbot
Jan 28 2016 07:24
no wiki entry for: kind of stuck here
Rajesh Moguloju
@rajeshmoguloju
Jan 28 2016 07:24
so I end up doing this, myStorage.car["inside"].----------;
what should I do here?
Pranjal Singh
@pr4njal
Jan 28 2016 07:24
@rajeshmoguloju You have to use myStorage.car.inside["glove box"]
Rajesh Moguloju
@rajeshmoguloju
Jan 28 2016 07:24
okay
thanks you@pr4njal
Enrique Cahua
@enriquecahua
Jan 28 2016 07:25
@rajeshmoguloju yeah theres one more layer
Pranjal Singh
@pr4njal
Jan 28 2016 07:25
@rajeshmoguloju wherever you see space between properties name use bracket notation otherwise use dot notation
eeflores
@eeflores
Jan 28 2016 07:25
@lantiwonka take out the words - replace "backslash" with "\\"
Rajesh Moguloju
@rajeshmoguloju
Jan 28 2016 07:26
Thank you everyone
Enrique Cahua
@enriquecahua
Jan 28 2016 07:26
@rajeshmoguloju high-fives all around
eeflores
@eeflores
Jan 28 2016 07:26
:high_heel:
oops
Pranjal Singh
@pr4njal
Jan 28 2016 07:28

@lantiwonka
var myStr; // Change this line

myStr = "\ \t \t \r \n";

Rajesh Moguloju
@rajeshmoguloju
Jan 28 2016 07:28
yeah @enriquecahua
This group is very encouraging and I appreciate everyone :)
Jonathan Mitchell
@Vanhealen
Jan 28 2016 07:29
++
Jay
@lantiwonka
Jan 28 2016 07:30
thanks @eeflores and @pr4njal appreciate your help
CamperBot
@camperbot
Jan 28 2016 07:30
lantiwonka sends brownie points to @eeflores and @pr4njal :sparkles: :thumbsup: :sparkles:
:star: 220 | @pr4njal | http://www.freecodecamp.com/pr4njal
:star: 495 | @eeflores | http://www.freecodecamp.com/eeflores
eeflores
@eeflores
Jan 28 2016 07:30
no problem
Pranjal Singh
@pr4njal
Jan 28 2016 07:31

i am having problem in exercise record collection.
While writing update function i am accessing properties like this:

function update(id, prop, value) {
if(value !== "" && prop !== "tracks") {
collection.id[prop] = value;
}

return collection;
}

This one is just for one part of exercise... where am i wrong?

eeflores
@eeflores
Jan 28 2016 07:32
@pr4njal you'll have to put id in brackets also
Pranjal Singh
@pr4njal
Jan 28 2016 07:32
@eeflores Why???
eeflores
@eeflores
Jan 28 2016 07:33
@pr4njal id contains the value that you want to access in collection
@pr4njal collection.id tries to access property id in collection, whereas collection[id] uses the value that id stores to reference a property of collection
Pranjal Singh
@pr4njal
Jan 28 2016 07:34
so i am using dot notation here to access id from collection....
see...
collection.id[prop] = value;
eeflores
@eeflores
Jan 28 2016 07:34
@pr4njal collection.id specifically looks for property id in collection, not the value that id contains
Markus Kiili
@Masd925
Jan 28 2016 07:34
@pr4njal collection.id tries to access property key "id".
eeflores
@eeflores
Jan 28 2016 07:35
@pr4njal collection.id == collection["id"] but not collection[id]
@pr4njal if id == 1234, collection[id] == collection.1234
Pranjal Singh
@pr4njal
Jan 28 2016 07:36
@eeflores I am too much confused in dot notation and bracket notation... Can you tell me resources for learning these concepts?
Ekpo David
@ekpo-d
Jan 28 2016 07:36
hi guys, i dont get the instructions in the truncate-a-string challenge, pls i dont need the solution, just a explanation of the instructions, thanks
Enrique Cahua
@enriquecahua
Jan 28 2016 07:36
help truncate-a-string challenge
CamperBot
@camperbot
Jan 28 2016 07:36
no wiki entry for: truncate-a-string challenge
Ekpo David
@ekpo-d
Jan 28 2016 07:37
help truncate-a-string
CamperBot
@camperbot
Jan 28 2016 07:37

:point_right: bonfire truncate a string [wiki]

Explanation:

We need to reduce the length of the string or truncate it if it is longer than the given maximum lengths specified and add ... to the end. If it is not that long then we keep it as is.

:pencil: read more about bonfire truncate a string on the FCC Wiki

Pranjal Singh
@pr4njal
Jan 28 2016 07:37
thanks @eeflores @Masd925
CamperBot
@camperbot
Jan 28 2016 07:37
pr4njal sends brownie points to @eeflores and @masd925 :sparkles: :thumbsup: :sparkles:
:star: 836 | @masd925 | http://www.freecodecamp.com/masd925
:star: 496 | @eeflores | http://www.freecodecamp.com/eeflores
Astha Sharma
@asthas
Jan 28 2016 07:38
@ekpo-d
function truncate(str, num) {
  // Clear out that junk in your trunk
  var newstr = "";
  var result = "";

  if(num>3 && num < str.length){
    newstr = str.slice(0, num-3);
    result = newstr.concat("...");
   } else if(num < 3) {
    newstr = str.slice(0, num);
    result = newstr.concat("...");
   } else{
     result = str;
   }

  return result;
}

truncate("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2);
My solution is a little bombastic, could have been simplified
Ekpo David
@ekpo-d
Jan 28 2016 07:39
noooo.....didnt want the solution @asthas
IamKien
@IamKien
Jan 28 2016 07:39
Can someone help me?

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

// Your code above this line
return result;
}

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

Astha Sharma
@asthas
Jan 28 2016 07:39
@ekpo-d What did you wanted to ask;
Ekpo David
@ekpo-d
Jan 28 2016 07:39
i have written a solution already....just needed better explanation of the problem
Markus Kiili
@Masd925
Jan 28 2016 07:40
@asthas Try to give hints. Not solutions.
eeflores
@eeflores
Jan 28 2016 07:40
@tyteeye510 add spaces between words: myNoun + " " + myAdjective etc
Pranjal Singh
@pr4njal
Jan 28 2016 07:40
@tyteeye510 Write these as they make some sense
IamKien
@IamKien
Jan 28 2016 07:40
how do I add a space after the words?
Astha Sharma
@asthas
Jan 28 2016 07:40
@Masd925 I'll keep that in mind
Enrique Cahua
@enriquecahua
Jan 28 2016 07:40
@tyteeye510 + " " +
Ekpo David
@ekpo-d
Jan 28 2016 07:41
bt thanks for responding @asthas
CamperBot
@camperbot
Jan 28 2016 07:41
ekpo-d sends brownie points to @asthas :sparkles: :thumbsup: :sparkles:
:star: 284 | @asthas | http://www.freecodecamp.com/asthas
Pranjal Singh
@pr4njal
Jan 28 2016 07:41
@tyteeye510 result = myNoun +" is "+ myAdjective + " so he "+myVerb+" " + myAdverb;
Astha Sharma
@asthas
Jan 28 2016 07:41
 result += myNoun + " ";
Pranjal Singh
@pr4njal
Jan 28 2016 07:42
@tyteeye510 now when function runs your code with given parameter it will make sense.. Try it
Astha Sharma
@asthas
Jan 28 2016 07:42
@tyteeye510 Since you have initialised an empty string try to append results to it rather than rewriting it
Pranjal Singh
@pr4njal
Jan 28 2016 07:43
@asthas Hahhh... caught right... You also have to add it.. You r right
IamKien
@IamKien
Jan 28 2016 07:44
Thank you @asthas @pr4njal @enriquecahua
CamperBot
@camperbot
Jan 28 2016 07:44
tyteeye510 sends brownie points to @asthas and @pr4njal and @enriquecahua :sparkles: :thumbsup: :sparkles:
:star: 319 | @enriquecahua | http://www.freecodecamp.com/enriquecahua
:star: 285 | @asthas | http://www.freecodecamp.com/asthas
:star: 221 | @pr4njal | http://www.freecodecamp.com/pr4njal
Pranjal Singh
@pr4njal
Jan 28 2016 07:44
@tyteeye510 so finally ..
result += myNoun +" is "+ myAdjective + " so he "+myVerb+" " + myAdverb;
IamKien
@IamKien
Jan 28 2016 07:45
@pr4njal I done is this way, result = myNoun + " " + myAdjective + " " + myVerb + " " + myAdverb ;
would your way be better?
eeflores
@eeflores
Jan 28 2016 07:45
looks good
does it pass?
IamKien
@IamKien
Jan 28 2016 07:46
it passed
eeflores
@eeflores
Jan 28 2016 07:46
yay
IamKien
@IamKien
Jan 28 2016 07:46
thanks @eeflores
CamperBot
@camperbot
Jan 28 2016 07:46
tyteeye510 sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 497 | @eeflores | http://www.freecodecamp.com/eeflores
eeflores
@eeflores
Jan 28 2016 07:46
yw
Pranjal Singh
@pr4njal
Jan 28 2016 07:46
@tyteeye510 well if its working then good... but surely the correct way is to use
result+= ......
because you have to add your result to the given result
@tyteeye510 but its working.... so just move on
IamKien
@IamKien
Jan 28 2016 07:47
I see, similar to adding it an array
Chris Moore
@dooglus
Jan 28 2016 08:26
evening all
kirbyedy
@kirbyedy
Jan 28 2016 08:30
morning @dooglus :D
fluffystub
@RakshithNM
Jan 28 2016 09:14
hey guys
what does string.indexOf() return??
Ramazan
@Haxx55
Jan 28 2016 09:15
im not sure but the index of the string ?
fluffystub
@RakshithNM
Jan 28 2016 09:17
'Blue Whale'.indexOf('Blue');     // returns  0
'Blue Whale'.indexOf('Blute');    // returns -1
'Blue Whale'.indexOf('Whale', 0); // returns  5
'Blue Whale'.indexOf('Whale', 5); // returns  5
'Blue Whale'.indexOf('', 9);      // returns  9
'Blue Whale'.indexOf('', 10);     // returns 10
'Blue Whale'.indexOf('', 11);     // returns 10
@Haxx55 i found this on MDN...i could not make sense of it
Pranjal Singh
@pr4njal
Jan 28 2016 09:19
@RakshithNM string.indexOf() is used to find the position of character in the string. If found it will return the position otherwise -1
Ramazan
@Haxx55
Jan 28 2016 09:20
hence why Blue has an index of 0 becuase its located first in the string.
and Blute returned -1 becuase it is not in the string
Etah Chen
@777000777
Jan 28 2016 09:22
does anyone know if the waypoint "Make Object Properties Private "
is broke?
Pranjal Singh
@pr4njal
Jan 28 2016 09:22
@Haxx55 yupppp
Ramazan
@Haxx55
Jan 28 2016 09:22
@pr4njal :)
fluffystub
@RakshithNM
Jan 28 2016 09:24
function mutation(arr) {
  myVar = arr[0].indexOf(arr[1]);
  if(myVar==-1){
    return false;
  }
    else 
    {
      return true;
    }

}

mutation(["hello", "hey"]);
@pr4njal @Haxx55 can you check this code for me?
Ramazan
@Haxx55
Jan 28 2016 09:25
@RakshithNM is that an example or did you write it?
Pranjal Singh
@pr4njal
Jan 28 2016 09:25
@RakshithNM I think the problm is in second line
fluffystub
@RakshithNM
Jan 28 2016 09:25
@Haxx55 its my code...it doesnt pass
Pranjal Singh
@pr4njal
Jan 28 2016 09:26
you are checking arr[0] position with arr1... Its little bit meaningless.... :worried:
Ramazan
@Haxx55
Jan 28 2016 09:26
what are you trying to do becuase the code dosn’t make sense
fluffystub
@RakshithNM
Jan 28 2016 09:27
@pr4njal i should check "hello" with "hey"
@Haxx55 i am learning
Brendan Kinahan
@BKinahan
Jan 28 2016 09:29
@RakshithNM indexOf() is a method of arrays. arr[0] is a string.
Ramazan
@Haxx55
Jan 28 2016 09:29
@RakshithNM I know you are but if you could just briefly explain what were trying to do with that code so we can help
Michal
@xMicRoz
Jan 28 2016 09:30

Hello, would you mind helping me with lesson 222 - "Nesting For Loops"? My code is: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; i++) {
product += arr[i]* arr[i][j];
}
}
// Only change code above this line
return product;
}

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

I keep getting "TypeError: Cannot read property 'length' of undefined"
fluffystub
@RakshithNM
Jan 28 2016 09:31
@BKinahan @Haxx55
'Blue Whale'.indexOf('Blue');     // returns  0
'Blue Whale'.indexOf('Blute');    // returns -1
'Blue Whale'.indexOf('Whale', 0); // returns  5
'Blue Whale'.indexOf('Whale', 5); // returns  5
'Blue Whale'.indexOf('', 9);      // returns  9
'Blue Whale'.indexOf('', 10);     // returns 10
'Blue Whale'.indexOf('', 11);
i found the help from MDN
Pranjal Singh
@pr4njal
Jan 28 2016 09:31
@xMicRoz You are writing wrong
fluffystub
@RakshithNM
Jan 28 2016 09:32
i am trying to check if arr[0] has characters from arr1
Pranjal Singh
@pr4njal
Jan 28 2016 09:32

@xMicRoz

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

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

fluffystub
@RakshithNM
Jan 28 2016 09:33
@BKinahan so indexOf() cannot be used with a string!!!
Brendan Kinahan
@BKinahan
Jan 28 2016 09:33
@RakshithNM those examples show that it is checking the first string for occurrences of the second entire string, not each individual character.
Michal
@xMicRoz
Jan 28 2016 09:33
@pr4njal thank you, I miessed that typo with the 2nd for loop, my 1st version included the 'product *= arr[i][j];', but thought that I went wrong there ;)
CamperBot
@camperbot
Jan 28 2016 09:33
xmicroz sends brownie points to @pr4njal :sparkles: :thumbsup: :sparkles:
:star: 230 | @pr4njal | http://www.freecodecamp.com/pr4njal
Michal
@xMicRoz
Jan 28 2016 09:33
thank you my friend :-)
Pranjal Singh
@pr4njal
Jan 28 2016 09:34
@xMicRoz Happy to help buddy
Brendan Kinahan
@BKinahan
Jan 28 2016 09:34
@RakshithNM if you want to check letter by letter, you need to loop through the second string somehow. Either a for loop with arr[1][i] or break it up into an array and use .forEach()
fluffystub
@RakshithNM
Jan 28 2016 09:35
@BKinahan i will try the for loop
SimonJang
@SimonJang
Jan 28 2016 09:44
hello everybody, I am currently stuck at the "Check for palindromes" assignment
cannelflow
@cannelflow
Jan 28 2016 09:44
@SimonJang tried something?
SimonJang
@SimonJang
Jan 28 2016 09:44
I got something really strange there
function palindrome(str) {
  str = str.toLowerCase();

  str = str.replace(/ /g, "");  
  str = str.replace(".", "");
  str = str.replace(/,/g, "");


  var convertedArrayString = str.split("");
  convertedArrayString.reverse();
  var revStr = convertedArrayString.join("");


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

  return false;
}



palindrome("0_0 (: /-\ :) 0-0");
that one doesn't seem to work at all
cannelflow
@cannelflow
Jan 28 2016 09:46
@SimonJang use replace(/[^A-Za-z0-9]/g, '');
Blauelf
@Blauelf
Jan 28 2016 09:47
@SimonJang For regular expressions, there is a wiki page on js regex, and you can try them on websites like regexr.com
SimonJang
@SimonJang
Jan 28 2016 09:47
lol, I never thought about that. I actually thought the sequence of symbols was part of the actual argument
kasra Jalilian
@kasraJ
Jan 28 2016 09:47
if(value===""){
delete collection[id][prop];
}
else if(collection[id][prop]!=="tracks" ){
collection[id][prop]=value;
}
else{
collection[id].tracks.push(value);
}
SimonJang
@SimonJang
Jan 28 2016 09:48
@Blauelf thanks
CamperBot
@camperbot
Jan 28 2016 09:48
simonjang sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1029 | @blauelf | http://www.freecodecamp.com/blauelf
SimonJang
@SimonJang
Jan 28 2016 09:48
@Blauelf thanks
kasra Jalilian
@kasraJ
Jan 28 2016 09:48
can someone help me with this? Record collection
SimonJang
@SimonJang
Jan 28 2016 09:48
@cannelflow thanks
CamperBot
@camperbot
Jan 28 2016 09:48
simonjang sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
:star: 610 | @cannelflow | http://www.freecodecamp.com/cannelflow
kasra Jalilian
@kasraJ
Jan 28 2016 09:48
the last else dose not work
Blauelf
@Blauelf
Jan 28 2016 09:50
Are you sure? And do you return collection (some people forget that line)?
kasra Jalilian
@kasraJ
Jan 28 2016 09:50
yes i return the collection
Blauelf
@Blauelf
Jan 28 2016 09:51
Tried a reload?
kasra Jalilian
@kasraJ
Jan 28 2016 09:51
yes
Blauelf
@Blauelf
Jan 28 2016 09:52
Your second condition is wrong. Test prop!=="tracks"
How could I not see that instantly? :D
kasra Jalilian
@kasraJ
Jan 28 2016 09:53
@Blauelf oh I see the problem
@Blauelf thank you
CamperBot
@camperbot
Jan 28 2016 09:53
kasraj sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1030 | @blauelf | http://www.freecodecamp.com/blauelf
sanwalatta
@sanwalatta
Jan 28 2016 09:58
The variable product should equal 5.0.