These are chat archives for FreeCodeCamp/HelpJavaScript

12th
Feb 2016
Sarah
@gingersnapp
Feb 12 2016 00:01
definitely doing something wrong with Chunky Monkey...anyone want to check out the code below?
function chunk(arr, size) {
for (i=0;i<arr.length;i++){
if (i === 0){
  arr[i] = arr.slice(arr[i],size);
}
else {
    arr[i] = arr.slice(arr[i],size);

} return arr; }}

chunk(["a", "b", "c", "d"], 2);
Moisés Man
@moigithub
Feb 12 2016 00:05
@gingersnapp create a new array variable instead of reusing arr
Vik
@vvang044
Feb 12 2016 00:06
im back......lol.....sounds horrible
Sarah
@gingersnapp
Feb 12 2016 00:06
okay @moigithub thanks ill try this
CamperBot
@camperbot
Feb 12 2016 00:06
gingersnapp sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 554 | @moigithub | http://www.freecodecamp.com/moigithub
Vik
@vvang044
Feb 12 2016 00:08
@bitgrower i did record collection i got two errors.....can you check the code ?
anyone ?
karencordova
@karencordova
Feb 12 2016 00:10
thanksss @Takumar ;-) i'll do it
Vik
@vvang044
Feb 12 2016 00:10
@Takumar can u check my code ?
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

    return collection[id][value];
  } 
  else if(prop === "tracks" && value !== ""){

    return collection [id][prop].push[value];   
  } 
  else if( value === ""){

    delete collection[id][prop];
  }


  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
where did i go wrong ?
Vik
@vvang044
Feb 12 2016 00:15
anyone ?
Taysha
@taariya
Feb 12 2016 00:16
hey guys, is anyone else encountering freezing when doing the fibonacci number bonfire?
greg
@wearenotgroot
Feb 12 2016 00:16
@taariya that means you code runs into infinite for loop
Taysha
@taariya
Feb 12 2016 00:16
I do NOT have an infinite loop because I have infinite loop notifications turned on
I tested it out and when I intentionally create an infinite loop, it notifies me
Here is my code:
greg
@wearenotgroot
Feb 12 2016 00:17
@vvang044 use id and prop as identifiers
Michael Mason
@boone2016
Feb 12 2016 00:17
thanks @Takumar
CamperBot
@camperbot
Feb 12 2016 00:17
boone2016 sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 2301 | @takumar | http://www.freecodecamp.com/takumar
Taysha
@taariya
Feb 12 2016 00:18
var fibs = [1,1];
var i = 0;
while(i <num){
fibs.push(i);
i++
}
Vik
@vvang044
Feb 12 2016 00:18
for?
Taysha
@taariya
Feb 12 2016 00:18
fibonacci number sum bonfire
I KNOW it's not correct, I was just testing to see
greg
@wearenotgroot
Feb 12 2016 00:18
@vvang044
function update(id, prop, value) {
  if ( value !== "" && prop !== "tracks") {

    return collection[id][value]; //<-------------------------------use prop, remember you set value by  =
  } 
  else if(prop === "tracks" && value !== ""){

    return collection [id][prop].push[value];   //<------------ memember methods uses () not []
  } 
  else if( value === ""){

    delete collection[id][prop];
  }


  return collection;
}
@taariya well there is your problem
@taariya infite for loop right there
@taariya or close to it
Taysha
@taariya
Feb 12 2016 00:20
@wearenotgroot what line?
Michael Mason
@boone2016
Feb 12 2016 00:21
Testing Objects for Properties
Vik
@vvang044
Feb 12 2016 00:21
sorry i was reading what you have written
Michael Mason
@boone2016
Feb 12 2016 00:21
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here


  return "Change Me!";
}

// Test your code by modifying these values
checkObj("gift");
greg
@wearenotgroot
Feb 12 2016 00:21
@taariya oh nvm,
Michael Mason
@boone2016
Feb 12 2016 00:21
can someone please help with this
Taysha
@taariya
Feb 12 2016 00:21
@wearenotgroot ???
greg
@wearenotgroot
Feb 12 2016 00:22
@taariya but if the num is too large then the browser will hang
Taysha
@taariya
Feb 12 2016 00:22
@wearenotgroot I understand, but on the test I'm running it's only going up to 4, so you mightn't expect it to be so taxed
greg
@wearenotgroot
Feb 12 2016 00:22
@taariya that mean you need to figure out more efficient way of doing this
Taysha
@taariya
Feb 12 2016 00:23
@wearenotgroot also, this happens on other exercises as well when I don't use loops, for example on spinal tap case when I was testing to see what a variable i declared using the RegEx object "looked like"
Vik
@vvang044
Feb 12 2016 00:23
@boone2016 i believe you need to write an if and else statement
if i remember
greg
@wearenotgroot
Feb 12 2016 00:24
@taariya does the hanging happens alot?
Taysha
@taariya
Feb 12 2016 00:24
@wearenotgroot no, it only started happening recently and only on certain exercises
Vik
@vvang044
Feb 12 2016 00:25
@wearenotgroot does that mean i need to change it to collection (id)(value) ?.....im lost there
Michael Mason
@boone2016
Feb 12 2016 00:25
@vvang044 ive tried and I can write the correct conditions but i have trouble with the returns
greg
@wearenotgroot
Feb 12 2016 00:25
@taariya oh well the site is under maintainance
@taariya might be that causes it
@taariya also consider how many tabs you have opened
Vik
@vvang044
Feb 12 2016 00:25
the last return should be "not found"
Taysha
@taariya
Feb 12 2016 00:26
@wearenotgroot thanks...I guess I'll just come back to the fibonacci thing later and see if it's remedied. I only have the one tab open to minimize distraction, but thanks
CamperBot
@camperbot
Feb 12 2016 00:26
taariya sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 760 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
Vik
@vvang044
Feb 12 2016 00:26
and one return should be myObj....... what are you trying to return?
Bryan Gilbraith
@bryantheastronaut
Feb 12 2016 00:26
@boone2016 did you change the return value at the bottom?
greg
@wearenotgroot
Feb 12 2016 00:27
@vvang044 yes use ---------> collection[id][prop] = value as you have use collection[id][prop] elsewhere in your code
Michael Mason
@boone2016
Feb 12 2016 00:28
@bryantheastronaut yes to checkProp
Tobias Murphy
@tmrdr
Feb 12 2016 00:30
can someone help me with the "factorialize a number" bonfire?
CamperBot
@camperbot
Feb 12 2016 00:30
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Bryan Gilbraith
@bryantheastronaut
Feb 12 2016 00:30
@boone2016 okay so you would use checkProp in the if statement but I believe it wants you to return the actual value of it
greg
@wearenotgroot
Feb 12 2016 00:30
@vvang044 another thing your return statement should only be in the last line
@vvang044 remove the returns in other places
Tobias Murphy
@tmrdr
Feb 12 2016 00:31
bonfire factorialize a number
CamperBot
@camperbot
Feb 12 2016 00:31

:fire:Bonfire: Factorialize a Number :link:

function factorialize(num) {
  return num;
}

factorialize(5);

Return the factorial of the provided integer.

more info:  bf details | bf links | hint

Vik
@vvang044
Feb 12 2016 00:31
oh.....
let me fix those erros
Bryan Gilbraith
@bryantheastronaut
Feb 12 2016 00:32
@boone2016 so you could return the array property with either dot or bracket notation if you've done that yet? I don't actually remember the order of the challenges
greg
@wearenotgroot
Feb 12 2016 00:32
@tmrdr there is two ways of doing this----> using recursion or just regular iterative approach
@tmrdr here is the math formula---------> n! = n * (n-1)!
Tobias Murphy
@tmrdr
Feb 12 2016 00:33
@wearenotgroot I wrote a code that passes all the tests but it wont let me complete the bonfire
Vik
@vvang044
Feb 12 2016 00:34
from two errors now im down to one error
greg
@wearenotgroot
Feb 12 2016 00:34
@tmrdr lets see it
Tobias Murphy
@tmrdr
Feb 12 2016 00:34
array = [];
function factorialize(num) {
  if(num === 0){
    return 1;
  }
  for (i = 0; i < num; i){
     array.push(num);
    num--;
  } 

  newArray = array.reduce(function(previousVal, currentVal){
    return previousVal * currentVal;
  });

  return newArray;
}

factorialize(20);
greg
@wearenotgroot
Feb 12 2016 00:34
@vvang044 consider testing if prop = 'tracks' first
Michael Mason
@boone2016
Feb 12 2016 00:34
@bryantheastronaut im not real sure my brain is fried right now to be honest
greg
@wearenotgroot
Feb 12 2016 00:35
@vvang044 to avoid setting value to non existing property
Vik
@vvang044
Feb 12 2016 00:36
oh....so i need to switch it around....i wrote prop= "tracks" at else if..... so i should change it to if
greg
@wearenotgroot
Feb 12 2016 00:36
@vvang044 yep
Vik
@vvang044
Feb 12 2016 00:36
ok let me make that change
Bryan Gilbraith
@bryantheastronaut
Feb 12 2016 00:36
@boone2016 but you would actually need to use bracket notation with the variable. So it could be: return fakeArray [replaceThisVariable]
Tobias Murphy
@tmrdr
Feb 12 2016 00:36
when I put the test numbers in I get the right result but the test marks do not turn to checks. Only the first and last go through. @wearenotgroot
Bryan Gilbraith
@bryantheastronaut
Feb 12 2016 00:37
@boone2016 totally understandable. Been there. May be helpful to step away for a bit and come at it fresh later
greg
@wearenotgroot
Feb 12 2016 00:38
@tmrdr figured it out
@tmrdr your code it correct
@tmrdr it's just the checker is picky
Tobias Murphy
@tmrdr
Feb 12 2016 00:39
@wearenotgroot what should I do?
greg
@wearenotgroot
Feb 12 2016 00:39
@tmrdr if you move the array inside the method
@tmrdr
function factorialize(num) {
var array = [];
  if(num === 0){
    return 1;
  }
  for (i = 0; i < num; i){
     array.push(num);
    num--;
  } 

  newArray = array.reduce(function(previousVal, currentVal){
    return previousVal * currentVal;
  });

  return newArray;
}

factorialize(20);
@tmrdr :smile:
Tobias Murphy
@tmrdr
Feb 12 2016 00:39
wow thank you @wearenotgroot
CamperBot
@camperbot
Feb 12 2016 00:39
tmrdr sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 761 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 12 2016 00:40
@tmrdr YW
Tobias Murphy
@tmrdr
Feb 12 2016 00:40
I would have never solved that lol
greg
@wearenotgroot
Feb 12 2016 00:40
@tmrdr well there are hints remember to read the commented line
@tmrdr it will usually tell you where to edit the code and where not to
Allison Anderson
@Allison80
Feb 12 2016 00:41
what's this issue with this?
// Only change code below this line

var myStr = "This is the start." + "This is the end.";
greg
@wearenotgroot
Feb 12 2016 00:41
@Allison80 use ' instead of "
Tobias Murphy
@tmrdr
Feb 12 2016 00:41
the commented line? where is that? @wearenotgroot
Allison Anderson
@Allison80
Feb 12 2016 00:41
i tried that
greg
@wearenotgroot
Feb 12 2016 00:42
@tmrdr some of the exercises have them
Jason Ulaner
@julaner
Feb 12 2016 00:42
HI all, hope everyone is doing well! Im struggling on the "Make Object Properties Private"
Allison Anderson
@Allison80
Feb 12 2016 00:42
@wearenotgroot doesn't make a diff
there's another prob somewhere
Vik
@vvang044
Feb 12 2016 00:42
still got one error
greg
@wearenotgroot
Feb 12 2016 00:42
@Allison80 post the title of the task
Jason Ulaner
@julaner
Feb 12 2016 00:42
  this.accelerate = function(change) {
    speed += change;
  };

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

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

var Bike = function() {

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

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

  };

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


};



var myCar = new Car();
Allison Anderson
@Allison80
Feb 12 2016 00:42

Concatenating Strings with Plus Operator
In JavaScript, when the + operator is used with a String value, it is called the concatenation operator. You can build a new string out of other strings by concatenating them together.

Example

'My name is Alan,' + ' I concatenate.'
Note
Watch out for spaces. Concatenation does not add spaces between concatenated strings, so you'll need to add them yourself.

Instructions
Build myStr from the strings "This is the start. " and "This is the end." using the + operator.

Run tests (ctrl + enter)

greg
@wearenotgroot
Feb 12 2016 00:43
@Allison80 add space
Tobias Murphy
@tmrdr
Feb 12 2016 00:43
@wearenotgroot hmm this bonfire didnt have one, I guess i just have to brush up on 'best practices' , anyway, thanks again
CamperBot
@camperbot
Feb 12 2016 00:43
tmrdr sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:warning: tmrdr already gave wearenotgroot points
Allison Anderson
@Allison80
Feb 12 2016 00:43
where?? @wearenotgroot
greg
@wearenotgroot
Feb 12 2016 00:43
@Allison80 should be 'This is the start. This is theend'
Zion
@learnor
Feb 12 2016 00:43
@Allison80 After your first period
greg
@wearenotgroot
Feb 12 2016 00:44
@tmrdr np
@tmrdr oh wanna see the recursive way of doing this?
Vik
@vvang044
Feb 12 2016 00:44

```
function update(id, prop, value) {

if ( prop === "tracks" && value !=="" ){

collection [id][prop].push[value];

}
else if ( value !== "" && prop !== "tracks") {

 collection[id][prop]=value;

}

else if( value === ""){

delete collection[id][prop];

}

return collection;

Tobias Murphy
@tmrdr
Feb 12 2016 00:44
@wearenotgroot yes please
Allison Anderson
@Allison80
Feb 12 2016 00:44
@learnor thank you - why is there a space there and not after the 2nd one??
CamperBot
@camperbot
Feb 12 2016 00:45
allison80 sends brownie points to @learnor :sparkles: :thumbsup: :sparkles:
greg
@wearenotgroot
Feb 12 2016 00:45
@tmrdr check your pm
CamperBot
@camperbot
Feb 12 2016 00:45
:star: 487 | @learnor | http://www.freecodecamp.com/learnor
Vik
@vvang044
Feb 12 2016 00:45
oh shoot why did it paste like that

``` function update(id, prop, value) {

if ( prop === "tracks" && value !=="" ){

collection [id][prop].push[value];

}
else if ( value !== "" && prop !== "tracks") {

 collection[id][prop]=value;

}

else if( value === ""){

delete collection[id][prop];

}

return collection;
```

Brian
@sludge256
Feb 12 2016 00:45
you can edit your message instead of resubmitting
Vik
@vvang044
Feb 12 2016 00:45
i have one error
Zion
@learnor
Feb 12 2016 00:45
@Allison80 the final string has a space between the two original strings. So you can add one either at the end of the first string or the beginning of the second one
greg
@wearenotgroot
Feb 12 2016 00:46
@vvang044 use () in methods
@vvang044 not []
@vvang044 .push is a method
Allison Anderson
@Allison80
Feb 12 2016 00:46
@learnor lol, okay that was too confusing for thi slate in the day, lol
Vik
@vvang044
Feb 12 2016 00:46
greee oh bummer
Zion
@learnor
Feb 12 2016 00:46
@Allison80 :smile: np
Vik
@vvang044
Feb 12 2016 00:47
what a bumm i am....grrr
Zion
@learnor
Feb 12 2016 00:48
@vvang044 collection [id][prop].push(value);
Vik
@vvang044
Feb 12 2016 00:48
thank you @wearenotgroot @learnor anyone else i missed
CamperBot
@camperbot
Feb 12 2016 00:48
vvang044 sends brownie points to @wearenotgroot and @learnor :sparkles: :thumbsup: :sparkles:
:star: 488 | @learnor | http://www.freecodecamp.com/learnor
:star: 762 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 12 2016 00:48
@vvang044 i think you need a break :smile:
Vik
@vvang044
Feb 12 2016 00:48
indeed......
maybe i should practice some html and css and come back to this
i lost half of hair from scratching and trying to understand what the heck i should do first.....
greg
@wearenotgroot
Feb 12 2016 00:50
@vvang044 wear mittens so it wont scratch your head :smile:
Vik
@vvang044
Feb 12 2016 00:50
but this is what i dont understand..... why doesn't it work if i follow the "if" statements in the instructions
as i switched it over to prop===" tracks" as the first instead of the second
Zion
@learnor
Feb 12 2016 00:52
@wearenotgroot I just tested your calculator project. Have you tried 3+3 then press the + button several times
greg
@wearenotgroot
Feb 12 2016 00:53
@vvang044 well you could have done this much more readable
if (value !=="" ){


   if (prop === "tracks") {

   }
    else
   {
    }
else
{
}
@learnor well not finished yet :smile:
Vik
@vvang044
Feb 12 2016 00:54
true
Zion
@learnor
Feb 12 2016 00:54
@wearenotgroot :smile:
Vik
@vvang044
Feb 12 2016 00:54
going to take a breakk
thank you
André Ferreira
@andreferreira-me
Feb 12 2016 01:02
Hey guys.. How should I do to load the Tweet button asynchronously?? http://codepen.io/andreferreira-me/pen/yeGdMV
AnnasLab
@AnnasLab
Feb 12 2016 01:11
Hello guys! How's your day going ^^ I need a small help in the
Find Numbers with Regular Expressions waypoints
and here's what I did
~~~
// Setup
var testString = "There are 3 cats but 4 dogs.";

// Only change code below this line.

var expression = /\[0-9]/g;  // Change this line

// Only change code above this line

// This code counts the matches of expression in testString
var digitCount = testString.match(expression).length;
Norman Dela Cruz
@dcnr
Feb 12 2016 01:13
@AnnasLab

Hi You're supposed to use \d

Instructions
Use the \d selector to select the number of numbers in the string, allowing for the possibility of one or more digit.

AnnasLab
@AnnasLab
Feb 12 2016 01:15
done
thanks @dcnr
CamperBot
@camperbot
Feb 12 2016 01:15
annaslab sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 600 | @dcnr | http://www.freecodecamp.com/dcnr
Jason
@carpediem1213
Feb 12 2016 01:21

```js
function end(str, target) {
// "Never give up and good luck will find you."
// -- Falcor

var a = target.charAt(target.length-1);
var b = str.charAt(str.length-1);

return (a === b);
}

end("Bastian", "n");

Oops!
function end(str, target) {

  var a = target.charAt(target.length-1);
  var b = str.charAt(str.length-1);

  return (a === b);
  }

end("Bastian", "n");
These are working except of course the one that ends with "frozen" and has a target of "specification" since e != o. I've tried to make 2 other variables with length - 2, but this ruins the other part of the program
DJ
@qualitymanifest
Feb 12 2016 01:24
@carpediem1213 you're only checking to see if the very last letters are the same, but target's length won't always be equal to 1
you need to check if target's length of the ending of str is equal to target
greg
@wearenotgroot
Feb 12 2016 01:27
@carpediem1213 use substr or slice
Evan Kincade
@evankincade
Feb 12 2016 01:27
Can someone give me an idea of why a certain solution works for the Confirm the Ending bonfire?
Jason
@carpediem1213
Feb 12 2016 01:27
@wearenotgroot what is pr slice?
greg
@wearenotgroot
Feb 12 2016 01:28
@carpediem1213 meant or
:smile:
Jason
@carpediem1213
Feb 12 2016 01:28
@wearenotgroot how does substr differ from charAt(endofstring)
greg
@wearenotgroot
Feb 12 2016 01:28
@carpediem1213 remember you need to get the entire string
@carpediem1213 not just a character at index 0
Jason
@carpediem1213
Feb 12 2016 01:29
@wearenotgroot @qualitymanifest Thanks!
CamperBot
@camperbot
Feb 12 2016 01:29
carpediem1213 sends brownie points to @wearenotgroot and @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 943 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
:star: 764 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 12 2016 01:29
@carpediem1213 example ------>"He has to give me a new name" wont work with this
@carpediem1213 you can either split up the entire sting into array and check the last item on the array or use substr :smile:
Jason
@carpediem1213
Feb 12 2016 01:30
@wearenotgroot substr sounds better. thanks again! gn
CamperBot
@camperbot
Feb 12 2016 01:30
carpediem1213 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:warning: carpediem1213 already gave wearenotgroot points
greg
@wearenotgroot
Feb 12 2016 01:31
@carpediem1213 YW
@carpediem1213 have a nice sleep
@evankincade what have you tried?
RickWisneske
@rwisneske
Feb 12 2016 01:32
Lesson "Profile Lookup". Need Help.
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

// Change these values to test your function
lookUp("Akira", "likes");
greg
@wearenotgroot
Feb 12 2016 01:33
@rwisneske i meant
Norman Dela Cruz
@dcnr
Feb 12 2016 01:33
@rwisneske contacts is an array, so you'd have to loop through the elements before you access the object
greg
@wearenotgroot
Feb 12 2016 01:34
:smile:
@rwisneske use for loop :smile:
RickWisneske
@rwisneske
Feb 12 2016 01:34
@wearenotgroot that was weird I think I deleted your comment by accident
greg
@wearenotgroot
Feb 12 2016 01:35
@rwisneske nope
RickWisneske
@rwisneske
Feb 12 2016 01:35
oh
greg
@wearenotgroot
Feb 12 2016 01:35
@rwisneske i did :smile:
RickWisneske
@rwisneske
Feb 12 2016 01:35
Good I'm not loosing it.
greg
@wearenotgroot
Feb 12 2016 01:35
@rwisneske thought it was the other task
@rwisneske but yea as @dcnr mention it's an array so use for loop
RickWisneske
@rwisneske
Feb 12 2016 01:37
@dcnr Ah! Duh! Ok I'll do that. Thanks!
CamperBot
@camperbot
Feb 12 2016 01:37
rwisneske sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
greg
@wearenotgroot
Feb 12 2016 01:37
@rwisneske also prop is your key here :+1: use it with brackets
CamperBot
@camperbot
Feb 12 2016 01:37
:star: 601 | @dcnr | http://www.freecodecamp.com/dcnr
RickWisneske
@rwisneske
Feb 12 2016 01:37
@wearenotgroot thanks!
CamperBot
@camperbot
Feb 12 2016 01:37
rwisneske sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 765 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 12 2016 01:37
@rwisneske YW
RickWisneske
@rwisneske
Feb 12 2016 01:39
So is it possible to keep all this js in your brain?
greg
@wearenotgroot
Feb 12 2016 01:39
@rwisneske you can try :smile:
@rwisneske also you dont have to memorize everything
@rwisneske remember docs are available
@rwisneske just get the concept of things
RickWisneske
@rwisneske
Feb 12 2016 01:40
well thanks for helping us noobs out!
greg
@wearenotgroot
Feb 12 2016 01:41
@rwisneske everyone was once a noob at the beginning except @dcnr :smile:
RickWisneske
@rwisneske
Feb 12 2016 01:42
Yoda!
greg
@wearenotgroot
Feb 12 2016 01:43
@rwisneske :clap:
E
@efhjones
Feb 12 2016 01:44
Hiya everybody :wave:
greg
@wearenotgroot
Feb 12 2016 01:44
O/
Norman Dela Cruz
@dcnr
Feb 12 2016 01:45
@wearenotgroot oi! lol that's not so, I pride myself that I'm an eternal noob
@rwisneske don't use loops for extra points :smiling_imp:
RickWisneske
@rwisneske
Feb 12 2016 01:49
@dcnr That's crazy!
Kala Radl
@mossandboar
Feb 12 2016 01:59
need help counting cards
E
@efhjones
Feb 12 2016 02:01
go ahead @mossandboar
Kala Radl
@mossandboar
Feb 12 2016 02:03
will i be using multiple "case" or "if " statements?
E
@efhjones
Feb 12 2016 02:05
@mossandboar you will need both. if statements don't work so well when there are a ton of cases to compare because it gets wordy. So if there are a lot of cases, I would lean towards "case". If there are only a few things that need to be checked, I'd use "if".
Kala Radl
@mossandboar
Feb 12 2016 02:06

switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count = count -1;
break;
case 7:
case 8:
case 9:
count = count + 0;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count = count + 1;

}
if (count <= -3) {
return count + " Hold";
}
else if (count >= 5) {
return count + " Bet";
}

does this look close?
DJ
@qualitymanifest
Feb 12 2016 02:08
close but take a look at your if/else conditions. that returns nothing if count is between -3 and 5
E
@efhjones
Feb 12 2016 02:10
@mossandboar Yeah, but remember that you want to "hold" if the count is negative and "bet" if the count is positive. Also, you don't need another "if" after "else" if it is the only "else" statement.
Krissel
@selchel
Feb 12 2016 02:11
Hello! I need some help with the following... not sure where to go from here and wondering if I'm on the right track?
function queue(arr, item) {
  // Your code here
  testArr.push(item);
  testArr.shift();
  return ;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Kala Radl
@mossandboar
Feb 12 2016 02:11
@efhjones that you!! @qualitymanifest thank you!!!
CamperBot
@camperbot
Feb 12 2016 02:11
mossandboar sends brownie points to @efhjones and @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 945 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
:star: 211 | @efhjones | http://www.freecodecamp.com/efhjones
cannelflow
@cannelflow
Feb 12 2016 02:12
@selchel you have to return what is removed by shift
@selchel should be arr.pudh() and shift
Norman Dela Cruz
@dcnr
Feb 12 2016 02:13
@selchel you should also be working on arr and not testArr :P
Krissel
@selchel
Feb 12 2016 02:13
hah, ok!
but how do I get it to return what was removed?
cannelflow
@cannelflow
Feb 12 2016 02:15
@selchel you can return shift statement
or make you can do like var abc = arr.shift(); and return abc;
E
@efhjones
Feb 12 2016 02:17
@selchel When you shift() something, it removes the last thing the array but it needs to put it somewhere. You can stick it onto a variable. So you'll need a variable to store what was removed.
@selchel and then you can return that variable.
Krissel
@selchel
Feb 12 2016 02:19
@efhjones thank you!! this was the explanation I was looking for :)
CamperBot
@camperbot
Feb 12 2016 02:19
selchel sends brownie points to @efhjones :sparkles: :thumbsup: :sparkles:
:star: 212 | @efhjones | http://www.freecodecamp.com/efhjones
Jason Ulaner
@julaner
Feb 12 2016 02:19
var Car = function() {
  // this is a private variable
  var speed = 10;

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

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

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

var Bike = function() {

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

  this.getGear = function (myBike){
    gear += myBike;

  };

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


};



var myCar = new Car();

var myBike = new Bike();
E
@efhjones
Feb 12 2016 02:19
@selchel Glad I could help. Just did that one last night :grin:
Jason Ulaner
@julaner
Feb 12 2016 02:19
im struggling a bit with this
cannelflow
@cannelflow
Feb 12 2016 02:20
@julaner which exercise?
Jason Ulaner
@julaner
Feb 12 2016 02:20
@cannelflow Make Object Properties Private
Zachary Vacek
@zacharyvacek
Feb 12 2016 02:22
@julaner first you don't want to set gear = 4 from the beginning. You'll want to do that when you call the function.
Sarah
@gingersnapp
Feb 12 2016 02:23
anyone want to take a look at this Chunky Monkey?
function chunk(arr, size) {

  var newArr = [];

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

  newArr.push(arr.slice (i, size));


} return newArr;
}

chunk(["a", "b", "c", "d"], 2);
cannelflow
@cannelflow
Feb 12 2016 02:27
This message was deleted
hellotojello
@hellotojello
Feb 12 2016 02:31

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

return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
why doesn't my code work. i dont want the answer..just a small hint.. this is for the section, record collection

Taylor Ham
@taylorham
Feb 12 2016 02:34
@hellotojello 'id' is not a property of collection, it's a variable!
I got tripped up on the same thing
hellotojello
@hellotojello
Feb 12 2016 02:35
ok thanks for the hint @taylorham.. let me try this again
CamperBot
@camperbot
Feb 12 2016 02:35
hellotojello sends brownie points to @taylorham :sparkles: :thumbsup: :sparkles:
:star: 174 | @taylorham | http://www.freecodecamp.com/taylorham
Norman Dela Cruz
@dcnr
Feb 12 2016 02:36
@gingersnapp Hi .slice() takes in indices so it should be .slice(startIndex, endIndex)
@gingersnapp in your code chunk(["a", "b", "c", "d"], 2); on the second iteration
@gingersnapp it will be arr.slice(2, 2)
@gingersnapp and it will return you []
@gingersnapp so you should also move your endIndex
Ramón Emilio Ledezma Vargas
@Mercality
Feb 12 2016 02:40
Hey guys good night
Could use some help with that regexp
There's no look behind in javascript's regexp? how could i pass that one case that is missing there?
Thomas Tzanetoulakos
@tommasgr
Feb 12 2016 02:43
Hello guys and goodevening!!!Can anyone help me here????Please guys i will appreciate because i have been stuck since midday."Convert Celsius to Fahrenheit"

function convert(celsius) {

// Only change code below this line

var Celsius;
var fahrenheit;

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

Taylor Ham
@taylorham
Feb 12 2016 02:45
@tommasgr You have to write the code to convert the temp yourself! The question should give you the conversion equation, and you'll want to include that in the convert() function
@tommasgr Oh, and don't declare a new celsius variable, you can just use the one that is provided as the argument to the function
Thomas Tzanetoulakos
@tommasgr
Feb 12 2016 02:50
@taylorham Can you please give me an example ?
Taylor Ham
@taylorham
Feb 12 2016 02:53

@tommasgr

function convert(celsius) {
  var fahrenheit = (celsius * ......<equation here>)
}

something along those lines

RK1225
@RK1225
Feb 12 2016 02:53
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
return "Not Found";
}
// Test your code by modifying these values
checkObj("gift");
i can't seem to figure this out
Norman Dela Cruz
@dcnr
Feb 12 2016 02:55
@Mercality hi, yes JS has no lookbehind, would have made that algo more straightforward I guess
RK1225
@RK1225
Feb 12 2016 02:55
suppose to modify "checkObj" to use the ".hasOwnProperty" to test true or false on "myObj". Any help appreciated
Norman Dela Cruz
@dcnr
Feb 12 2016 02:57
@RK1225 hi .hasOwnProperty takes in one argument and the function is used on the object you want to look up the property of
@RK1225 you're not supposed to modify checkObj because that's the property you want looked up
RK1225
@RK1225
Feb 12 2016 02:58
i meant modify the function named checkObj. not the call for it at the end
vin4oo
@vin4oo
Feb 12 2016 03:00
ok i seriously need some help with this
the lesson is called stand in line
Franco Zapata
@Francozt01
Feb 12 2016 03:00
@vin4oo with?
vin4oo
@vin4oo
Feb 12 2016 03:00

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

Franco Zapata
@Francozt01
Feb 12 2016 03:01
@vin4oo 2 things
vin4oo
@vin4oo
Feb 12 2016 03:01
whats that?
Franco Zapata
@Francozt01
Feb 12 2016 03:01
use push(); to push the item into the array
and use shif(); to subtract the first element in the array
vin4oo
@vin4oo
Feb 12 2016 03:01
ooh ok
Franco Zapata
@Francozt01
Feb 12 2016 03:01
save that subtracted element in a variable
and return that variable
vin4oo
@vin4oo
Feb 12 2016 03:01
ill give that a try
Franco Zapata
@Francozt01
Feb 12 2016 03:02
read pus(); and shift();
Norman Dela Cruz
@dcnr
Feb 12 2016 03:02
@RK1225 I'm sorry I don't quite understand what you mean. You use it like this
Object.hasOwnProperty(property)
epicsong
@epicsong
Feb 12 2016 03:02

Can somebody help me with my code? ```js //Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

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

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

ugh...how do I get it to display right?
Thomas Tzanetoulakos
@tommasgr
Feb 12 2016 03:03
@taylorham Thank you But still cant get it!
CamperBot
@camperbot
Feb 12 2016 03:03
tommasgr sends brownie points to @taylorham :sparkles: :thumbsup: :sparkles:
:star: 175 | @taylorham | http://www.freecodecamp.com/taylorham
Norman Dela Cruz
@dcnr
Feb 12 2016 03:03
@epicsong the backticks should be on their own line
```js
<code here>
```
Matt Gilbert
@Alquh
Feb 12 2016 03:03
@epicsong
code here
epicsong
@epicsong
Feb 12 2016 03:03
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

// Change these values to test your function
lookUp("Akira", "lastName");
Norman Dela Cruz
@dcnr
Feb 12 2016 03:04
@epicsong you can use SHIFT+ENTER to make a new line
Taylor Ham
@taylorham
Feb 12 2016 03:04
@tommasgr can you show what you've tried?
epicsong
@epicsong
Feb 12 2016 03:04
it also seems like after I put the code in, I have to type something else to be able to enter...I think it was CTRL+Enter
does that seem right?
Taylor Ham
@taylorham
Feb 12 2016 03:04
@epicsong yep!
epicsong
@epicsong
Feb 12 2016 03:04
thanks @taylorham
CamperBot
@camperbot
Feb 12 2016 03:04
epicsong sends brownie points to @taylorham :sparkles: :thumbsup: :sparkles:
:star: 176 | @taylorham | http://www.freecodecamp.com/taylorham
RK1225
@RK1225
Feb 12 2016 03:05
thanks @dcnr, but how do i modify the function "checkObj" in the code i posted to test myObj for checkProp?
CamperBot
@camperbot
Feb 12 2016 03:05
rk1225 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 602 | @dcnr | http://www.freecodecamp.com/dcnr
Franco Zapata
@Francozt01
Feb 12 2016 03:05
@RK1225 use an if statement
eeflores
@eeflores
Feb 12 2016 03:06
do a barrel roll
epicsong
@epicsong
Feb 12 2016 03:06
Does anyone see what's wrong with my code? I've been playing with it for a bit, but something's not right. It works for only the test cases that result in "no such contact" or "no such property"
Taylor Ham
@taylorham
Feb 12 2016 03:07
@epicsong you'll want to return something outside of your for loop for when it does find a match
eeflores
@eeflores
Feb 12 2016 03:07
@epicsong you'll want to use the hasOwnProperty() function
@epicsong contacts[i].hasOwnProperty(prop)
epicsong
@epicsong
Feb 12 2016 03:08
ooh, nice! thanks @eeflores
CamperBot
@camperbot
Feb 12 2016 03:08
epicsong sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 577 | @eeflores | http://www.freecodecamp.com/eeflores
eeflores
@eeflores
Feb 12 2016 03:08
yw
RK1225
@RK1225
Feb 12 2016 03:09
so what variable would i use for the if statement?
epicsong
@epicsong
Feb 12 2016 03:10
@taylorham why should it return something outside of the for loop?
Taylor Ham
@taylorham
Feb 12 2016 03:11
@epicsong I was wrong. I'm not much farther than you and this is my first time trying to help, so I'm still a little 'buggy' myself :P
Thomas Tzanetoulakos
@tommasgr
Feb 12 2016 03:11

@taylorham function convert(celsius) {

var fahrenheit = (celsius 9/5 +32)

// Only change code below this line

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

epicsong
@epicsong
Feb 12 2016 03:11
@taylorham no problem
Taylor Ham
@taylorham
Feb 12 2016 03:12
@tommasgr mathematical order of operations is the problem there. You may want the + 32 outside the parentheses
RK1225
@RK1225
Feb 12 2016 03:13
@Francozt01 what variable would i use for the if statement?
Taylor Ham
@taylorham
Feb 12 2016 03:13
@tommasgr and you'll need to specify the operation you're doing on celsius and 9/5!
RK1225
@RK1225
Feb 12 2016 03:13

// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here

return "Not Found";
}

// Test your code by modifying these values
checkObj("gift");

you can't do an if .hasOwnProperty()
Taylor Ham
@taylorham
Feb 12 2016 03:14
@RK1225 you'll need to run .hasOwnProperty on the argument you pass to the function
Thomas Tzanetoulakos
@tommasgr
Feb 12 2016 03:15
@taylorham mate what do you mean specify the operation that im doing on celsius?
and 9/5?
Taylor Ham
@taylorham
Feb 12 2016 03:15
@RK1225 er... rather on myObj, then check for the argument
@tommasgr (celsius * 9/5)
Thomas Tzanetoulakos
@tommasgr
Feb 12 2016 03:18
@taylorham Thank you mate!!!!!!!!!!!!!!!
CamperBot
@camperbot
Feb 12 2016 03:18
tommasgr sends brownie points to @taylorham :sparkles: :thumbsup: :sparkles:
:warning: tommasgr already gave taylorham points
Thomas Tzanetoulakos
@tommasgr
Feb 12 2016 03:18
@taylorham all day for this
thank you very much.
Taylor Ham
@taylorham
Feb 12 2016 03:18
@tommasgr anytime! I know the frustrations
sherrardsd
@sherrardsd
Feb 12 2016 03:19
Would someone mind reading over my code for the ROT-13 challenge? I am getting an extra letter appearing and I'm not sure why
never mind I found it!!
thanks anyway, everybody in here helping others out is AWESOME
Taylor Ham
@taylorham
Feb 12 2016 03:19
@sherrardsd haha, congrats!
RK1225
@RK1225
Feb 12 2016 03:21
@taylorham , i still just don't get it. what argument am i passing to the function? and then do i put the .hasOwnProperty() after the return outside the function?
Taylor Ham
@taylorham
Feb 12 2016 03:22
@RK1225 no worries. can you post your code one more time?
@RK1225 to format it, type ``` <shift + enter>
Brian Kilrain
@bkilrain
Feb 12 2016 03:23
Hi all - I’m currently breezing through basic algorithm challenges. I haven’t had too much trouble until this current one: Seek and Destroy. I have to filter arguments out of an array. I’ve tried to research arguments objects and I just can’t get my head around the concept.
Taylor Ham
@taylorham
Feb 12 2016 03:24
@bkilrain I had trouble with that one, too. The hints on the wiki helped me immensely > https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Algorithm-Seek-and-Destroy
Brian Kilrain
@bkilrain
Feb 12 2016 03:24
I understand they can be used when we want to pass more than one argument… but the How is frying my brain
thanks @taylorham I’ll check that out and if I have any other questions I shall return^^
CamperBot
@camperbot
Feb 12 2016 03:25
bkilrain sends brownie points to @taylorham :sparkles: :thumbsup: :sparkles:
:star: 177 | @taylorham | http://www.freecodecamp.com/taylorham
Taylor Ham
@taylorham
Feb 12 2016 03:25
@bkilrain just don't scroll down far enough to see the answer and keep trying to figure it out!
Brian Kilrain
@bkilrain
Feb 12 2016 03:25
you got it :smile:
pandaxoom
@pandaxoom
Feb 12 2016 03:27
Hi I'm stuck on a challenge called Profile Lookup and I've got all the ticks except one...
I cant figure out whats wrong
Taylor Ham
@taylorham
Feb 12 2016 03:29
@pandaxoom can you post your code for us? to format it put three backticks (```) and hit shift+enter, then paste your block in there
@RK1225 having any luck?
pandaxoom
@pandaxoom
Feb 12 2016 03:30

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

}
}
// Only change code above this line
}

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

Taylor Ham
@taylorham
Feb 12 2016 03:31
Oh yeah, it needs to end with ``` on a separate line as well ;P
pandaxoom
@pandaxoom
Feb 12 2016 03:31
I can't get the "No such contact" else to work without breaking the first 3 tests. I cant figure where to put the last else correctly. I know where i think it should go - which gives the correct result for that test, but breaks the first three tests
bitgrower
@bitgrower
Feb 12 2016 03:32
thanks @dcnr
CamperBot
@camperbot
Feb 12 2016 03:32
bitgrower sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 603 | @dcnr | http://www.freecodecamp.com/dcnr
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 12 2016 03:32
I am having problems with wiki search if there’s two words with the space in between. I’m stumped. http://codepen.io/pkshreeman/pen/yeEorX
bitgrower
@bitgrower
Feb 12 2016 03:33
@pandaxoom -- can you post your code (or is it somewhere above) ?
pandaxoom
@pandaxoom
Feb 12 2016 03:33
function lookUp(firstName, prop){
// Only change code below this line
var result = "";
 for (var i = 0; i < contacts.length; i++) {
  if (contacts[i]["firstName"] == firstName) {
    if (contacts[i].hasOwnProperty(prop)) {
      result = contacts[i][prop];
      return result;
      }
    else {
     return "No such property";
   }

  }
 }
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
DJ
@qualitymanifest
Feb 12 2016 03:34
@pkshreeman what problem? it works for me.
bitgrower
@bitgrower
Feb 12 2016 03:34
Ahh ... okay ... I see ...
Taylor Ham
@taylorham
Feb 12 2016 03:34
@pandaxoom Place the return of "No such contact" just before the end of your test for the contact's name
bitgrower
@bitgrower
Feb 12 2016 03:34
so ... here's the question ... you have 3 things you need to do .... work out how you would determine them separately ...
pandaxoom
@pandaxoom
Feb 12 2016 03:34
ah - ok
Taylor Ham
@taylorham
Feb 12 2016 03:35
@bitgrower ah crap, I gave too much away, didn't I?
bitgrower
@bitgrower
Feb 12 2016 03:35
@pandaxoom -- so, one of the things you have to do is determine if something IS NOT there ...
pandaxoom
@pandaxoom
Feb 12 2016 03:35
i put a second else in and get it functioning but then it breaks the earlier tests
bitgrower
@bitgrower
Feb 12 2016 03:35
dunno, @taylorham -- didn't see what you said ...
@pandaxoom ... code EACH condition separately ...
so ... ask yourself ... how would I determine if something has a particular property ... code that
Kala Radl
@mossandboar
Feb 12 2016 03:36
@efhjones I've tried a few thing and I understand what to do but I'm missing something. code still looks the same everything seems correct up to the "if"
pandaxoom
@pandaxoom
Feb 12 2016 03:36
thanks @bitgrower - i'll try that.
CamperBot
@camperbot
Feb 12 2016 03:36
pandaxoom sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 464 | @bitgrower | http://www.freecodecamp.com/bitgrower
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 12 2016 03:37
@qualitymanifest with two words?
DJ
@qualitymanifest
Feb 12 2016 03:38
@pkshreeman yes. what problem are you having when you try two words? the only problem i see is that you aren't emptying out the old results before adding on the new ones
bitgrower
@bitgrower
Feb 12 2016 03:38
@taylorham -- I came up with a new question today ... "do you want the answer, or do you want to know how to fish?"
rphares
@rphares
Feb 12 2016 03:39
(i saw you say that, my yesterday :) Also-- hiya, @bitgrower , @qualitymanifest :) )
bitgrower
@bitgrower
Feb 12 2016 03:39
I am of the "teach people how to fish" group
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 12 2016 03:39
strange…it isn’t working on my end…what browser are you using? @qualitymanifest
pandaxoom
@pandaxoom
Feb 12 2016 03:39
@bitgrower - does that mean i need a new loop to test each condition?
bitgrower
@bitgrower
Feb 12 2016 03:39
hi @rphares ...
Taylor Ham
@taylorham
Feb 12 2016 03:39
@bitgrower totally get that. this is my first day on the helping side of things and I'm not the best teacher yet. that quote makes a lot of sense, but the way you phrased the solution was infinitely better than I had thought of
DJ
@qualitymanifest
Feb 12 2016 03:39
@pkshreeman chrome. have you tried it with two words after refreshing?
@rphares hello :wave:
Ihsan Fauzan
@ihsanfauzan
Feb 12 2016 03:40

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

bitgrower
@bitgrower
Feb 12 2016 03:40
@pandaxoom -- what i'm advising is a way to solve the problem over all ... right now, you are trying to solve 3 problems at the same time and they are kind of colliding into each other (mentally)
Ihsan Fauzan
@ihsanfauzan
Feb 12 2016 03:40
need help with that
DJ
@qualitymanifest
Feb 12 2016 03:40
@pkshreeman i suspect your problem is that you are trying it with two words after trying it with one word, and you're expecting to see the new results, but you aren't because they're being appended to the bottom of the old results.
pandaxoom
@pandaxoom
Feb 12 2016 03:41
ok thanks @bitgrower
CamperBot
@camperbot
Feb 12 2016 03:41
pandaxoom sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: pandaxoom already gave bitgrower points
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 12 2016 03:41
@qualitymanifest even with refresh or debug in safari browser, I get no results if I use two words.
bitgrower
@bitgrower
Feb 12 2016 03:41
here's probably the biggest hint, or at least the one people seem to have most trouble with on that problem: code it so you answer the 3rd condition ... the one where NO objects were found that met the firstname requirement ...
rphares
@rphares
Feb 12 2016 03:42
@ihsanfauzan , i suggest reviewing the MDN on push and shift, that'll really be all you need :blush:
Ihsan Fauzan
@ihsanfauzan
Feb 12 2016 03:42
aah okey! thank you @rphares
CamperBot
@camperbot
Feb 12 2016 03:42
ihsanfauzan sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2682 | @rphares | http://www.freecodecamp.com/rphares
bitgrower
@bitgrower
Feb 12 2016 03:42
...this is called "stepwise refinement" ... take one piece of your code ... get it right. Then add the next piece ... etc ...
this helps in the future, when you get into doing things like unit tests :)
rphares
@rphares
Feb 12 2016 03:43
sure thing :)
bitgrower
@bitgrower
Feb 12 2016 03:43
(don't think they teach that here -- but it is industry practice for sure...)
DJ
@qualitymanifest
Feb 12 2016 03:44
@pkshreeman i just tried it on CrossBrowserTesting using OS X 10.11 and safari 9 and it works
Selection_106.png
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 12 2016 03:44
@qualitymanifest that’s amazing.
Monty
@webdev8183
Feb 12 2016 03:45
ugh this default option in switch statement looks to have an error, it won't pass me and I am not sure why.
rphares
@rphares
Feb 12 2016 03:46
@webdev8183 , please paste your code :blush:
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 12 2016 03:46
Now I am utterly baffled…:) @qualitymanifest ok it works…but not on my end…that’s bizarre ….I just tried chrome as well.
DJ
@qualitymanifest
Feb 12 2016 03:46
@pkshreeman are you sure you're searching for something valid?
Taylor Ham
@taylorham
Feb 12 2016 03:46

@webdev8183 ``` <shift+enter>

<your code here>
```

rphares
@rphares
Feb 12 2016 03:46
( @webdev8183 , the most common error on that one is to forget to put "" on the letters for the cases,)
Monty
@webdev8183
Feb 12 2016 03:47

function myTest(val) {
var answer = "";
// Only change code below this line
switch(answer){
case "a":
console.log("apple");
break;
case "b":
console.log("bird");
break;
case "c":
console.log("cat");
break;

default:
  console.log("stuff");

}

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

// Change this value to test
myTest("c");

its not clear from the directions if answer or val is the value to switch on.. I have tried both neither passes.
bitgrower
@bitgrower
Feb 12 2016 03:47
@webdev8183 -- check the argument name vs what you are using in your switch statement
Monty
@webdev8183
Feb 12 2016 03:48
instructions say following.. Write a switch statement to set answer for the following conditions:
"a" - "apple"
"b" - "bird"
"c" - "cat"
default - "stuff"
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 12 2016 03:48
Oh! (Slaps my forehead)…you are right…null results…I did bullet train and john smith and that works…need to do the clean-up thingie and it’s set! Thank you! @qualitymanifest
CamperBot
@camperbot
Feb 12 2016 03:48
pkshreeman sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 946 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Norman Dela Cruz
@dcnr
Feb 12 2016 03:49
@webdev8183 set answer not console.log :P
bitgrower
@bitgrower
Feb 12 2016 03:49
right -- are you using the parameter val ? I could have missed it ...
you have to switch on the incoming value, don't you ?
^^^ and also what @dcnr says ...
Monty
@webdev8183
Feb 12 2016 03:50
answer is set to null, so I would think so but it doesnt work even if I use val, even if i set answer to val its just saying a is not defined
bitgrower
@bitgrower
Feb 12 2016 03:50
@webdev8183 -- where are you using val, at all ?
boleda
@boleda
Feb 12 2016 03:52
Thank you @ghopkins919, I had the same question - and to @JetmirShatri and @blauelf, too. Looking forward to when I can add to, as well as, take away. : )
CamperBot
@camperbot
Feb 12 2016 03:52
boleda sends brownie points to @ghopkins919 and @jetmirshatri and @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1180 | @blauelf | http://www.freecodecamp.com/blauelf
:star: 255 | @ghopkins919 | http://www.freecodecamp.com/ghopkins919
:star: 248 | @jetmirshatri | http://www.freecodecamp.com/jetmirshatri
bitgrower
@bitgrower
Feb 12 2016 03:52
yeah, it helps if you understand what the first lines of code are doing ... a switch statement is just a replacement for a bunch of if/else statements ... where the if/else is checking for the value of the same variable ...
Luke Murray
@vremerz
Feb 12 2016 03:53

i dont know why this doesnt work?
var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.

var newArray = oldArray.filter(function(val) {
return val > 5;
});

filter arrays with filter

bitgrower
@bitgrower
Feb 12 2016 03:54
vremez ... there are two things people need to know on this one ...
  1. how the array is filtered by Array.filter
  2. the instructions of the challenge
review those, and I suspect you'll find the answer ... :)
Luke Murray
@vremerz
Feb 12 2016 03:54
when i click run, it does filter out all the numbers > 5 tho
mitch
@mitchxps
Feb 12 2016 03:54
cant figure out why this wont work when inputting values
Otman Bouchari
@obouchari
Feb 12 2016 03:54
@vremerz filter only keep the values that return true
bitgrower
@bitgrower
Feb 12 2016 03:55
and you want to filter out numbers <= 5, right ?
Monty
@webdev8183
Feb 12 2016 03:55
@bitgrower those directions on this challenge are vague,
thanks I got it now.
bitgrower
@bitgrower
Feb 12 2016 03:55
light bulb came on ? :)
Norman Dela Cruz
@dcnr
Feb 12 2016 03:55
@webdev8183 I think there's a certain nuance to understanding these descriptions :(
bitgrower
@bitgrower
Feb 12 2016 03:55
no doubt, @dcnr ..
Monty
@webdev8183
Feb 12 2016 03:56
I knew how to do it, but there directions had me chasing my tail.
bitgrower
@bitgrower
Feb 12 2016 03:57
yeah, some of the instructions can be like that ... so, when that happens, it helps to re-review the instructions ... maybe a few times, and make sure to understand what's supposed to be returned ... as well as any "helpful links" provided ... ESPECIALLY, at times, the "helpful links"
mitch
@mitchxps
Feb 12 2016 03:57

sry didnt paste correctly... cant figure out why values truncate(A-",1) doesnt work? everything else in the test worksfunction truncate(str, num) {

var a = str.length;

if(a > num){

str = str.slice(0,num-3) + "..." ;

}
if(num <= 3){

str = str.slice(0,num) + "..." ;

}

return str;
}

truncate("A-tisket a-tasket A green and yellow basket", 11);

bitgrower
@bitgrower
Feb 12 2016 03:57
most people who will ask you to code something will often not be able to explain it well ...
Luke Murray
@vremerz
Feb 12 2016 03:58
@bitgrower thanks got it now
CamperBot
@camperbot
Feb 12 2016 03:58
vremerz sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 465 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 12 2016 03:58
awesome, @vremerz -- happy coding!
@mitchxps -- I know on that particular challenge, I had to go back and CAREFULLY re-read the instructions ...
mitch
@mitchxps
Feb 12 2016 03:59
ok i will
thanks for the tip i didnt want the answer i want to beat this one badly i been on it for over half hour lol
bitgrower
@bitgrower
Feb 12 2016 04:00
LOL, I know the feeling ...
I can't count the number of times where, when one or more of my test cases didn't pass, the answer was in reviewing the instructions for the challenge ...
mitch
@mitchxps
Feb 12 2016 04:01
i know its my seconf IF statement but cant see it yet, ill get there
Thomas Tzanetoulakos
@tommasgr
Feb 12 2016 04:01
Guys good morning!Can somebody help me here please?Escaping Literal Quotes in Strings.
Otman Bouchari
@obouchari
Feb 12 2016 04:01
@mitchxps Try also to break the problem (or instructions) to pieces and write code for each piece!
Thomas Tzanetoulakos
@tommasgr
Feb 12 2016 04:01
can you tell me my wrong
bitgrower
@bitgrower
Feb 12 2016 04:01
can you show us whatcha got, @tommasgr ?
mitch
@mitchxps
Feb 12 2016 04:02
yes your right @bitgrower
Thomas Tzanetoulakos
@tommasgr
Feb 12 2016 04:02
var myStr = "I am a \""double quoted" \"string inside" \"double quotes\"";
mitch
@mitchxps
Feb 12 2016 04:02
will do @obouchari
bitgrower
@bitgrower
Feb 12 2016 04:03
good problem solving approach, @obouchari
Thomas Tzanetoulakos
@tommasgr
Feb 12 2016 04:03
You should use two double quotes (") and four escaped double quotes (\")
Variable myStr should equal to ("I am a "double quoted" string inside "double quotes""). @bitgrower
bitgrower
@bitgrower
Feb 12 2016 04:03
what are the instructions, @tommasgr ?
Norman Dela Cruz
@dcnr
Feb 12 2016 04:03
@mitchxps yeah it's going inside your first if AND your second if. The first if set str to '...' then the second if sets it to .... ('...'.splice(0,1) + '...')
Kevin Myrick
@aphextwin234
Feb 12 2016 04:05
I'm looking to make a calendar in JS does anyone know a good reference?
mitch
@mitchxps
Feb 12 2016 04:06
i knew i was adding an extra "." but didnt see where it added. TY @dcnr
bitgrower
@bitgrower
Feb 12 2016 04:06
@tommasgr -- I don't know what kind of hint to give you, and I'm not sure if I tell you how to fix this it will be immediately obvious ... but you are adding too much into string ...
mitch
@mitchxps
Feb 12 2016 04:06
is it good practice to use the else statement or is two " if" statements ok here?
Otman Bouchari
@obouchari
Feb 12 2016 04:06
@tommasgr in most prog languages you can use either double quotes " or single quotes ' on a string, you can't combine them.
bitgrower
@bitgrower
Feb 12 2016 04:07
so .. you have ONE quoted string ... right now, you've made it into multiple separately quoted strings ...
Norman Dela Cruz
@dcnr
Feb 12 2016 04:07
@mitchxps it's arguable but personally, I lean toward the no-else camp :P
@mitchxps it's just how you structure your conditions
mitch
@mitchxps
Feb 12 2016 04:08
gotcha @dcnr
bitgrower
@bitgrower
Feb 12 2016 04:08
@mitchxps -- probably more of a matter of style ... the main thing is ... is it readable? Can someone else look at your code and have an idea of what's going on ...
(because that person may very well be the future you ... )
mitch
@mitchxps
Feb 12 2016 04:08
makes sense @bitgrower
Otman Bouchari
@obouchari
Feb 12 2016 04:09
@tommasgr string start with quotes " or ' and ends with same quotes you start with
bitgrower
@bitgrower
Feb 12 2016 04:09
I think most of the js code I see, they tend not to use the extra else ... but the main thing, for the most part, is is it clear to you ...
Thomas Tzanetoulakos
@tommasgr
Feb 12 2016 04:09
@bitgrower if you can please give the obvious answer because i need to understand what's going on.
mitch
@mitchxps
Feb 12 2016 04:09
i figured " else" was false anyway so why even have to always add it in...just my way of thinking about it , i might be wrong tho
bitgrower
@bitgrower
Feb 12 2016 04:09
@tommasgr -- you have too many quotes
greg
@wearenotgroot
Feb 12 2016 04:10
@pkshreeman might want to use .hasOwnProperty('query') on the result that comes back :smile:
Otman Bouchari
@obouchari
Feb 12 2016 04:10
if contain same quotes somewhere in the middle you have to escape them with \
bitgrower
@bitgrower
Feb 12 2016 04:10
I mentioned above ... what you have ended up with is NOT ONE string with escaped quotes, but multiple strings ...
pandaxoom
@pandaxoom
Feb 12 2016 04:11
@bitgrower thanks so much i got it.
CamperBot
@camperbot
Feb 12 2016 04:11
pandaxoom sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: pandaxoom already gave bitgrower points
bitgrower
@bitgrower
Feb 12 2016 04:12
this is a string: "I am a \""
double quoted <-- probably confuses the parser horribly ... probably looks for vars with those names ...
YAY!!!!! @pandaxoom !!!
Otman Bouchari
@obouchari
Feb 12 2016 04:12
@mitchxps sometimes its for readability, sometimes its redundant to use it, sometimes you have only 2 choices
bitgrower
@bitgrower
Feb 12 2016 04:13
so ... did separating the problem out into 3 separate parts help, @pandaxoom
Norman Dela Cruz
@dcnr
Feb 12 2016 04:13

@mitchxps depends on the scenario really, for example

function func(val) {
  if (val) {
    //do true
    return something;
  }

  // obviously false no need for else
  return doSomethingElse;
}

simplified but you get the idea

mitch
@mitchxps
Feb 12 2016 04:14
def get the idea @dcnr
bitgrower
@bitgrower
Feb 12 2016 04:14
@tommasgr -- ground control to major tom ...
mitch
@mitchxps
Feb 12 2016 04:14
so its good practice but only really for readability for others( and maybe myself)
Norman Dela Cruz
@dcnr
Feb 12 2016 04:15
@mitchxps have you fixed your code?
mitch
@mitchxps
Feb 12 2016 04:16
gonna fix it now ill show you when done
bitgrower
@bitgrower
Feb 12 2016 04:16

yeah, @mitchxps -- but I think you'll see much more js code written like @dcnr wrote it ..

which gives some of my old structured programming lessons the willies ... as we were taught single entry single exit ... hahahahahahahahaha

THAT is definitely NOT what happens in the js world ...
thanks, @dcnr
CamperBot
@camperbot
Feb 12 2016 04:17
bitgrower sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:warning: bitgrower already gave dcnr points
bitgrower
@bitgrower
Feb 12 2016 04:17
LOL, I need a countdown timer for giving people points ...
Franco Zapata
@Francozt01
Feb 12 2016 04:19
@bitgrower give points for free
lol
Norman Dela Cruz
@dcnr
Feb 12 2016 04:19
@bitgrower does it looks like this?!
.global    _start

.text
_start:
    movl    $4, %eax
    movl    $1, %ebx
    movl    $msg, %ecx
    movl    $len, %edx
    int    $0x80

    movl    $1, %eax
    movl    $0, %ebx
    int    $0x80
.data
msg:
    .ascii    "Hello, world!\n"
    len =    . - msg
lol thanks @bitgrower
CamperBot
@camperbot
Feb 12 2016 04:20
dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 466 | @bitgrower | http://www.freecodecamp.com/bitgrower
Norman Dela Cruz
@dcnr
Feb 12 2016 04:20
@bitgrower oh project idea, brownie timer. one hour cooldown right?
bitgrower
@bitgrower
Feb 12 2016 04:20
ah dear ... is that intel ? never did much intel chip programming ... I was a motorola kid
@dcnr ... yup ...
Norman Dela Cruz
@dcnr
Feb 12 2016 04:21
@bitgrower I knew it, you're one of em old wizard people!
bitgrower
@bitgrower
Feb 12 2016 04:21
mc680x0 all the way, baby !!!!
Norman Dela Cruz
@dcnr
Feb 12 2016 04:21
lool
bitgrower
@bitgrower
Feb 12 2016 04:21
don't give me no stinkin' special registers ... I want ALL my registers to be general purpose!!
Norman Dela Cruz
@dcnr
Feb 12 2016 04:23
I'll rue the day I'll have to relearn these stuffs again. Some things should be left forgotten.
Thomas Tzanetoulakos
@tommasgr
Feb 12 2016 04:28
@bitgrower var myStr = "I am a \"double quoted" \"string inside" \"double quotes ""; Where i am wrong?
Otman Bouchari
@obouchari
Feb 12 2016 04:28
@dcnr Cool stuff!! did you check out Arduino systems? it's good
Karma Tsering
@ktseringchem
Feb 12 2016 04:29

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

return collection;
}

bitgrower
@bitgrower
Feb 12 2016 04:29
so @tommasgr -- you need to go ... real quote, escaped quote escaped quote ... escaped quote escaped quote real quote
Karma Tsering
@ktseringchem
Feb 12 2016 04:29
what is wrong with this code?
Taylor Ham
@taylorham
Feb 12 2016 04:29
@tommasgr missing one more backslash! Should have 4 in that example
Karma Tsering
@ktseringchem
Feb 12 2016 04:29
The following test would fail: After update(1245, "tracks", "Addicted to Love"), tracks should have a length of 1
Taylor Ham
@taylorham
Feb 12 2016 04:30
@tommasgr And you've got a couple extra double quotes
Norman Dela Cruz
@dcnr
Feb 12 2016 04:30
@obouchari I'd like an arduino! I'm hoping to get one and a pi this year :D
bitgrower
@bitgrower
Feb 12 2016 04:31
@tommasgr -- your escaped quotes should come in pairs, and then you should have two more quotes, 1 at each end of the string ...
Otman Bouchari
@obouchari
Feb 12 2016 04:31
Cool!! :)
bitgrower
@bitgrower
Feb 12 2016 04:32
arduino -- very cool -- I knew I had run across it before ...
@ktseringchem -- you'll get more help if you post your entire code, and do it in the way camperbot explains just as soon as I ask her...
explain format
CamperBot
@camperbot
Feb 12 2016 04:32

: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

Rae
@Raesling
Feb 12 2016 04:32
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i=1; i<arr.length;i++){
    for (var j=1; j<arr[i].length; j++){
     product=(i*j);
     product = " " + product;  
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
I'm not sure what I'm doing wrong w/ this? @pradeepce tried to help me in /Help, but, tbh, I'm not sure what he was hinting at. The class is Nested For Loops. I get the objective of iterating through the loops--it's the multiplying through it that I'm not understanding. Thanks in advance!
CamperBot
@camperbot
Feb 12 2016 04:32
raesling sends brownie points to @pradeepce :sparkles: :thumbsup: :sparkles:
:star: 261 | @pradeepce | http://www.freecodecamp.com/pradeepce
Otman Bouchari
@obouchari
Feb 12 2016 04:32
@bitgrower The good news you can program it with JS
bitgrower
@bitgrower
Feb 12 2016 04:33
that hurts my head a bit right now, @obouchari -- I took digital electronics, and I am an old-school assembly language programmer ... to me hardware should be programmed in assembly !!!!
(I DID say I was old school, right ?)
Otman Bouchari
@obouchari
Feb 12 2016 04:35
originaly you can write code with C#, I think, but you can use some libraries to write in JS or other languages
But I don't know if its possible to use Assembly.
Cam
@CamMakoJ
Feb 12 2016 04:37
i have a bit of a struggle on 'Profile Lookup'
can anyone help out?
Karma Tsering
@ktseringchem
Feb 12 2016 04:37

`var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
`

sorry
Otman Bouchari
@obouchari
Feb 12 2016 04:38
@CamMakoJ Sure! what is the issue?
Pandarati
@Pandarati
Feb 12 2016 04:38
@ktseringchem Edit the post so that the "`" at the top is on a line by itself
Cam
@CamMakoJ
Feb 12 2016 04:39
@obouchari i for some reason cant get my statements to return the property arrays
Otman Bouchari
@obouchari
Feb 12 2016 04:40
Can you paste some code here?
Karma Tsering
@ktseringchem
Feb 12 2016 04:40

`

var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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


  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");

`

bitgrower
@bitgrower
Feb 12 2016 04:40
YAY!!!! wtg, @ktseringchem !
Karma Tsering
@ktseringchem
Feb 12 2016 04:40
@Pandarati thank you
CamperBot
@camperbot
Feb 12 2016 04:40
ktseringchem sends brownie points to @pandarati :sparkles: :thumbsup: :sparkles:
Cam
@CamMakoJ
Feb 12 2016 04:40
function lookUp(firstName, prop){
// Only change code below this line
for (i=0; i < contacts.length; i++) {
if (firstName === contacts[i].firstName) {
if (prop === contacts[i].prop) {
return contacts[i].prop;
}
else{
return 'No such property';
}
}
else {
return "No such contact";
}
}
CamperBot
@camperbot
Feb 12 2016 04:40
:star: 366 | @pandarati | http://www.freecodecamp.com/pandarati
Karma Tsering
@ktseringchem
Feb 12 2016 04:41
@bitgrower woot
rphares
@rphares
Feb 12 2016 04:41
@ktseringchem , check out your ifs... you dont need to usecollection[id][prop] in the if part, only in the {} part...
bitgrower
@bitgrower
Feb 12 2016 04:41
@CamMakoJ -- you have 3 conditions to test for ... while you can put them all in one piece of code .. I recommend you FIRST start by coding a snippet for each condition ...
Cam
@CamMakoJ
Feb 12 2016 04:42
@bitgrower a snippet?
rphares
@rphares
Feb 12 2016 04:42
read the instructions again, @ktseringchem -- If value is non-blank (value !== "") and prop is not "tracks"... its just that simple :)
bitgrower
@bitgrower
Feb 12 2016 04:42
snippet = a little piece of code, written, often, for testing purposes ...
Karma Tsering
@ktseringchem
Feb 12 2016 04:42
@rphares ok I will try that
rphares
@rphares
Feb 12 2016 04:43
:blush: (i didn't look hard, there may be more, that just jumped out :) )
Otman Bouchari
@obouchari
Feb 12 2016 04:43
@CamMakoJ you can't access contacts[i].prop, prop is a variable
Rae
@Raesling
Feb 12 2016 04:44
No one has an answer for what I'm doing wrong w/ my code, tho? :worried:
bitgrower
@bitgrower
Feb 12 2016 04:44

so ... you have 3 conditions ... write 3 separate pieces of code ... :) ...

I am advising this based on dozens of people who have come in here with the same problem ... and I believe if you separate out each thing you are supposed to do, it makes it easier to see what's going wrong ... :)

@Raesling -- I haven't looked ...
Cam
@CamMakoJ
Feb 12 2016 04:44
@obouchari ahhh ok ok i see, didnt realize i couldnt use a variable there
@bitgrower ahh ok ok
Pradeep CE
@cepradeep
Feb 12 2016 04:44

@Raesling If you do

product=(i*j);

then you are re-assigning the value of product during every iteration. That strike a bell?

Otman Bouchari
@obouchari
Feb 12 2016 04:44
@CamMakoJ also you can check if contacts[i] has a property
Thomas Tzanetoulakos
@tommasgr
Feb 12 2016 04:44
After two hours i did it. @bitgrower Thank you
CamperBot
@camperbot
Feb 12 2016 04:44
tommasgr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 467 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 12 2016 04:45
YAY !!!!!
Cam
@CamMakoJ
Feb 12 2016 04:45
thanks @bitgrower @obouchari
CamperBot
@camperbot
Feb 12 2016 04:45
cammakoj sends brownie points to @bitgrower and @obouchari :sparkles: :thumbsup: :sparkles:
:star: 468 | @bitgrower | http://www.freecodecamp.com/bitgrower
:star: 307 | @obouchari | http://www.freecodecamp.com/obouchari
bitgrower
@bitgrower
Feb 12 2016 04:45
you feel solid about it now, @tommasgr ?
Rae
@Raesling
Feb 12 2016 04:45
OHHHH, Doh! Thanks, @pradeepce !
CamperBot
@camperbot
Feb 12 2016 04:45
raesling sends brownie points to @pradeepce :sparkles: :thumbsup: :sparkles:
:warning: raesling already gave pradeepce points
bitgrower
@bitgrower
Feb 12 2016 04:46
@raesling -- your problem is one in knowing how to address each element of the arrays/subarrays ... more specifically, the subarrays ...
(it's not your only problem ... but it's a major one ... )
Karma Tsering
@ktseringchem
Feb 12 2016 04:47
thanks @rphares it worked
CamperBot
@camperbot
Feb 12 2016 04:47
:star: 2683 | @rphares | http://www.freecodecamp.com/rphares
ktseringchem sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
Otman Bouchari
@obouchari
Feb 12 2016 04:47
@CamMakoJ
var prop = "name";
var obj = {
   name: "CamMakoJ";
};
obj[prop]; // "CamMakoJ"
bitgrower
@bitgrower
Feb 12 2016 04:48
i and j, you are using as indexes into the arrays, and then into the subarrays ...
rphares
@rphares
Feb 12 2016 04:48
yay, congrats, @ktseringchem ~
bitgrower
@bitgrower
Feb 12 2016 04:48
they are indexes -- which is a way of addressing a slot in memory -- but it is not the contents of the memory (that is, the member of the array) itself ...
Otman Bouchari
@obouchari
Feb 12 2016 04:49
prop === obj[prop]; // still will not work, you are doing this instead  "name" === "CamMakoJ"
Pradeep CE
@cepradeep
Feb 12 2016 04:49
@Raesling Feel free to ask here if you are still stuck :)
Rae
@Raesling
Feb 12 2016 04:51
OK, @pradeepce. I'm still processing all that you and @bitgrower are telling me.
Jason
@carpediem1213
Feb 12 2016 04:53
help confirm the ending
CamperBot
@camperbot
Feb 12 2016 04:53

:point_right: algorithm confirm the ending [wiki]

Explanation:

The function is a whole Boolean operation. You need to return true if the first argument ends with the second argument. This means that for the problem script, it should return true for the end('Bastian', 'n'); case.

:pencil: read more about algorithm confirm the ending on the FCC Wiki

Thomas Tzanetoulakos
@tommasgr
Feb 12 2016 04:54
@bitgrower Now i can have a goodmorning!
bitgrower
@bitgrower
Feb 12 2016 04:54
YAY !!!!! happy coding @tommasgr
@carpediem1213 -- to encourage your use of the MDN documentation, I'm going to tell you that I stumbled across a super cool function there you can use to do that challenge in practically one line of code ... :)
Jason
@carpediem1213
Feb 12 2016 04:55
@bitgrower if it's substr I'm already at 4 lines ha ha
bitgrower
@bitgrower
Feb 12 2016 04:56

(at least I think I did ... I need to go back and check ... I haven't re-written mine ... ) --

No, I don't think it was substr, @carpediem1213 :)

it's either a string or an array function, i don't remember which now ...
substr would NOT have excited me like I remember being excited when I saw it ...
unfortunately, I'm having trouble pulling up the MDN pages now ...
Norman Dela Cruz
@dcnr
Feb 12 2016 04:57
confirm the ending?! I think you can do it in 45 characters or so
bitgrower
@bitgrower
Feb 12 2016 04:57
@Raesling ... from the just prior exercise, you remember how to address a single member of an array, right ?
hahahahaha @dcnr we should have a scavenger/treasure hunt ...
Otman Bouchari
@obouchari
Feb 12 2016 04:59
@carpediem1213 It's a 1 line of code like @bitgrower said :)
Cam
@CamMakoJ
Feb 12 2016 04:59
@obouchari i have tried quite a few things on this one, do you know where i should start to look
Norman Dela Cruz
@dcnr
Feb 12 2016 04:59
@bitgrower even though it's taken from the official docs, I find http://devdocs.io/ easier to search for stuffs :D
Jason
@carpediem1213
Feb 12 2016 04:59
  var a = target.substr( target.length-3 );
  var b = str.substr( str.length-3 );
  var c = str.substr( str.length -1 );
  var d = target.substr( target.length - 1 );

  return ( a === b || c ===d );
This passes all tests but one :(
bitgrower
@bitgrower
Feb 12 2016 05:00
thanks, @dcnr -- I've seen that referenced, but haven't explored it yet ...
CamperBot
@camperbot
Feb 12 2016 05:00
bitgrower sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 604 | @dcnr | http://www.freecodecamp.com/dcnr
DJ
@qualitymanifest
Feb 12 2016 05:00
@dcnr just to check i tried it myself just now, and i did the return in 40 characters (using ES5, and not including the length of 'return')
bitgrower
@bitgrower
Feb 12 2016 05:01
I kinda wish MDN would do like php.net does -- -which have ongoing conversations about different parts of the language right on the language page ... (too, unbelievably, cool ... )
DJ
@qualitymanifest
Feb 12 2016 05:01
make that 38
Otman Bouchari
@obouchari
Feb 12 2016 05:01
@CamMakoJ Your code was good except some issues:
  • Check if obj has property instead of comparing prop to contacts[i].prop
bitgrower
@bitgrower
Feb 12 2016 05:01
@qualitymanifest -- show off !!!! :) (good job!)
DJ
@qualitymanifest
Feb 12 2016 05:02
@bitgrower haha, but i'm sure if i knew ES6 i could probably do the entire function in that many characters
Norman Dela Cruz
@dcnr
Feb 12 2016 05:03
@qualitymanifest yeah it's just slice if you use == and forgo spaces and semicolon, you can do it in 40 chars with the return included
es3 too!
Rae
@Raesling
Feb 12 2016 05:04
@bitgrower yes
DJ
@qualitymanifest
Feb 12 2016 05:04
@dcnr ah, yep
Wes
@weslez
Feb 12 2016 05:05
help Nesting For Loops
CamperBot
@camperbot
Feb 12 2016 05:05

:point_right: challenge nesting for loops [wiki]

Challenge: Nesting For Loops

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

    var arr = [
      [1,2], [3,4], [5,6]
    ];
    for (var i=0; i < arr.length; i++) {
      for (var j=0; j < arr[i].length; j++) {
        console.log(arr[i][j]);
      }
    }

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

bitgrower
@bitgrower
Feb 12 2016 05:06
okay -- in that problem you added elements of an array together ... so how would you multiply them instead (I'm trying to take from what you know and building upon it)
Rae
@Raesling
Feb 12 2016 05:06
I appreciate that. Maybe I'm just tired.
Wes
@weslez
Feb 12 2016 05:06
thanks @bitgrower - My impulse is i*1 instead of i++
bitgrower
@bitgrower
Feb 12 2016 05:06
LOL ... sheesh ... if I posted that every time someone came in with a problem with Nesting For Loops I would have saved a Lot of time ...
CamperBot
@camperbot
Feb 12 2016 05:06
weslez sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 469 | @bitgrower | http://www.freecodecamp.com/bitgrower
Rae
@Raesling
Feb 12 2016 05:07
lol, so it's a common problem with all of us?!
rphares
@rphares
Feb 12 2016 05:08
super common
Wes
@weslez
Feb 12 2016 05:08
@bitgrower Haha! Well, it's good to know I'm not UNusually dense. Just normal type.
bitgrower
@bitgrower
Feb 12 2016 05:08
well, I don't know how common a problem it is for all campers ... but it does show up a lot here
Wes
@weslez
Feb 12 2016 05:09
@bitgrower Can you explain to me where "i" and "j" get their definition? Do those letters have any great importance?
bitgrower
@bitgrower
Feb 12 2016 05:09
probably Fortran
back in early fortran days, the way you named variables determined their type ... and i & j were integer number types ...
(note, there were NO, I mean NO string types ... making outputting a string a bit of a pain...)
Wes
@weslez
Feb 12 2016 05:10
Interesting. I wasn't sure if they were just made up like var "product" or whatever is just made up.
Jason
@carpediem1213
Feb 12 2016 05:11
I always thought i stood for iterative or something
and then j is after i so....
bitgrower
@bitgrower
Feb 12 2016 05:11
@weslez & @Raesling -- check out the "hint" there and see if that helps you ... (I hope I'm giving the right hint to the right people ... I don't remember what we were talking about @weslez ... was it the nested loops as well ?
Wes
@weslez
Feb 12 2016 05:12
multiplying instead of adding in the loop. i*1 instead of i++?
bitgrower
@bitgrower
Feb 12 2016 05:12
nah, I think they go back to the very old fortran days, @carpediem1213
@weslez, no ... look at the hint camperbot posted above ...
(it's practically a giveaway)
Cam
@CamMakoJ
Feb 12 2016 05:13
help Profile lookup
CamperBot
@camperbot
Feb 12 2016 05:13

: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

bitgrower
@bitgrower
Feb 12 2016 05:13
back in fortran IV ...
Norman Dela Cruz
@dcnr
Feb 12 2016 05:13
@weslez I think it comes from this i and j
Jason
@carpediem1213
Feb 12 2016 05:14
@bitgrower Id be grateful for a couple more hints on confirm the ending. I don't want to use a for loop, but substr seems to get me mixed up. I tried length -3 and length - 1 but some of the tests do not pass
bitgrower
@bitgrower
Feb 12 2016 05:15
@carpediem1213 -- what I would recommend is keep trying with substr ... and output the intermediate results to the console.log -- that way you will uncover what substr does, instead of what you are thinking it does ...
Rae
@Raesling
Feb 12 2016 05:15
@bitgrower the part where it says that we have to use arr[i] because i is an array itself?
bitgrower
@bitgrower
Feb 12 2016 05:15
gotta tame the errant brain ccells ...
yes, with nested arrays, arr[i] points to an array ...
Norman Dela Cruz
@dcnr
Feb 12 2016 05:16
@carpediem1213 the hint I realized about confirm the ending is the relationship of the target to the source string
bitgrower
@bitgrower
Feb 12 2016 05:16
(note, you can also always use the handy Array.isArray function(variable) to test ... :)
Norman Dela Cruz
@dcnr
Feb 12 2016 05:17
@carpediem1213 think about where the target is supposed to be in relation to the source
@carpediem1213 then you don't have to hard code slices
Rae
@Raesling
Feb 12 2016 05:18
So, I'm gonna die of embarrassment when I figure out what I'm missing, I'm sure.
Cam
@CamMakoJ
Feb 12 2016 05:18
for (i=0; i < contacts.length; i++) {
if (contacts[i].hasOwnProperty(firstName)) {
if (prop === contacts[i].prop) {
return contacts[i].prop;
}
else{
return 'No such property';
}
}
else {
return "No such contact";
}
}
@obouchari not sure why its not posting it 'pretty'
Otman Bouchari
@obouchari
Feb 12 2016 05:19
@CamMakoJ You don't need if (prop === contacts[i].prop) {
// Check if contacts[i].firstName is equalt to given firstName
Cam
@CamMakoJ
Feb 12 2016 05:21
ok ok
bitgrower
@bitgrower
Feb 12 2016 05:21

I can create an array containing ANYTHING ... and even within the same array, the type of elements do not have to be consistent ...

MyArr = [ [2,3,4], { "myKey" : myVal }, "myString", 3 ]

in this case, MyArr[0] = [2,3,4]

if I want to address one of the elements within MyArr[0], I address it the same way as I address any element of an array ... with brackets ...

so ...

MyArr[0][0] is 2
MyArr0 is 3
and MyArr0 is ????

(pardon the coding style ...variables should customarily begin with lowercase ... I messed up)

Otman Bouchari
@obouchari
Feb 12 2016 05:21
// Then check if contacts[i] has a property
Cam
@CamMakoJ
Feb 12 2016 05:21
ahhhh
bitgrower
@bitgrower
Feb 12 2016 05:22

MyArr = [ [2,3,4], { "myKey" : myVal }, "myString", 3 ]

/*
in this case, MyArr[0] = [2,3,4]

if I want to address one of the elements within MyArr[0], I address it the same way as I address any element of an array ... with brackets ... 

so ... 

MyArr[0][0]  is 2
MyArr[0][1]  is 3
and MyArr[0][2] is ????

*/
Rae
@Raesling
Feb 12 2016 05:23
hehe, I know this one. :P
bitgrower
@bitgrower
Feb 12 2016 05:23
@Raesling -- does that help ?
YAY !!!!
Rae
@Raesling
Feb 12 2016 05:24
haha, Thanks! @bitgrower!
CamperBot
@camperbot
Feb 12 2016 05:24
raesling sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 470 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 12 2016 05:25
the more nested the array, you just whack another pair of brackets at the end of your expression (? not sure that's the right word...)
so @Raesling ... if I am "accumulating" the product of all the members of the sub-arrays, you see how you would do it ?
Cam
@CamMakoJ
Feb 12 2016 05:28
@obouchari i feel closer but now i am still stuck
hrmm
its only really working for the first object in the array
Otman Bouchari
@obouchari
Feb 12 2016 05:28
Whats updated code :)
Cam
@CamMakoJ
Feb 12 2016 05:29
function lookUp(firstName, prop){
// Only change code below this line
for (i=0; i < contacts.length; i++) {
if (firstName === contacts[i].firstName) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
}
else{
return 'No such property';
}
}
else {
return "No such contact";
}
}
// Only change code above this line
}
Norman Dela Cruz
@dcnr
Feb 12 2016 05:31
The trick to getting all these nested objects is to drill down ONE AT A TIME
var backpack = {
  food: {
    fruits: ['Apple', 'Persimmon', 'Gooseberry'],
    candies: ['Nougat', 'Gum', 'Toffee']
  },
  clothes: [
    'Shirt',
    'Pants',
    {
      Underpants: ['Boxers', 'Briefs', 'Thongs']
    }
  ]
};

/* I want to get Toffe */
backpack.food.candies[2]; // "Toffee"

/* I want to get Thongs */
backpack.clothes[2].UnderPants[2]; // thongs

/* explanation */
backpack // object
backpack.clothes // clothes property of backpack which is an array
backpack.clothes[2] /* since clothes is an array we use brackets and 2
                       is the index for anonymous object holding Underpants */
backpack.clothes[2].Underpants // get the Underpants property which is an array
backpack.clothes[2].UnderPants[2] // Finally found Thongs
bitgrower
@bitgrower
Feb 12 2016 05:31

@CamMakoJ -- for the "no such contact", let me ask you a question ... if I have a bag of 20 marbles and I want to know if there is a black marble in the bag, how many of the marbles do I have to look at ... ???

(this is NOT a trick question...however, I'm hoping by answering it, it will give you insight into when to return "no such contact" ...

Cam
@CamMakoJ
Feb 12 2016 05:31
@bitgrower i think i know what you mean
Jason
@carpediem1213
Feb 12 2016 05:35
@bitgrower I understand substring and how it's printing to console. My issue is comparing target to substring without using a for loop
Cam
@CamMakoJ
Feb 12 2016 05:35
@bitgrower @obouchari thankyou both again!!
E
@efhjones
Feb 12 2016 05:36
@mossandboar case 10 - "K" needs to subtract 1 from the count, not add. In your if statements you need to check if the count is positive or negative, not less than -3 or greater than 5
Norman Dela Cruz
@dcnr
Feb 12 2016 05:36
@bitgrower that's a nice analogy
bitgrower
@bitgrower
Feb 12 2016 05:37
thanks @dcnr
CamperBot
@camperbot
Feb 12 2016 05:37
bitgrower sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:warning: bitgrower already gave dcnr points
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:37
Help guys
CamperBot
@camperbot
Feb 12 2016 05:37
no wiki entry for: guys
Norman Dela Cruz
@dcnr
Feb 12 2016 05:37
thanks too @bitgrower I have trouble explaining on why and where to put the return
CamperBot
@camperbot
Feb 12 2016 05:37
dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 472 | @bitgrower | http://www.freecodecamp.com/bitgrower
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:37
Help girls
CamperBot
@camperbot
Feb 12 2016 05:37
no wiki entry for: girls
Norman Dela Cruz
@dcnr
Feb 12 2016 05:37
thanks @obama
CamperBot
@camperbot
Feb 12 2016 05:37
dcnr sends brownie points to @obama :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for obama
bitgrower
@bitgrower
Feb 12 2016 05:37
@carpediem1213 -- can you post your code if you haven't already posted it
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:38
Lol @dcnr.
Norman Dela Cruz
@dcnr
Feb 12 2016 05:38
@brainyfarm quick the username is available! lol
bitgrower
@bitgrower
Feb 12 2016 05:38
LOL ... wonder if they'll let me change my name to FeelTheBern ... :)
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:38
cbot, I called the number you gave me three times.
CamperBot
@camperbot
Feb 12 2016 05:38
you called?
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:38
Yes, I did.
Norman Dela Cruz
@dcnr
Feb 12 2016 05:38
@bitgrower you could start by changing your avatar :D
Otman Bouchari
@obouchari
Feb 12 2016 05:38
@CamMakoJ you are iterating through contacts than if you don't find the match first time it will return and doesn't bother checking the rest
bitgrower
@bitgrower
Feb 12 2016 05:39
hahahahahahaha...
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:39
He would soon be out @dcnr :P
bitgrower
@bitgrower
Feb 12 2016 05:39
@dcnr -- basic problem solving skills ... can you analogize the problem you are trying to solve to something you know how to do ...
Norman Dela Cruz
@dcnr
Feb 12 2016 05:39
camperbot stop camping :(
bitgrower
@bitgrower
Feb 12 2016 05:40
if Hilary, Bernie or Trump are elected, I'll see something I never thought I'd see again in my life -- a president who is older than me ...
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:40
What?
Jason
@carpediem1213
Feb 12 2016 05:40
  if (target == 1) {
  str = str.substr( str.length - 1 ); 
  }
  else {
  str = str.substr( str.length - 2, str.length - 1);
  }

  return (str == target);
This is how I've been approaching the problem
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:41
You must be a senior @bitgrower.
E
@efhjones
Feb 12 2016 05:41
Hey guys, can you tell me if I'm on the right track for the challenge Record Collection? Am I right to use these for and if statements?
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) {

  for (id in collection){

    if (value !== "" && prop !== "tracks"){

    prop = update.prop = "";

    }

    else if (prop == "tracks" && value !== ""){
      tracks.push(value);
    }

    else if (value === ""){

      delete.collection.prop;
    }

  }

  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
bitgrower
@bitgrower
Feb 12 2016 05:41

okay ... I gotta go look at the problem desc ...

@brainyfarm -- I am indeed ...

Norman Dela Cruz
@dcnr
Feb 12 2016 05:41

@bitgrower I guess this applies to me

If you can't explain it simply you don't understand it well enough

bitgrower
@bitgrower
Feb 12 2016 05:41
hahahahahahaha ... "see one, do one, show one"
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:42
You are doing something wrong after your conditions @efhjones.
@efhjones, update is your function name.
Jason
@carpediem1213
Feb 12 2016 05:44
@efhjones try using obj.hasOwnProperty(prop) to see if the prop is part of the object
bitgrower
@bitgrower
Feb 12 2016 05:44
aha I guess I did put the one solution in for confirm the ending I mentioned ... I have 3 solutions in my solution file ... :) 2 don't require a for loop ...
1 uses a for loop
2nd one uses subsr
3rd uses the mysterious function I alluded to ...
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:45
You could used a one liner @bitgrower :P
Otman Bouchari
@obouchari
Feb 12 2016 05:46
@bitgrower and another one uses lastIndexOf and some lengths
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:46
return str.endsWith(target) @bitgrower.
bitgrower
@bitgrower
Feb 12 2016 05:47
@brainyfarm -- 3rd one is a one liner ... 2nd could be as well, esp if I wanted to shortened my if statement with a ternary operator ...
@brainfarm -- yes I know ... that's the 3rd solution ...
Jason
@carpediem1213
Feb 12 2016 05:47
@efhjones disregard what I said about hasOwnProperty. You will want to get to the prop using a multidimensional array
is endsWith a thing?
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:47
ES6 @carpediem1213.
bitgrower
@bitgrower
Feb 12 2016 05:47
I was actually trying to inspire @carpediem1213 to go searching the docs and find that function ...
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:48
Is @carpediem1213 working on it?
Jason
@carpediem1213
Feb 12 2016 05:48
@brainyfarm I do not know what ES6 is, but that worked to solve my problem. Too easy though... I'll need to try substr
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:48
Lol
Jason
@carpediem1213
Feb 12 2016 05:48
@brainyfarm I laughed out loud though!
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:48
I wanted to tell you not to use it @carpediem1213.
Jason
@carpediem1213
Feb 12 2016 05:49
been working on this for a few hrs and there you have a 5 word solution
bitgrower
@bitgrower
Feb 12 2016 05:49
yeah, you will be vastly edumucated by figuring it out using substr, @carpediem1213
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:49
I ruined the show @bitgrower :P
bitgrower
@bitgrower
Feb 12 2016 05:50
hahahahahaha ... these rooms get contaminated easily ...
Jason
@carpediem1213
Feb 12 2016 05:50
thanks for the laugh!
@brainyfarm thanks
CamperBot
@camperbot
Feb 12 2016 05:50
carpediem1213 sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1409 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:50
It might not work universally @carpediem1213 and ES6 means EcmaScript6.
Thanks @bitgrower.
CamperBot
@camperbot
Feb 12 2016 05:51
brainyfarm sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 473 | @bitgrower | http://www.freecodecamp.com/bitgrower
Jason
@carpediem1213
Feb 12 2016 05:51
@bitgrower what i've been trying to do is return (this.substr(length) === this.substr(length) but at least one test fails
bitgrower
@bitgrower
Feb 12 2016 05:51
yeah ... true what @brainyfarm says -- if you are doing web dev -- the whole world is not on the same version you are ...
@carpediem1213 -- I was just about to say ... I think I'm going to put a quote up which is ... "it's addressing ... it's ALL about the addressing ... "
so --- break down why that one test fails, @carpediem1213 ...
E
@efhjones
Feb 12 2016 05:52
@brainyfarm something more like this?
function update(id, prop, value) {


    if (value !== "" && prop !== "tracks"){

    collection.id = prop;


    }
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:52
Almost @efhjones.
Condition is good, now remember, you set value as value of prop @efhjones.
bitgrower
@bitgrower
Feb 12 2016 05:53
or, more literally, @carpediem1213 -- how do you count backward from the end of a string (or an array, for that matter)
Immad Hamid
@immad-hamid
Feb 12 2016 05:54
Can anyone here please help me out with how to access nested arrays in JSON
@bitgrower
Jason
@carpediem1213
Feb 12 2016 05:55
@bitgrower I had an epiphany. Am I on the right track here? str = str.substr(str.length - target.length, target.length);
E
@efhjones
Feb 12 2016 05:55
Did the Javascript section take way longer than 10 hours for anyone else? :laughing:
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:55
@efhjones :laughing:
Jason
@carpediem1213
Feb 12 2016 05:55
@bitgrower That was IT! return str === target. Done!
Immad Hamid
@immad-hamid
Feb 12 2016 05:55
@efhjones yea for me, its the third day.
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:56
The new curriculum has stuff harder than some problems from the algorithm section @efhjones.
bitgrower
@bitgrower
Feb 12 2016 05:56
hey, that's cool, @carpediem1213 -- I think you've just added to my managery ...
Jason
@carpediem1213
Feb 12 2016 05:56
```js
str = str.substr(str.length - target.length, target.length);
return (str === target);
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:56
What is your issue @immad-hamid?
Jason
@carpediem1213
Feb 12 2016 05:56
two lines instead of one @brainyfarm @brainyfarm thanks!!!!
CamperBot
@camperbot
Feb 12 2016 05:56
carpediem1213 sends brownie points to @brainyfarm and @brainyfarm :sparkles: :thumbsup: :sparkles:
:warning: carpediem1213 already gave brainyfarm points
:warning: carpediem1213 already gave brainyfarm points
bitgrower
@bitgrower
Feb 12 2016 05:56
@brainyfarm -- if we started previously are we on the old curriculum and don't see the new curriculum ?
Immad Hamid
@immad-hamid
Feb 12 2016 05:58
@carpediem1213 this is what I am doing in order to access the second list second item.
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

var secondTree = myPlants["list"].list[1]; /* This is what I have done */
bitgrower
@bitgrower
Feb 12 2016 05:58
I don't recall ... and everyone comes from different places, @efhjones -- so I wouldn't worry too much about how time something takes ... worry more about how well you learn it ...
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:58
This is the new curriculum @bitgrower, when I joined in October, the Javascript section was much more easier than the January update.
Jason
@carpediem1213
Feb 12 2016 05:58
function end(str, target) {
   str = str.substr(str.length - target.length, target.length);
  return (str === target);
}
E
@efhjones
Feb 12 2016 05:58
@immad-hamid high five! :hand:
bitgrower
@bitgrower
Feb 12 2016 05:58
you CAN do it easier @carpedium -- using substr ...
Abhishek Kumar
@abhishekKumar1
Feb 12 2016 05:58
@immad-hamid try var secondTree=myPlants1.list1
bitgrower
@bitgrower
Feb 12 2016 05:59
think about addressing backwards ..
Jason
@carpediem1213
Feb 12 2016 05:59
@bitgrower don't rain on my celebration lol
bitgrower
@bitgrower
Feb 12 2016 05:59
ahhh ... sorry ... !!!!!
Jason
@carpediem1213
Feb 12 2016 05:59
haha!
bitgrower
@bitgrower
Feb 12 2016 05:59
congrats @carpediem1213 ...
Jason
@carpediem1213
Feb 12 2016 05:59
okay now that I've completed the puzzle, how can I do it do easier with substr?
Olawale Akinseye
@brainyfarm
Feb 12 2016 05:59
Nice and good job @carpediem1213, now I pay you my tax :P
CamperBot
@camperbot
Feb 12 2016 05:59
brainyfarm sends brownie points to @carpediem1213 :sparkles: :thumbsup: :sparkles:
:star: 265 | @carpediem1213 | http://www.freecodecamp.com/carpediem1213
bitgrower
@bitgrower
Feb 12 2016 06:00
so think about it ... ...
if I have hearth and I want to see if earth is there, where would earth HAVE to start ...
Danny136200
@Danny136200
Feb 12 2016 06:00

Hello 'var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.

var newArray =oldArray.filter(function(val){
return val > 5;
});
'

bitgrower
@bitgrower
Feb 12 2016 06:01
and then what is that in relationship to the length of both strings ?
Danny136200
@Danny136200
Feb 12 2016 06:01
I am having trouble figuring out why I am not passing this challenge
Olawale Akinseye
@brainyfarm
Feb 12 2016 06:01
@Danny136200, could you copy your code as pretty code and paste again?
Danny136200
@Danny136200
Feb 12 2016 06:01
It tells me to filter all numbers that are greater than 5 from the old array to the new one/
Abhishek Kumar
@abhishekKumar1
Feb 12 2016 06:01
it should be return val<=5
Danny136200
@Danny136200
Feb 12 2016 06:01
@brainyfarm how do you do that?
Olawale Akinseye
@brainyfarm
Feb 12 2016 06:01
Explain format
CamperBot
@camperbot
Feb 12 2016 06:01

: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

ichirped
@ichirped
Feb 12 2016 06:02
does javascript have a range function like : range(hi, lo) that returns an array of that range ?
Immad Hamid
@immad-hamid
Feb 12 2016 06:02

@efhjones haha high five... :smile:

@abhishekKumar1 Thanks man, I should have thought that one need to access the objects like the arrays using indexes.

CamperBot
@camperbot
Feb 12 2016 06:02
immad-hamid sends brownie points to @efhjones and @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
:star: 327 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
:star: 227 | @efhjones | http://www.freecodecamp.com/efhjones
bitgrower
@bitgrower
Feb 12 2016 06:02
@abhishekKumar1 -- you ever gonna let people struggle for an answer ?
SuhasHosamani
@SuhasHosamani
Feb 12 2016 06:02
var Car = function() {
  // this is a private variable
  var speed = 10;

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

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

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

var Bike = function() {
var gear ;
  // Only change code below this line.
  this.setGear = function(gear) {
    gear = gear;
  };

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

var myCar = new Car();

var myBike = new Bike();
myBike.setGear(3);
myBike.getGear();
Hi everyone, Whats is wrong with this code?
Abhishek Kumar
@abhishekKumar1
Feb 12 2016 06:02
@bitgrower sorry :worried:
Danny136200
@Danny136200
Feb 12 2016 06:03
Thanks @brainyfarm and @abhishekKumar1 !
CamperBot
@camperbot
Feb 12 2016 06:03
danny136200 sends brownie points to @brainyfarm and @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
Immad Hamid
@immad-hamid
Feb 12 2016 06:03
@abhishekKumar1 but you should not have directly tell me the answer. btw thanks
CamperBot
@camperbot
Feb 12 2016 06:03
immad-hamid sends brownie points to @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
Jason
@carpediem1213
Feb 12 2016 06:03
@bitgrower I'm not quite sure of the relationship. You'd have to start at index 1 to find earth.
CamperBot
@camperbot
Feb 12 2016 06:03
:warning: immad-hamid already gave abhishekkumar1 points
:star: 1410 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
:star: 328 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
bitgrower
@bitgrower
Feb 12 2016 06:03
@SuhasHosamani -- which challenge is that ?
okay ... is there some mathematical relationship between the length of the two strings which would give you that number @carpediem1213 ?
Jason
@carpediem1213
Feb 12 2016 06:04
-1
Olawale Akinseye
@brainyfarm
Feb 12 2016 06:05
You are good @bitgrower :D
SuhasHosamani
@SuhasHosamani
Feb 12 2016 06:05
@bitgrower Make Object Properties Private
bitgrower
@bitgrower
Feb 12 2016 06:05
I have a string of length 6 and a string of length 5 -- how can I use those numbers to get 1 ?
Jason
@carpediem1213
Feb 12 2016 06:05
oh that's a good idea
bitgrower
@bitgrower
Feb 12 2016 06:06
now ... how can you use that with substr to solve that challenge ?
Jason
@carpediem1213
Feb 12 2016 06:06
so the target can be subtracted from the string?