These are chat archives for FreeCodeCamp/HelpJavaScript

15th
Mar 2016
Amy
@AJMorrisClark
Mar 15 2016 00:02

@eeflores I got that part, but I'm not sure about how to modify the test line. Here's the code: function queue(arr, item) {

arr.push(item);
var removed = arr.shift();
return removed;
}

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

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

Where it says "modify this line to test"
eeflores
@eeflores
Mar 15 2016 00:03
@AJMorrisClark you shouldn't need to modify that line to pass the challenge
Amy
@AJMorrisClark
Mar 15 2016 00:03
oh
eeflores
@eeflores
Mar 15 2016 00:03
@AJMorrisClark except that on that line, item is undefined ... maybe change item to a number?
Amy
@AJMorrisClark
Mar 15 2016 00:04
ok
oh wow, that did it. Thanks!!!!!
eeflores
@eeflores
Mar 15 2016 00:04
yw
Henry Quinn
@Quinncuatro
Mar 15 2016 00:04
help seek
CamperBot
@camperbot
Mar 15 2016 00:04

:point_right: algorithm seek and destroy [wiki]

Explanation:

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

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

Andrew Charlebois
@andrewchar
Mar 15 2016 00:05
oh man.. Where art thou algorithm is a pain in my butt
Maddah Anass
@unlimiworks
Mar 15 2016 00:09
@andrewchar With enough time thinking and iterating, you'll get it :)
Andrew Vanboxel
@avanbox
Mar 15 2016 00:21
hey guys. quick question. Im working on the weather app, and changing my backgrounds with jquery. how would I adjust the position, size repeat etc of the image? Heres my code
```
$("body").css("background-image","url('https://upload.wikimedia.org/wikipedia/commons/a/a4/Cloud_to_ground_lightning_strikes_south-west_of_Wagga_Wagga.jpg')");
oops
 $("body").css("background-image","url('https://upload.wikimedia.org/wikipedia/commons/a/a4/Cloud_to_ground_lightning_strikes_south-west_of_Wagga_Wagga.jpg')");
Andrew Charlebois
@andrewchar
Mar 15 2016 00:23
@avanbox to make it a full cover background image you mean?
Andrew Vanboxel
@avanbox
Mar 15 2016 00:24
yeah. the jquery will overwrite my .csss
-s
Leslie Covington
@LesCov610
Mar 15 2016 00:25
Thank you, @Blauelf ! I appreciate your taking the time to explain how you do things. Maybe I need to re-write it and see if I can make something work myself before I give in.
CamperBot
@camperbot
Mar 15 2016 00:25
lescov610 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1415 | @blauelf | http://www.freecodecamp.com/blauelf
Andrew Charlebois
@andrewchar
Mar 15 2016 00:27
can try adding no-repeat center center fixed; @avanbox
Andrew Vanboxel
@avanbox
Mar 15 2016 00:27
yeah but where would i add it?
Andrew Charlebois
@andrewchar
Mar 15 2016 00:28
right after the closing paren of your img
Andrew Vanboxel
@avanbox
Mar 15 2016 00:28
after this? jpg')
Andrew Charlebois
@andrewchar
Mar 15 2016 00:29
 $("body").css("background-image","url('https://upload.wikimedia.org/wikipedia/commons/a/a4/Cloud_to_ground_lightning_strikes_south-west_of_Wagga_Wagga.jpg')no-repeat center center fixed");
Andrew Vanboxel
@avanbox
Mar 15 2016 00:29
thanks @andrewchar andrew
CamperBot
@camperbot
Mar 15 2016 00:29
avanbox sends brownie points to @andrewchar :sparkles: :thumbsup: :sparkles:
:star: 351 | @andrewchar | http://www.freecodecamp.com/andrewchar
Andrew Charlebois
@andrewchar
Mar 15 2016 00:30
@avanbox im not sure if that will work or not for how your doing it but thats how i style it in my css sheet
@avanbox i missed something. i add background-size: cover; to my body aswell for a background image
samamsam
@samsamam
Mar 15 2016 00:31
@ArielLeslie thanks anyway only the quotation is not showing but it gives the right output
CamperBot
@camperbot
Mar 15 2016 00:31
samsamam sends brownie points to @arielleslie :sparkles: :thumbsup: :sparkles:
:star: 1256 | @arielleslie | http://www.freecodecamp.com/arielleslie
pgjones72
@pgjones72
Mar 15 2016 00:36
hey guys. Anyone about to help me with this function?

function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty(checkObj)){
return checkObj;
}

return "Not Found";
}

samamsam
@samsamam
Mar 15 2016 00:37
hi coders is there a bug in this code it gives the right output
var count = 0;

function cc(card) {
  // Only change code below this line
  if(card == 2 || card == 3 || card == 4 || card == 5 || card == 6 )
    {
      count = count + 1;


    }
  if(card == 7 || card == 8 || card == 9)
    {

    }
  if(card == 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A')
    {
      count = count - 1;

    }
  if(count > 0)
    {
      return(count + '\t' + "Bet");
    }
  else if(count <= 0)
    {
      return("Bet" +'\t' + "Hold");
    }
  // Only change code above this line
}


// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Caleb Fringer
@40OztoFreedom
Mar 15 2016 00:39
samsamam- try doing that as a switch, it will work much more easily
pgjones72
@pgjones72
Mar 15 2016 00:39
i think the goal of the exercise was to use switch
Caleb Fringer
@40OztoFreedom
Mar 15 2016 00:42
how do you send a picture of your code
Kia Farhang
@KiaFarhang
Mar 15 2016 00:43
Hey @pgjones72 - try changing that if statement to have an === true and an explicit else. Don't know if that will help, but worth a shot.
@40OztoFreedom - use three of these then hit shift enter, type code. Then when you're done, another shift enter, end with three more
Dammit.
Use three of the other characters on the ~ key.
Caleb Fringer
@40OztoFreedom
Mar 15 2016 00:44
function destroyer(arr) {
function exterminate(x) {
for (i = 1; i < arguments.length; i++) {
if (x !== arguments[i]) {
return false;
}
}
return true;
}
var newArr = arr.filter(exterminate);
return newArr;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Andrew Charlebois
@andrewchar
Mar 15 2016 00:44
help format
CamperBot
@camperbot
Mar 15 2016 00:44

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

bitgrower
@bitgrower
Mar 15 2016 00:45
hmmm ... you need to re-read what array.filter does @40OztoFreedom
...and how it does it ...
you are also going to run into problems because the arguments object gets completely re-defined when you open a new scope ... and your current attempt would include the new scope opened in your .filter call, along with the new scope that would be opened in the exterminate function ...
Caleb Fringer
@40OztoFreedom
Mar 15 2016 00:48
the scope part makes a lot of sense- whats wrong with the way im using .filter?
pgjones72
@pgjones72
Mar 15 2016 00:48
@KiaFarhang thanks I'll try that
CamperBot
@camperbot
Mar 15 2016 00:48
pgjones72 sends brownie points to @kiafarhang :sparkles: :thumbsup: :sparkles:
:star: 238 | @kiafarhang | http://www.freecodecamp.com/kiafarhang
bitgrower
@bitgrower
Mar 15 2016 00:52
@40OztoFreedom -- you're right ... sorry -- so used to seeing a callback function call as an IIFE ...
pgjones72
@pgjones72
Mar 15 2016 00:52

```js
function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty(checkObj)){
return checkObj;
}

return "Not Found";
}

Caleb Fringer
@40OztoFreedom
Mar 15 2016 00:52
nevermind! i figured it out lol- i had it as !== when i need it as ==
thanks a ton, the scope part was right on @bitgrower
CamperBot
@camperbot
Mar 15 2016 00:53
40oztofreedom sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 857 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 15 2016 00:53
yeah ... not an uncommon problem with that challenge ... :)
pgjones72
@pgjones72
Mar 15 2016 00:56
gah. aside from my obvious formatting issues, my quest for help is still on.
bitgrower
@bitgrower
Mar 15 2016 00:56

now ... we just need to initiate you into getting your code "colorized" ... :) ... it's easy ... just 3 steps...

  1. create a line with ```js on it, by itself
  2. paste your code in
  3. if the editor hasn't added a line with ``` on a line by itself "after" your code ... then do that
  4. optional: if your chat window is no longer in chat mode, (a little keyboard shows up on the upper right when it's not, and "chat" balloons when it is) ... click on the keybooard

oh yeah, now, click enter ... :)

^^^ above was for @40OztoFreedom -- but can be used freely by anyone (highly encouraged)
Moisés Man
@moigithub
Mar 15 2016 00:57
@pgjones72 ur checkObj function need to check if ur object have the property u passsing through checkProp and return the value of that object /property
bitgrower
@bitgrower
Mar 15 2016 00:57
your formatting isn't far off, @pgjones72 -- just edit your message and add the ``` line
pgjones72
@pgjones72
Mar 15 2016 00:58
function checkObj(checkProp) {
  // Your Code Here
  if(myObj.hasOwnProperty(checkObj)){
    return checkObj;
}

  return "Not Found";
}
sweet!
samamsam
@samsamam
Mar 15 2016 00:59
@40OztoFreedom tried it still gets results but does not get a tick
var count = 0;

function cc(card) {
  // Only change code below this line
  switch(true)
    {
      case card == 2:
      case card == 3:
      case card == 4:
      case card == 5:
      case card == 6:
        count = count + 1;
        break;

      case card == 7:
      case card == 8:
      case card == 9:
        break;

      case card == 10:
      case card == 'J':
      case card == 'Q':
      case card == 'K':
      case card == 'A':
        count = count + 1;
        break;
    }

  if(count > 0)
    {
      return(count + '\t' + "Bet");
    }
  else if(count <= 0)
    {
      return("Bet" +'\t' + "Hold");
    }
  // Only change code above this line
}


// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
bitgrower
@bitgrower
Mar 15 2016 00:59
don't use tab, @samsamam ...
pgjones72
@pgjones72
Mar 15 2016 00:59
spaces @samsamam
" bet"
bitgrower
@bitgrower
Mar 15 2016 01:00
...and you don't need to put parens around the expression on your return statement
bitgrower @bitgrower 's eyes thank @pgjones72 & @samsamam -- thanks for getting the syntax coloring :) makes it MUCH easier
CamperBot
@camperbot
Mar 15 2016 01:01
bitgrower sends brownie points to @pgjones72 and @samsamam :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for samsamam
:star: 218 | @pgjones72 | http://www.freecodecamp.com/pgjones72
pgjones72
@pgjones72
Mar 15 2016 01:02
@bitgrower LOL
bitgrower
@bitgrower
Mar 15 2016 01:02
@samsamam -- you need to hook up your FCC/github/gitter links in order to be given brownie points ...
samamsam
@samsamam
Mar 15 2016 01:02
@bitgrower no worries :)
bitgrower
@bitgrower
Mar 15 2016 01:03
k ... well, just fyi -- I only help people who have all that hooked up ... :)
Andrew Charlebois
@andrewchar
Mar 15 2016 01:03
lol
samamsam
@samsamam
Mar 15 2016 01:03
@pgjones72 @40OztoFreedom thanks works now
CamperBot
@camperbot
Mar 15 2016 01:03
samsamam sends brownie points to @pgjones72 and @40oztofreedom :sparkles: :thumbsup: :sparkles:
:star: 273 | @40oztofreedom | http://www.freecodecamp.com/40oztofreedom
:star: 219 | @pgjones72 | http://www.freecodecamp.com/pgjones72
bitgrower
@bitgrower
Mar 15 2016 01:05
hey @andrewchar -- is my help worth it ? :) :) :)
Andrew Charlebois
@andrewchar
Mar 15 2016 01:06
@bitgrower absolutely
bitgrower
@bitgrower
Mar 15 2016 01:06
:)
Andrew Charlebois
@andrewchar
Mar 15 2016 01:06
got me out of a few "i dont know wth i am doing" situations
im having one right now and trying hard not to ask for help lol
bitgrower
@bitgrower
Mar 15 2016 01:08
good for you ... just ask -- you know me ... I try to just give you pushes in the right direction, not solutions ... :)
Andrew Charlebois
@andrewchar
Mar 15 2016 01:08
working on the Where art thou algorithm
bitgrower
@bitgrower
Mar 15 2016 01:08
which one are you working on ?
Andrew Charlebois
@andrewchar
Mar 15 2016 01:08
apparently my working with objects knowledge is weak
bitgrower
@bitgrower
Mar 15 2016 01:08
ahhh ...
pgjones72
@pgjones72
Mar 15 2016 01:08
@andrewchar mine too
bitgrower
@bitgrower
Mar 15 2016 01:08
you're far from alone ...
pgjones72
@pgjones72
Mar 15 2016 01:11
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");
Andrew Charlebois
@andrewchar
Mar 15 2016 01:11
i feel like there is a lot to learn to get this one done
pgjones72
@pgjones72
Mar 15 2016 01:11
my function still needs help
i'm trying to isolate whether or not the value passed to checkObj exists
bitgrower
@bitgrower
Mar 15 2016 01:12
so ... objects are complicated by having some interesting aspects to them ...
  1. you can address properties in two ways...knowing when to use which can be tricky
  2. one of those ways looks a LOT like how you index into arrays
  3. the "properties" (aka "keys") can, themselves contain even MORE properties (keys), which makes addressing tricky
  4. to "address" a particular piece of data in an object requires creating a "path" (address) to the data -- which is made up of using the properties of the object at the first level ... and subsequently properties deeper in the object and/or a numeric index -- if the value you seek is in an array ...
so your code is not passing, @pgjones72 ? which challenge is it ?
pgjones72
@pgjones72
Mar 15 2016 01:14
Testing Objects for Properties
Andrew Charlebois
@andrewchar
Mar 15 2016 01:16
@bitgrower enumerable properties?
@bitgrower is that what your saying is sorta the way you index arrays
Object.keys
bitgrower
@bitgrower
Mar 15 2016 01:17
@pgjones72 -- (don't kick yourself) -- you need to check the parameter ... look more closely at what you are trying to check ...
pgjones72
@pgjones72
Mar 15 2016 01:17
@andrewchar yeah. If you know the key is in the Object, you can access it's value
Andrew Charlebois
@andrewchar
Mar 15 2016 01:18
im trying to think how do i make a comparison if hasownproperty gives me a boolean and keys gives me numbers
Geo Galagaran
@geeofree
Mar 15 2016 01:18
hey guys. Can I get some help on the Title-Case-A-Sentence challenge?
bitgrower
@bitgrower
Mar 15 2016 01:18
you use keys to iterate thru the object's properties ... so it gives you an array of ALL the object's properties ...
possibly, @da7thsin ... can you post your code ? :point_up: March 14, 2016 5:56 PM
Geo Galagaran
@geeofree
Mar 15 2016 01:20
I only have this for now..
function titleCase(str) {
  var wordArray = str.toLowerCase().split(' ');
}

titleCase("I'm a little tea pot");
jw1540
@jw1540
Mar 15 2016 01:20
help Caesars Cipher
CamperBot
@camperbot
Mar 15 2016 01:20

:point_right: algorithm caesars cipher [wiki]

Problem Explanation:

  • You need to write a function, which will take string encoded with
    Caesar cipher as a parameter and decode it.
  • The one used here is ROT13 where the value of the letter is
    shifted by 13 places.
    e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
  • You have to shift it back 13 positions, such that 'N' ↔ 'A'.
:pencil: read more about algorithm caesars cipher on the FCC Wiki
bitgrower
@bitgrower
Mar 15 2016 01:21

so ... if you don't know how to write the js for the challenge, write out what you would do in pseudocode --

you now have an array of words ... now what?

bitgrower @bitgrower 's eyes thank @da7thsin
CamperBot
@camperbot
Mar 15 2016 01:21
bitgrower sends brownie points to @da7thsin :sparkles: :thumbsup: :sparkles:
:star: 258 | @da7thsin | http://www.freecodecamp.com/da7thsin
bitgrower
@bitgrower
Mar 15 2016 01:22
@andrewchar -- if you have the object property from Object.keys, you shouldn't need hasOwnProperty ... :)
@pgjones72 -- you figure out where your code is not working ?
pgjones72
@pgjones72
Mar 15 2016 01:24
not yet. Stand by LOL
got one tick out of three
bitgrower
@bitgrower
Mar 15 2016 01:25
:point_up: March 14, 2016 6:17 PM @pgjones72
what does your code look like now?
pgjones72
@pgjones72
Mar 15 2016 01:26
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");
It's moments like these that caused JS and I to beak up in the first place
bitgrower
@bitgrower
Mar 15 2016 01:29
@pgjones72 -- you've gotten caught up in the difference between using dot notation and brackets ... bracket notation is by far the more general way of addressing ... dot notation is for when you know the actual name of the property you are looking for ...
Geo Galagaran
@geeofree
Mar 15 2016 01:30
@bitgrower this is where I get stuck with.
function titleCase(str) {
  var wordArray = str.toLowerCase().split(' ');
  var upperCased = [];
  for(i = 0; i < wordArray.length; i++){
    upperCased = wordArray[i][0].toUpperCase();
    //push each upperCased elements to wordArray[i]
  }
  //return answer
}

titleCase("I'm a little tea pot");
bitgrower
@bitgrower
Mar 15 2016 01:31
how do you add items to an array , @da7thsin ?
Dustin
@Key-Banger
Mar 15 2016 01:31
Someone help me out with this. Its Diff Two Arrays:
function diff(arr1, arr2) {
var Index =[];
for (var i=0; i<arr1.length; i++) {
    Index = arr2.indexOf(arr1[i]);
    if (Index > -1) {
        arr2.splice(Index, 1);
    }
}
  return arr2;
}

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Geo Galagaran
@geeofree
Mar 15 2016 01:32
@bitgrower okay 1 sec. I thought about something
thank you
@bitgrower thank you!
CamperBot
@camperbot
Mar 15 2016 01:33
da7thsin sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 858 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 15 2016 01:34
I don't quite understand why you are splicing an empty array, @Key-Banger ?
or, at the most, an array with only one element in it ...
devonwilson1
@devonwilson1
Mar 15 2016 01:36
can i get some help with the "shopping list" assignment for java script please
Andrew Charlebois
@andrewchar
Mar 15 2016 01:36
@bitgrower i know in my code i need to change something so it checks for something being the same in only part of the object, instead of how mine is checking, where its checking if the entire object is the same. just unsure how yet.
function where(collection, source) {

  var foo = [];

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

    if (source == collection[i]) {
      foo += collection[i];
    }
  }
  console.log(foo);
}

where([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
devonwilson1
@devonwilson1
Mar 15 2016 01:36
i honestly still am not sure how to start from scratch and create an array or really understand what they mean
bitgrower
@bitgrower
Mar 15 2016 01:36
ahhh ... Where Art Thou ... yeah, that's an intense challenge ... :)
devonwilson1
@devonwilson1
Mar 15 2016 01:36
@mandeepbhutani i am creating the shopping list for java script stuff
bitgrower
@bitgrower
Mar 15 2016 01:37
@devonwilson1 -- what is the name of the FCC challenge ?
devonwilson1
@devonwilson1
Mar 15 2016 01:37
a multideimensional array of a shopping list and its emerassing but i am not sure how to begin
bitgrower
@bitgrower
Mar 15 2016 01:37
is this an FCC challenge, @devonwilson1 ?
devonwilson1
@devonwilson1
Mar 15 2016 01:37
"shopping list"
bitgrower
@bitgrower
Mar 15 2016 01:37
k ... don't remember that one !!! hang on
devonwilson1
@devonwilson1
Mar 15 2016 01:38
thank you!!
Dustin
@Key-Banger
Mar 15 2016 01:39
@bitgrower I don't either. I'm really lost at this point.
pgjones72
@pgjones72
Mar 15 2016 01:39
@bitgrower got it. :)
bitgrower
@bitgrower
Mar 15 2016 01:39
:) congrats, @pgjones72
@Key-Banger -- can you step thru the code and see what's going on with your Index array? I don't even understand it's purpose ...
ahh ... @devonwilson1 -- what have you tried?
devonwilson1
@devonwilson1
Mar 15 2016 01:41
im not even really sure where to start
i first made my list and it looked like this..
bitgrower
@bitgrower
Mar 15 2016 01:41
and, yeah, @andrewchar -- Object.keys() is def something you'll want to use ...
Andrew Charlebois
@andrewchar
Mar 15 2016 01:42
@bitgrower reading the mdn for it again
Joshua Jerrick
@JoshuaJerrick
Mar 15 2016 01:42
I am a little frustrated on the Returning Boolean Values from Functions challenge can someone help me out?
Andrew Charlebois
@andrewchar
Mar 15 2016 01:42
@bitgrower trying to understand it, its the first time i see this object.keys() thing
Joshua Jerrick
@JoshuaJerrick
Mar 15 2016 01:42

'''
function isLess(a, b) {
// Fix this code
switch(a, b){
case a < b:
isLess(false);
break;
default:
return true;
}
}

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

CamperBot
@camperbot
Mar 15 2016 01:42
:bulb: to format code use backticks! ``` more info
bitgrower
@bitgrower
Mar 15 2016 01:43
@Key-Banger -- write it out in English -- (pseudocode) -- don't try and figure it out in js first .. just figure out what needs to happen ... (it's a bit of a tricky problem -- there's a trickier version in the adv algos)
Andrew Charlebois
@andrewchar
Mar 15 2016 01:43
@JoshuaJerrick backticks not quotation marks
@JoshuaJerrick key to the left of your number 1 key
devonwilson1
@devonwilson1
Mar 15 2016 01:43
var myList = [
["chia", 2];
["granola", 10];
["yogurt", 10];
["strawberry", 8];
["milk", 2];
];
bitgrower
@bitgrower
Mar 15 2016 01:43
@JoshuaJerrick -- what @andrewchar said ... copy & paste these: ```
devonwilson1
@devonwilson1
Mar 15 2016 01:43
thats my start lol @bitgrower
bitgrower
@bitgrower
Mar 15 2016 01:44
so ... the problem I think is that you are trying to define the array literally ... but they want you to do it in code ...
so ... if I gave you ["chocolate bars", 10] how would you add it to your array ... using js
devonwilson1
@devonwilson1
Mar 15 2016 01:45
var myList = ???
not exactly sure
bitgrower
@bitgrower
Mar 15 2016 01:45
@andrewchar -- what Object.keys does is give you an array of all the properties of the object you're looking at ... which then makes it easy to iterate thru all the properties ...
hang on ... let me look at what you've been exposed to up until now, @devonwilson1
Joshua Jerrick
@JoshuaJerrick
Mar 15 2016 01:46
function isLess(a, b) {
// Fix this code
switch(a, b){
case a < b:
isLess(false);
break;
default:
return true;
}
}
// Change these values to test
isLess(10, 15);
That is my current code
devonwilson1
@devonwilson1
Mar 15 2016 01:47
oh wow i just finished it lol
i guessed and tried and finished it wow
bitgrower
@bitgrower
Mar 15 2016 01:47
hahahahahaha ... congrats!!!
devonwilson1
@devonwilson1
Mar 15 2016 01:47
much more simple than i though
hahahah
bitgrower
@bitgrower
Mar 15 2016 01:47
I was just gonna say, you had some exercises just prior that should have left some clues ...
devonwilson1
@devonwilson1
Mar 15 2016 01:47
i just wore that list with the [] with the right spaces and commas
wrote*
and inside brackets thank you @bitgrower
CamperBot
@camperbot
Mar 15 2016 01:48
devonwilson1 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 859 | @bitgrower | http://www.freecodecamp.com/bitgrower
devonwilson1
@devonwilson1
Mar 15 2016 01:48
thats so funny it was so much simpler than i thought
bitgrower
@bitgrower
Mar 15 2016 01:48
hmmm ... well ... how would you do it with js code, @devonwilson1 ...
look at the challenges you've done just prior
Joshua Jerrick
@JoshuaJerrick
Mar 15 2016 01:49
Alright I got to get off thanks for helping me guys
bitgrower
@bitgrower
Mar 15 2016 01:50
okay ... sorry I didn't get in there soon enuf, @JoshuaJerrick
@devonwilson1 -- hook up your FCC/github & gitter accounts ... :)
Andrew Charlebois
@andrewchar
Mar 15 2016 01:51
@bitgrower i really dont need to use hasOwnProperty for this?
bitgrower
@bitgrower
Mar 15 2016 01:59
yes, hasOwnProperty makes sense for this ...
pgjones72
@pgjones72
Mar 15 2016 02:12
I have a hypothetical question as I begin to see the usefulness of objects- is it possible to write a function that takes user input (like a form), and store the information in a nested object (alphabetically )? The important part would be creating the nested object automatically after a submit button.
bitgrower
@bitgrower
Mar 15 2016 02:15
well, I think you come up against the persistence of the object -- at which point you'd probably want to use json to store it in a database (which is far more persistant)
...otherwise you'd have the object sitting around cluttering up memory ...
pgjones72
@pgjones72
Mar 15 2016 02:16
ok. I'll wait until we get to databases. I figured that storage would become an issue with a function like that. thanks @bitgrower
CamperBot
@camperbot
Mar 15 2016 02:16
pgjones72 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 860 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 15 2016 02:17
yw -- databases are in the backend challenges ...
pgjones72
@pgjones72
Mar 15 2016 02:17
@bitgrower ok fine. I'll keep working
@pgjones72 sticks tongue out @bitgrower
bitgrower
@bitgrower
Mar 15 2016 02:18
:)
I think there's an emoticon for that ...
pgjones72
@pgjones72
Mar 15 2016 02:19
@bitgrower no time. too much work to get done in too little time
bitgrower
@bitgrower
Mar 15 2016 02:20
hahahaha I know how you feel !
Greg D
@mosaic-greg
Mar 15 2016 02:22
Where do I belong challenge: three out of seven tests passed :)
Geo Galagaran
@geeofree
Mar 15 2016 02:25
is there an alternative to .slice that removes the selected index of an array?

I have this

function titleCase(str) {
  var wordArray = str.toLowerCase().split(' ');
  var upperCased = wordArray.map(function(val){
     return val[0].toUpperCase().concat(val).slice(1, 2);
  });
  return upperCased;
}

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

But its taking the unneeded letters.. :/

Davide
@DavOnGit
Mar 15 2016 02:26
@da7thsin splice()
bitgrower
@bitgrower
Mar 15 2016 02:32
@da7thsin -- you might want to comment your code -- it's not obvious to me what you are trying to do .. and it hurts my head a bit trying to figure it out ... if I know what you are trying to do, I will have a better idea of whether your code does what you want ... or help you find the code that will ...
Geo Galagaran
@geeofree
Mar 15 2016 02:40
@bitgrower
function titleCase(str) {
  var wordArray = str.toLowerCase().split(' '); //change string to lower cased and split into array
  var upperCased = wordArray.map(function(val){
     return val[0].toUpperCase().concat(val);
  });
  return upperCased; //returns ["Ii'm", "Aa", "Llittle", "Ttea", "Ppot"]

}

titleCase("I'm a little tea pot");
which is why I'm trying to remove the 2nd letter from each index.
bitgrower
@bitgrower
Mar 15 2016 02:42
so what is val ?
give me an example value of val, as it comes into your map function ?
do that, and I'll step you thru what's going on ...
(incidentally, the code I was having trouble understanding was your return statement) ...
...but I'm good now ... I see what you are trying to do, and I know why it's giving you the results you are getting ...
Geo Galagaran
@geeofree
Mar 15 2016 02:46
actually. I really don't know how I did it. I just checked back to the iterate over Arrays challenge thinking that I should add every first index thats uppercased from the wordArray
bitgrower
@bitgrower
Mar 15 2016 02:47
cool ... but can you give me a value for your wordArray ?
okay ... let's take little ...
what you are doing is looking at the first character of little, l, and making it upper case ... it's just an upper case letter out there in space ... it's not assigned to anything yet
then you are taking "little" ... and basically doing this: "L"+"little"

so, you actually just want to return "L" + "ittle" ...

this WOULD BE a great place to use str..slice ...

slice is convenient, in that you give it the begin and end ... if you don't give it the end, it just goes from whichever point you indicate, and collects the rest of the string ...
so "little".slice(1) ---> "ittle"
Geo Galagaran
@geeofree
Mar 15 2016 02:55
okay I think I get it now. I'll try and do something. Thank you again!
@bitgrower this did the trick. Thank you!!!!!
function titleCase(str) {
  var wordArray = str.toLowerCase().split(' ');
  var upperCased = wordArray.map(function(val){
     var firstLetter = val.slice(1);
     var restOfWord = val[0].toUpperCase().concat(firstLetter);
     return restOfWord;
  });
  return upperCased.join(' ');
}

titleCase("I'm a little tea pot");
CamperBot
@camperbot
Mar 15 2016 02:58
da7thsin sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 861 | @bitgrower | http://www.freecodecamp.com/bitgrower
Vladimir Logachev
@VladimirLogachev
Mar 15 2016 03:00

Hello campers! That's how i'm trying to solve Chunk Monkey
and this code doesn't work. Can anyone help me to find an error?

```
function chunk(arr, size) {
  var arr2 = [], arr3 = []; //temporary for loop
  for (var i = 0; i < arr.length; i+=size) {
    if (size === arr3.push(arr[i])) { //push should return length
      arr2.push(arr3); 
      arr3 = [];
    }
  }
  if (arr3.length > 0) arr2.push(arr3); //final flush
  console.log(arr2);
  return arr2;
}
chunk(["a", "b", "c", "e"], 2);

//non-slice metod
//maybe I misunderstood slice()

```

bitgrower @bitgrower is honestly a bit perplexed as to how @da7thsin 's code works ...
pgjones72
@pgjones72
Mar 15 2016 03:01
var secondTree = ""; // Change this line
bitgrower
@bitgrower
Mar 15 2016 03:02
ahhh ... I see, the variable name "firstLetter" threw me off ...
Rex Schrader
@SaintPeter
Mar 15 2016 03:02
@vl-doit You're skipping some elements. You're incrementing i by size, but you're only "pushing" one element at a time.
@vl-doit Otherwise your logic is sound.
pgjones72
@pgjones72
Mar 15 2016 03:03
I'm having trouble here. I think it should be myPlants.trees[1] in order to access the second nested objects second item. Am i wrong? why?
and why are there quotations when there were none in the exmples? Are they trying to trick me?
Rex Schrader
@SaintPeter
Mar 15 2016 03:05
@pgjones72 No one is trying to trick you ;)
@pgjones72 Take a look at what myPlants is. Is it an object or an array?
@pgjones72 At the topmost level
pgjones72
@pgjones72
Mar 15 2016 03:05
@SaintPeter an array
Rex Schrader
@SaintPeter
Mar 15 2016 03:05
@pgjones72 So how do you access an element of an array?
pgjones72
@pgjones72
Mar 15 2016 03:06
please hold. :)
SaintPeter @SaintPeter hums the muzac version of "The Girl From Ipa Nima"
pgjones72
@pgjones72
Mar 15 2016 03:09
myPlants1 doesn't work
Vladimir Logachev
@VladimirLogachev
Mar 15 2016 03:09
@SaintPeter I increment i by 1 and push everything into temporary array, then I push whole temporary array to resulting array, it should happen when size is equal to length of arr3. I've read that push() returns new length of array. that's why I'm pushing inside if
pgjones72
@pgjones72
Mar 15 2016 03:09
myPlants[1][1]
Rex Schrader
@SaintPeter
Mar 15 2016 03:09
@pgjones72 You need to chain together your notations. It goes Array->Object->Array
prestonk25
@prestonk25
Mar 15 2016 03:10

```function myTest(val) {
var answer = "";
// Only change code below this line
switch (val) {
case 1: val = "a";
return "apple";
case 2: val = "b";
return 'bird';
case 3: val = "c";
return 'cat';
case 4: val = "d";
return 'stuff';
default: return 'stuff';
}

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

// Change this value to test
myTest('a');
```
I am having trouble getting this switch statement to work, any help?

Rex Schrader
@SaintPeter
Mar 15 2016 03:10
@vl-doit But push only pushes a single element on to the array. Tell me this: When does index 1 ever get pushed?
@prestonk25 when you say switch(val) you are implicitly testing each of the case statements against val. So you want to say case "a":
bitgrower
@bitgrower
Mar 15 2016 03:11
@prestonk25 -- you've ALMOST got the syntax coloring right -- just edit your message and put a carriage return just before "function" so that the 3 backticks are on a line by themselves ...
Vladimir Logachev
@VladimirLogachev
Mar 15 2016 03:11
@SaintPeter Thank you, man! Im Junior Idiot
CamperBot
@camperbot
Mar 15 2016 03:11
vl-doit sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2644 | @saintpeter | http://www.freecodecamp.com/saintpeter
Rex Schrader
@SaintPeter
Mar 15 2016 03:12
@vl-doit Haha, no you're not - this stuff is hard and not always obvious.
@prestonk25 You can insert a newline with shift-enter
Hecv
@HecvStyle
Mar 15 2016 03:15

function palindrome(str) {
// Good luck!

var newStr = str.replace(/[\,|.|\ ]/g,""); // 全局替换空格符号为空字符串
var testStr = newStr.toLowerCase();

console.log(testStr);

for(var i = 0;i< (testStr.length+1)/2; i++){
if(testStr[i] != testStr[testStr.length-1 - i]){
return false;
}
}
return true;
}

palindrome("0_0 (: /-\ :) 0-0");

Rex Schrader
@SaintPeter
Mar 15 2016 03:16
@HecvStyle You need to replace ALL non-alphanumerics, not just commas and periods. The last test is defintely a palindrome, because if you remove all non-alphanumerics you end up with 0000
@HecvStyle Also, your regex is probably wrong. You're using a character class[ ], but then you're putting | (or) inside it. Everything inside a chracter class is already ORed - that's what a chracter class does/means.
@HecvStyle You may want to test your regex at http://regexr.com
Hecv
@HecvStyle
Mar 15 2016 03:18
ok thank you very much
pgjones72
@pgjones72
Mar 15 2016 03:19
@SaintPeter The example shows two nested objects. Each with an array. It doesn't really help with what you are suggesting I should do.
var secondTree = myPlants[1].type.list[1];
Rex Schrader
@SaintPeter
Mar 15 2016 03:19
@pgjones72 I just realized that myself. I'm going to open an issue on it.
pgjones72
@pgjones72
Mar 15 2016 03:20
cool, but now I'm stuck! LOL
Rex Schrader
@SaintPeter
Mar 15 2016 03:21
@pgjones72 oh, you don't need .type in there.
pgjones72
@pgjones72
Mar 15 2016 03:21
@SaintPeter got it, thanks
CamperBot
@camperbot
Mar 15 2016 03:21
pgjones72 sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2645 | @saintpeter | http://www.freecodecamp.com/saintpeter
pgjones72
@pgjones72
Mar 15 2016 03:22
@SaintPeter BTW Peter is my favourite saint- I have his name too :)
Rex Schrader
@SaintPeter
Mar 15 2016 03:22
@pgjones72 :D
junction9x
@junction9x
Mar 15 2016 03:25

function bouncer(arr) {
var x = arr.filter(function(val){ return val !== false && val !== null && val !== 0 && val !== "" && val !== undefined && val !== (isNaN);});// Don't show a false ID to this bouncer.
return x;
}

bouncer([false, null, 0, NaN, undefined, ""]);

Can someone tell me what's wrong with my code for falsy bouncer here?
Rex Schrader
@SaintPeter
Mar 15 2016 03:26
@junction9x Unfortunately, you can't really test for "falsy"nesss in that way. The problem is that NaN === NaN returns false.
@junction9x Also, I think that undefined === undefined also is false.
@junction9x What you can do instead is use the Boolean function, which takes a value and returns true or false from it.
junction9x
@junction9x
Mar 15 2016 03:27
It doesn't seem to be working just for null.
Rex Schrader
@SaintPeter
Mar 15 2016 03:28
@junction9x https://repl.it/BwMp
junction9x
@junction9x
Mar 15 2016 03:28
@SaintPeter : Thank you. I'll use the Boolean then.
CamperBot
@camperbot
Mar 15 2016 03:28
junction9x sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2646 | @saintpeter | http://www.freecodecamp.com/saintpeter
Alex
@arcesso
Mar 15 2016 03:29
How many times have you guys spent hours trying to get some code to work, then gone back to it a little later, start over and get the new code right in the first few tries?
Rex Schrader
@SaintPeter
Mar 15 2016 03:29
@arcesso All. All of the times.
@arcesso ;)
Alex
@arcesso
Mar 15 2016 03:30
@SaintPeter lol
"Why was I trying to do it THAT way..."
Rex Schrader
@SaintPeter
Mar 15 2016 03:31
@arcesso It gets worse. I look at code I wrote ~5 years ago and I scratch my head "Was past me an idiot or a genius?"
Vivienne Sales
@Natto278
Mar 15 2016 03:31
 @arcesso: Many times...
Alex
@arcesso
Mar 15 2016 03:32
@SaintPeter I guess that is why we comment
Rex Schrader
@SaintPeter
Mar 15 2016 03:33
@arcesso I have learned this the hard way. Nothing makes you get religion on commenting quite as much as having to maintain your own code over the course of several years.
bitgrower @bitgrower thanks @SaintPeter for the comment about commenting
CamperBot
@camperbot
Mar 15 2016 03:38
bitgrower sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2647 | @saintpeter | http://www.freecodecamp.com/saintpeter
Rex Schrader
@SaintPeter
Mar 15 2016 03:38
LOL
Eric Murta
@murtinha
Mar 15 2016 03:39
function findLongestWord(str) {
 var longestword;
  var wordSizes=[];
  wordSizes=str.split(" ");
  for(i=0;i<wordSizes.length;i++){
    // Split wordSizes Array into arrays
    wordSizes[i]=wordSizes[i].split("");
    // only reads if after the second increment 
    if(i>=1){
      if(wordSizes[i].length>wordSizes[i-1].length){
        longestword=wordSizes[i].length;
      }
      else{
        longestword=wordSizes[i-1].length;
      }
    }         

    }

    return longestword;


}

findLongestWord("The quick brown fox jumped over the lazy dog");
guys let me know whats wrong
its Find the LOngest Word in a String exercise
devonwilson1
@devonwilson1
Mar 15 2016 03:41
have i not defined myvar in this code? the assignment is called local scope and functions
anyone please??
Rex Schrader
@SaintPeter
Mar 15 2016 03:41
@murtinha I think your logic is wrong on your innermost if statement. You're saying that if the previous word is longer thatn the current word, set the longestword to the new word. But that's backwards. Also, it is NOT true that if the other word is shorter that it should be equal to the other word.

@devonwilson1

now remove the console log line to pass the test

Eric Murta
@murtinha
Mar 15 2016 03:43
@SaintPeter actually is if the newst word is longer then the last word, set the longestword to the newest word
Rex Schrader
@SaintPeter
Mar 15 2016 03:44
@murtinha Ok, but the opposite is not true. If it's less then the new word, it is not true that longestword is now the prior word size.
@murtinha If it is not longer, do nothing.
Eric Murta
@murtinha
Mar 15 2016 03:45
@SaintPeter I wrote that because the first word may be the longeset one
Rex Schrader
@SaintPeter
Mar 15 2016 03:46
@murtinha But if it is not, you end up with some weird stuff happeningin. Imagine these inputs: [ "longword", "short", "a", "bigword", "b" ] - you end up with bigword being the longest because it's compared to "b"
Eric Murta
@murtinha
Mar 15 2016 03:47
@SaintPeter you're right... the trouble is that I have to set something to longestword before comparing
@SaintPeter I think i need another for to compare them all
Rex Schrader
@SaintPeter
Mar 15 2016 03:48
@murtinha Here is what I suggest: Rather than comparing the words to each other (and all the misery that that i -1 causes), instead set longestword to 0 and just compare EACH word to longestword - the first word will always be longer than 0
@murtinha That way, as you go, the longestword will always just be the longest you've seen so far.
Eric Murta
@murtinha
Mar 15 2016 03:50
@SaintPeter It worked perfectly dude hahaha thanks a lot!
CamperBot
@camperbot
Mar 15 2016 03:50
:star: 2648 | @saintpeter | http://www.freecodecamp.com/saintpeter
murtinha sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
Rex Schrader
@SaintPeter
Mar 15 2016 03:50
@murtinha :D
@murtinha BTW, a rule of thumb: If you ever write a for loop and have an i - 1 or i + 1 in it, you're probably doing it wrong/the hard way.
Those are almost impossible to keep track of and you have "fence post errors" all over the place.
Sidharth Kriplani
@sidkrip
Mar 15 2016 03:56
@SaintPeter I have a small problem with my Map the Debris code
jw1540
@jw1540
Mar 15 2016 03:56
help Sum All Numbers in a Range
CamperBot
@camperbot
Mar 15 2016 03:56

:point_right: algorithm sum all numbers in a range [wiki]

Problem Explanation:

  • You need to create a program that will take an array of two numbers who are not necessarily in order, and then add not just those numbers but any numbers in between. For example, [3,1] will be the same as 1+2+3 and not just 3+1
:pencil: read more about algorithm sum all numbers in a range on the FCC Wiki
Rex Schrader
@SaintPeter
Mar 15 2016 03:56
@sidkrip ok
@sidkrip Show me da code ;)
Sidharth Kriplani
@sidkrip
Mar 15 2016 03:57

here it is. The first output is correct. The second input is this:

orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}])

and I dont know how to change the code to get this output. Maybe it will require some looping. Here is the code anyway:

function orbitalPeriod(arr) {
  var GM = 398600.4418;
  var earthRadius = 6367.4447;
  var gm=398600.4418;
  var a=2*Math.PI;
  var alt=arr[0].avgAlt;
  var c = Math.pow(earthRadius + alt, 3);
  var b=Math.sqrt(c/gm);
  var round=Math.round(a*b);                       
  var arra=[];
  var op;
  for(var i=0; i<arr.length; i++) {
  op={name: arr[0].name, orbitalPeriod: round};
  }
  arra.push(op);
  return arra;
}
Rex Schrader
@SaintPeter
Mar 15 2016 03:58
@sidkrip All of your math needs to be inside the loop.
@sidkrip So does your push statement
Sidharth Kriplani
@sidkrip
Mar 15 2016 04:00
@SaintPeter here is the changed code:
function orbitalPeriod(arr) {
  var GM = 398600.4418;
  var earthRadius = 6367.4447;
  var gm=398600.4418;
  var a;
  var alt=arr[0].avgAlt;
  var c;
  var b;
  var round;
  var arra=[];
  var op;
  for(var i=0; i<arr.length; i++) {
  op={name: arr[0].name, orbitalPeriod: round};
  a=2*Math.PI;
  c= Math.pow(earthRadius + alt, 3);
  b=Math.sqrt(c/gm);
  round=Math.round(a*b);                       
  arra.push(op);
  }
  return arra;
}
*shift the op line to right before the push statement
Rex Schrader
@SaintPeter
Mar 15 2016 04:01
@sidkrip Ok, how far off is your answer?
Sidharth Kriplani
@sidkrip
Mar 15 2016 04:01
the same. Second output isnt correct
because the second input has three arguments and my code works for just one
Rex Schrader
@SaintPeter
Mar 15 2016 04:02
@sidkrip var alt=arr[0].avgAlt; <-- Needs to be in the loop, needs to be relative to i
@sidkrip op={name: arr[0].name <-- Similar issue
Sidharth Kriplani
@sidkrip
Mar 15 2016 04:03
alright. made the changes. Easy fix. Thanks @SaintPeter
CamperBot
@camperbot
Mar 15 2016 04:03
sidkrip sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2649 | @saintpeter | http://www.freecodecamp.com/saintpeter
Francis
@Francis-p
Mar 15 2016 04:04
need help with title case a sentence
function titleCase(str) {
  var splitjoin;
  var splitstr = str.split(" ");
  for (var i = 0; i < splitstr.length; i++){
    var splitsplit = splitstr[i].split('');
    splitsplit[0].toUpperCase();
    splitjoin[i] = splitsplit.join(''); 
  }
  var casestr = splitjoin.join(" ");
  return casestr;
}

titleCase("I'm a little tea pot”);
Brian
@BrianCodes33
Mar 15 2016 04:06

@SaintPeter

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

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

  } if (value = "") {

  }

  return collection;
}

can you help me what i'm missing?

Rex Schrader
@SaintPeter
Mar 15 2016 04:06
@Francis-p Remember that in Javascript strings are immutable. That means that toUpperCase() does not change a string, it returns a new string.
@BrianBorin You mean "fill in the blanks"?
Brian
@BrianCodes33
Mar 15 2016 04:07
not give me answers but at least provide direction on where to go
from Record Collection
Rex Schrader
@SaintPeter
Mar 15 2016 04:08
@BrianBorin Well, you need to modify the contents of collection. Do you know how to modify the prop for a given id in collection?
Francis
@Francis-p
Mar 15 2016 04:08
@SaintPeter is this string valid then?
splitsplit[0] = splitsplit[0].toUpperCase()
Rex Schrader
@SaintPeter
Mar 15 2016 04:09
@Francis-p If splitsplit is an array, then yes.
@Francis-p well . . maybe. It looks like it is an array of strings?
@Francis-p ok, yes, that will work :D
Francis
@Francis-p
Mar 15 2016 04:10
@SaintPeter okay! thanks!
CamperBot
@camperbot
Mar 15 2016 04:10
francis-p sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2650 | @saintpeter | http://www.freecodecamp.com/saintpeter
Brian
@BrianCodes33
Mar 15 2016 04:10
@SaintPeter not really
Rex Schrader
@SaintPeter
Mar 15 2016 04:11
@BrianBorin Well, collection is a nested object. You can use bracket notation.
Sidharth Kriplani
@sidkrip
Mar 15 2016 04:11
@SaintPeter this is the code for Seek and Destroy bonfire:
function destroyer(arr) {
  // Remove all the values

  var arg=[];
  var args=Array.prototype.slice.call(arr);
  args.filter(function(each) {
    for (var j=0; j<arg[0].length; j++)
      if (arg[0].indexOf(arg[j])===-1) {
       arg.push(arg[j]); 
    }
  });
  return arg;
}
*args[0] in the loop
some spelling mistakes and this is the code:
function destroyer(arr) {
  // Remove all the values

  var arg=[];
  var args=Array.prototype.slice.call(arr);
  args.filter(function(each) {
    for (var j=0; j<args[0].length; j++)
      if (args[0].indexOf(args[j])===-1) {
       arg.push(args[j]); 
    }
  });
  return arg;
}
Rex Schrader
@SaintPeter
Mar 15 2016 04:13
@sidkrip you're missing a return statement inside your filter. Remember that filter is called once for each element in the array args. You are also not testing each inside the filter function.
Francis
@Francis-p
Mar 15 2016 04:13
@SaintPeter i keep having this cannot set property ‘0’ of undefined
Rex Schrader
@SaintPeter
Mar 15 2016 04:14
@Francis-p That means that one of your "arrays" is not an array - it's empty.
Brian
@BrianCodes33
Mar 15 2016 04:15
@SaintPeter i still don't get it
Francis
@Francis-p
Mar 15 2016 04:15
@SaintPeter splitsplit[] shouldn’t be empty?
var splitsplit = splitstr[i].split("");
    splitsplit[0] = splitsplit[0].toUpperCase();
Rex Schrader
@SaintPeter
Mar 15 2016 04:16
@Francis-p Well, you can try adding console.log statements to see what is going on inside there.
Francis
@Francis-p
Mar 15 2016 04:16
okay. i will try that
Rex Schrader
@SaintPeter
Mar 15 2016 04:17
@BrianBorin You have an object collection. It has properties which are ids. each of those properties are themselves objects which, in turn, have props. You need to chain together bracket notation to access to the idth prop of collection.
jw1540
@jw1540
Mar 15 2016 04:17
hey, looking for some help/explanation
Rex Schrader
@SaintPeter
Mar 15 2016 04:18
I've got both.
Lay it on me.
Brian
@BrianCodes33
Mar 15 2016 04:18
@SaintPeter why can't i use a loop?
jw1540
@jw1540
Mar 15 2016 04:18
I've just completed Diff Two Arrays using this:
function diff(arr1, arr2) {
  var newArr = arr1.concat(arr2);
  function check(i){
    if (arr1.indexOf(i) === -1 || arr2.indexOf(i) === -1) {
      return i;
    }
  }
  // Same, same; but different.
  return newArr.filter(check);
}

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Rex Schrader
@SaintPeter
Mar 15 2016 04:18
@BrianBorin Because they're objects, not arrays. While you technically CAN iterate through an object, it's much easier to just directly access its properties.
jw1540
@jw1540
Mar 15 2016 04:19
I'm confused with the filter callback; how does the check function know what 'i' is?
Scott
@flyfamilyguy
Mar 15 2016 04:19
Hey everyone :)
jw1540
@jw1540
Mar 15 2016 04:20
i understand that with arr1, arr2 it comes from the diff() called after the function, but with 'i' i'm confused where the value comes from to pass to indexOf
Rex Schrader
@SaintPeter
Mar 15 2016 04:20
@jw1540 Well, technically you should be returning true or false to filter. THe reason that it works at all is because when you return i and it's greater than 0, it's read as truthy, and if you don't return i, you don't return anything, which is undefined, which is falsy. So you've accidentially solved the problem incorrectly ;)
@jw1540 Also, i is the value of each element in newArr, because filter calls check once for each element in newArr
@jw1540 When check returns true (or a truthy value), that element is kept. When check returns false (or a falsy value), that element is not kept.
jw1540
@jw1540
Mar 15 2016 04:22
ahhhh
Scott
@flyfamilyguy
Mar 15 2016 04:22
This is a little embarrasing, but I need to get through it. I'm the dumbest soul on the planet when it comes to math! I'm sitting here once again, staring at the 'celsius/fahrenheit' test. I know it's simple I just cannot grasp numbers!
Brian
@BrianCodes33
Mar 15 2016 04:23
@SaintPeter still not clicking
function update(id, prop, value) {
  if (value !== "" && prop !== "tracks") {
      prop[value];
Rex Schrader
@SaintPeter
Mar 15 2016 04:24
@BrianBorin collection is the object you need to access.
@BrianBorin Both id and prop are properties of collection or sub-properties of an object in collection.
Brian
@BrianCodes33
Mar 15 2016 04:24
function update(id, prop, value) {
  if (value !== "" && prop !== "tracks") {
      collection[value];
Rex Schrader
@SaintPeter
Mar 15 2016 04:24
@BrianBorin value will never be in the brackets, because that's what is getting ASSIGNed to the content of colleciton.
Brian
@BrianCodes33
Mar 15 2016 04:25
collection[prop]
Rex Schrader
@SaintPeter
Mar 15 2016 04:26
@BrianBorin What about id? Do you see where they are in the collection object?
Brian
@BrianCodes33
Mar 15 2016 04:26
yea but i dont get how the computer knows "2548" is ID
Sidharth Kriplani
@sidkrip
Mar 15 2016 04:26
wiki Pairwise
CamperBot
@camperbot
Mar 15 2016 04:26

:point_right: algorithm pairwise [wiki]

Explanation:

The program should look for the numbers in the array which would add to make the number from the arg. Then instead of adding those numbers up, you will add their indices which is the reason why you get 11 on the example from detail.

Remember that arrays start at index 0 and go from there so from [1,4,2,3,0,5] if we switch to their indices it would be [0,1,2,3,4,5] then we add indices 1 + 2 + 3 + 5 and we get 11. That is what we need to return.

:pencil: read more about algorithm pairwise on the FCC Wiki

Rex Schrader
@SaintPeter
Mar 15 2016 04:26
@BrianBorin With bracket notation.
Brian
@BrianCodes33
Mar 15 2016 04:27
i'm confused
Rex Schrader
@SaintPeter
Mar 15 2016 04:28
@BrianBorin the values of id, prop, and value are set when the function update is called. You can see down at the bottom of the code list that there is an example call to update
Brian
@BrianCodes33
Mar 15 2016 04:28
i got that
"update or set the value for the prop." that is too vague for me
Rex Schrader
@SaintPeter
Mar 15 2016 04:29
@BrianBorin So, the generaly layout of collection is that it has a top level id and then the object referenced by id has a prop
Gershom
@jinmanbok
Mar 15 2016 04:29
js 
var array = [1,2,3,4,5,6,7];
var newArray = [];

// Only change code below this line.

newArray = array.reverse();
I don’t know what’s going on
I used the reverse method…then assigned it to the newArray variable
Rex Schrader
@SaintPeter
Mar 15 2016 04:30
@BrianBorin IE:
var myObj = {
     "someProp": {  nestedProp: "some Value" }
   }
myObj["someProp"]["nestedProp"] = "Some New Value";
Ok, I've gotta call it a night
Catcha all later!
Catalin Scripcariu
@CatalinScr
Mar 15 2016 04:33
help Make a Person
CamperBot
@camperbot
Mar 15 2016 04:33

:point_right: algorithm make a person [wiki]

Explanation:

When I started the program I figured I just had to create the six functions mentioned in the details. However, it was not that simple. Creating them as a function was not the right way, I had to create them in a different way to make them a key.

There is also a tricky part as you need six keys no more or less, so at first I had the variable that store the original name as a key too which was wrong.

As for the usage of array, that is optional, you could also create new variable to hold the separated string if you wish but an array is easier to deal with as strings are immutable.

Read the instructions carefully, it is always a good hint in itself to run the code and check what the test results were so you know what to expect but do not fixate yourself on that. Once you understand what you need to do, this problem is very easy and straightforward.

:pencil: read more about algorithm make a person on the FCC Wiki

Brian
@BrianCodes33
Mar 15 2016 04:36
can someone help me complete the record collection prompt
Gershom
@jinmanbok
Mar 15 2016 04:41
Nevermind it worked when I refreshed the browser
Francis
@Francis-p
Mar 15 2016 04:44
@BrianBorin what’s the issue?
Sultan Ahmed
@sultanshaik
Mar 15 2016 04:51

Hi friends,
Can you tell me the error in this:
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty(checkProp))
{
return myObj(checkProp);
}
else

return "Not Found";
}

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

it throws "TypeError: myObj is not a function"
tbaotran
@tbaotran
Mar 15 2016 04:53
Not quite sure what the question is asking below:
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
Brian
@BrianCodes33
Mar 15 2016 04:54
@Francis-p having trouble finishing record collection
Francis
@Francis-p
Mar 15 2016 04:54
@BrianBorin show your code again?
Brian
@BrianCodes33
Mar 15 2016 04:56
function update(id, prop, value) {
  if (value !== "" && prop !== "tracks") {
      collection[id][prop] = value;
  } if(prop == "tracks" && value !== "") {

  } if (value == "") {

  }

  return collection;
}
tbaotran
@tbaotran
Mar 15 2016 04:58
I guess correctly.
var remainder = 11 % 3;
Francis
@Francis-p
Mar 15 2016 04:59
@BrianBorin your if else statement is correct. but what is within that?
Kyle Morton
@kmorton1988
Mar 15 2016 04:59
Hi everyone.
tbaotran
@tbaotran
Mar 15 2016 05:00
hi @kmorton1988
Brian
@BrianCodes33
Mar 15 2016 05:00
@Francis-p i need to push the value onto the tracks array
This message was deleted
Francis
@Francis-p
Mar 15 2016 05:01
@BrianBorin use .push(value)
Brian
@BrianCodes33
Mar 15 2016 05:04
@Francis-p tried it
    prop.push = value;
?
Kyle Morton
@kmorton1988
Mar 15 2016 05:05
he gave you the exact syntax to use.
.push(value)
Brian
@BrianCodes33
Mar 15 2016 05:05
i guess i feel dumb now
Francis
@Francis-p
Mar 15 2016 05:05
@sultanshaik checkProp is an array. so you might want to try using [] istead of ()
@BrianBorin
  else if ( value!=="" && prop == "tracks") {
    collection[id][prop].push(value);
Brian
@BrianCodes33
Mar 15 2016 05:08
// Only change code below this line
function update(id, prop, value) {
  if (value !== "" && prop !== "tracks") {
      collection[id][prop] = value;
  } if(prop == "tracks" && value !== "") {
     collection[id][prop].push(value);  } 
  if (value == "") {
 }

  return collection;
}
Francis
@Francis-p
Mar 15 2016 05:10
@BrianBorin last one is for you to delete
@BrianBorin you can find it at 'Delete Properties from a JavaScript Object'
Brian
@BrianCodes33
Mar 15 2016 05:12
  collection[id][prop].delete(value);
?
Francis
@Francis-p
Mar 15 2016 05:12
@BrianBorin nope. i made the same mistake! deleting is a different syntex
check out that lesson
Brian
@BrianCodes33
Mar 15 2016 05:14
did it but now i gotta understand the WHY lol
Sultan Ahmed
@sultanshaik
Mar 15 2016 05:18
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if(myObj.hasOwnProperty(checkProp))
      return myObj(checkProp);

  else

  return "Not Found";
}

// Test your code by modifying these values
console.log(myObj.hasOwnProperty("gift"));
checkObj("gift");
I get a myObj is not a function error..Can you please help?
@Francis-p Can you help me?
Francis
@Francis-p
Mar 15 2016 05:21
@sultanshaik is your code working?
V Arun Kumar
@arunvkumr
Mar 15 2016 05:21
@sultanshaik you can access object elements using dot and bracket notations.. not ().
Francis
@Francis-p
Mar 15 2016 05:21
@BrianBorin which part do u need help with?
Sultan Ahmed
@sultanshaik
Mar 15 2016 05:22
it throws a typerErro:myObj is not a function error
I don't know the cause
V Arun Kumar
@arunvkumr
Mar 15 2016 05:22
@sultanshaik inside if condition return myObj[checkProp]; <- this is what you need not return myObj(checkProp);
Francis
@Francis-p
Mar 15 2016 05:23
@sultanshaik like @arunkumrv said,
return myObj(checkProp);
you can only is .checkProp or [checkProp]
Kyle Morton
@kmorton1988
Mar 15 2016 05:23
help Chunky Monkey
CamperBot
@camperbot
Mar 15 2016 05:23

:point_right: algorithm chunky monkey [wiki]

Explanation

Our goal for this Algorithm is to split arr (first argument) into smaller chunks of arrays with the length provided by size (second argument). There are 4 green checks (objectives) our code needs to pass in order to complete this Algorithm:

  1. (['a', 'b', 'c', 'd'], 2) is expected to be [['a', 'b'], ['c', 'd']]
  2. ([0, 1, 2, 3, 4, 5], 3) is expected to be [[0, 1, 2], [3, 4, 5]]
  3. ([0, 1, 2, 3, 4, 5], 2) is expected to be [[0, 1], [2, 3], [4, 5]]
  4. ([0, 1, 2, 3, 4, 5], 4) is expected to be [[0, 1, 2, 3], [4, 5]]

Click More information under the Algorithm title and read the helpful links if you haven't yet.

:pencil: read more about algorithm chunky monkey on the FCC Wiki

Sultan Ahmed
@sultanshaik
Mar 15 2016 05:23
@arunkumrv Thanks buddy
CamperBot
@camperbot
Mar 15 2016 05:23
sultanshaik sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 363 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Mar 15 2016 05:24
@sultanshaik you're welcome, happy coding :grinning:
Francis
@Francis-p
Mar 15 2016 05:26
my turn to ask for help! :smile:
function titleCase(str) {
  var splitJoin;
  var splitSplit;
  var splitstr = str.split(" ");
  for (var i = 0; i < splitstr.length; i++){
    splitSplit = splitstr[i].split("");
    if (i === 0) {
      splitSplit[0] = splitSplit[0].toUpperCase();
    }
    else if (i > 0 ) {
      splitSplit[i] = splitSplit[i].toLowerCase();
    }

    splitJoin = [splitSplit.join('')];
    splitSplit[i] = splitJoin;
  }
  return splitsplit;
}

titleCase("I'm a little tea pot”);
cannot read property
‘toLowerCase’ of undefined
Bhaskar Sharma
@bhaskar20
Mar 15 2016 05:28
help camper bot
CamperBot
@camperbot
Mar 15 2016 05:28
no wiki entry for: camper bot
Bhaskar Sharma
@bhaskar20
Mar 15 2016 05:28
help no repeats please
CamperBot
@camperbot
Mar 15 2016 05:28

:point_right: algorithm no repeats please [wiki]

Problem Explanation:

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

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

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

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

Maddah Anass
@unlimiworks
Mar 15 2016 05:35
@bhaskar20 try using a recursive that generates all the permutations. I struggled a lot with that
Just completed it hours ago
Federico Marcos
@marcosfede
Mar 15 2016 05:47
hi guys, what is wrong with this code to generate al fibonacci numbers up to num?
function sumFibs(num) {
  var fibs=[0,1];
  while (fibs.slice(-1)[0]+fibs.slice(fibs.length-2,1)[0]<=num){
    fibs.push(fibs.slice(-1)[0]+fibs.slice(fibs.length-2,1)[0]);
  }
  return fibs;
}
Promise Izuagbala
@obule
Mar 15 2016 05:50

function golfScore(par, strokes) {
// Only change code below this line
if (4, 1) {
return "Hole-in-one!";
}
else {
return "Eagle";
}
if (5, 2) {
return "Eagle";
}
return "Change Me";
// Only change code above this line
}

// Change these values to test
golfScore(5, 4);

Please I need help with golf code
Gudmorning people
Jenni
@silverrain64
Mar 15 2016 05:58
This message was deleted
Markus Kiili
@Masd925
Mar 15 2016 06:00
@marcosfede The second argument of slice is the end index.
Kyle Morton
@kmorton1988
Mar 15 2016 06:05
help Mutations
CamperBot
@camperbot
Mar 15 2016 06:05

:point_right: algorithm mutations [wiki]

Problem Explanation:

  • Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array..
:pencil: read more about algorithm mutations on the FCC Wiki
Francis
@Francis-p
Mar 15 2016 06:06
@obule i think you got it wrong
V Arun Kumar
@arunvkumr
Mar 15 2016 06:07
@marcosfede your second slice function inside while is not correct, you can directly use -2 for second last argument instead of fibs.length-1. and
fibs.slice(-1)[0] is same as fibs.slice(fibs.length-1)[0] so for fibs.slice(fibs.length - 2)[0] you can use fibs.slice(-2)[0].
Francis
@Francis-p
Mar 15 2016 06:07
@obule you have to compare par to stroke
Rex Smith Jr.
@rsmith731
Mar 15 2016 06:08
is there anyone that could help me with this exercise 137?
Francis
@Francis-p
Mar 15 2016 06:09
@obule for example
stroke == 1
stroke <= par -2
Federico Marcos
@marcosfede
Mar 15 2016 06:12
@Masd925 @arunkumrv thanks!
CamperBot
@camperbot
Mar 15 2016 06:12
marcosfede sends brownie points to @masd925 and @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 1166 | @masd925 | http://www.freecodecamp.com/masd925
:star: 364 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Rex Smith Jr.
@rsmith731
Mar 15 2016 06:15
anyone there to help?
Kyle Morton
@kmorton1988
Mar 15 2016 06:15
wha'ts the name of the challenge, @rsmith731
Rex Smith Jr.
@rsmith731
Mar 15 2016 06:16
@kmorton1988 Storing Values with the Equal Operator
its not allowing me to assign contents of a to variable b with =
Kyle Morton
@kmorton1988
Mar 15 2016 06:17
post your code
Rex Smith Jr.
@rsmith731
Mar 15 2016 06:18

// Setup
var a;
var b = 2;

// Only change code below this line
var a = 7;
var b = 7;
var a = var b;

Kyle Morton
@kmorton1988
Mar 15 2016 06:19
a variable only has to be "defined" once. (That's what the "var" keyword does). Once it exists, in order to change it, you just use the name, and then the equals sign.
Rex Smith Jr.
@rsmith731
Mar 15 2016 06:20
ok let me try that
Kyle Morton
@kmorton1988
Mar 15 2016 06:20

so like:

var a = 17

you'd be able to then change "a" with just the named variable followed by the equals sign
like this:

a = 12
and you can directly assign the contents of one variable to the contents of another variable.
Rex Smith Jr.
@rsmith731
Mar 15 2016 06:21
still not working for some reason
Kyle Morton
@kmorton1988
Mar 15 2016 06:21
post your code again?
Rex Smith Jr.
@rsmith731
Mar 15 2016 06:22

// Setup
var a;
var b = 2;

// Only change code below this line
var a = 7;
var b = 7;
a = b;

Kyle Morton
@kmorton1988
Mar 15 2016 06:22
type ```js, then hit enter, then paste your code, then hit "Ctrl enter"
Rex Smith Jr.
@rsmith731
Mar 15 2016 06:22
// Setup
var a;
var b = 2;

// Only change code below this line
var a = 7;
var b = 7;
a = b;
thanks for that tip
Kyle Morton
@kmorton1988
Mar 15 2016 06:23
so, in the setup section, they defined the variables for you
so you don't have to redefine them after that
Rex Smith Jr.
@rsmith731
Mar 15 2016 06:23
oh ok gotcha
but in the instructions it states that a should have a value of 7
b should have a value of 7
Kyle Morton
@kmorton1988
Mar 15 2016 06:24
right
Rex Smith Jr.
@rsmith731
Mar 15 2016 06:25
so shouldn’t i redefine them?
Kyle Morton
@kmorton1988
Mar 15 2016 06:25
so if you set a to 7, then you set b to a
defining a variable only happens once, when you use var a = 4
after that, you can then assign a value to it with just a = 7
cannelflow
@cannelflow
Mar 15 2016 06:26
@rsmith731 you variable should always on left hand side and b is your variable there so it should be like var b =a;
Kyle Morton
@kmorton1988
Mar 15 2016 06:26
@cannelflow that would be redefining the "b" variable, which is already defined.
Ron Cruz
@Ronolibert
Mar 15 2016 06:26
wiki
CamperBot
@camperbot
Mar 15 2016 06:26
usage:
wiki $topic info on that topic
Ron Cruz
@Ronolibert
Mar 15 2016 06:27
help title case a sentence
CamperBot
@camperbot
Mar 15 2016 06:27

:point_right: algorithm title case a sentence [wiki]

Explanation:

We have to return a sentence with camel case. This means that the first letter will always be in uppercase and the rest lowercase.

:pencil: read more about algorithm title case a sentence on the FCC Wiki

Rex Smith Jr.
@rsmith731
Mar 15 2016 06:27
now since i change that, i’m getting red x’s
Kyle Morton
@kmorton1988
Mar 15 2016 06:28
remember to put a semicolon after each declaration.
Rex Smith Jr.
@rsmith731
Mar 15 2016 06:28
changed*
cannelflow
@cannelflow
Mar 15 2016 06:28
@kmorton1988 i just generalized for that exercise which says assign value 7 to a then assign the value of a to b so i did var b =a ;
Rex Smith Jr.
@rsmith731
Mar 15 2016 06:28
// Setup
var a;
var b = 2;

// Only change code below this line
a = 7;
a = b;
Kyle Morton
@kmorton1988
Mar 15 2016 06:28
ahh, ok. But in this case, the "setup" has already defined b for him.
variable you're defining always goes on the left, @rsmith731
variable you're assigning a value to, rather.
cannelflow
@cannelflow
Mar 15 2016 06:29
@kmorton1988 see the instruction // Only change code below this line we have to write our code below that and nothing is there
Rex Smith Jr.
@rsmith731
Mar 15 2016 06:29
@kmorton1988 @cannelflow thanks!!!! it finally worked
CamperBot
@camperbot
Mar 15 2016 06:29
rsmith731 sends brownie points to @kmorton1988 and @cannelflow :sparkles: :thumbsup: :sparkles:
:star: 918 | @cannelflow | http://www.freecodecamp.com/cannelflow
:star: 278 | @kmorton1988 | http://www.freecodecamp.com/kmorton1988
Kyle Morton
@kmorton1988
Mar 15 2016 06:29
welcome :)
cannelflow
@cannelflow
Mar 15 2016 06:30
@rsmith731 :+1:
Rex Smith Jr.
@rsmith731
Mar 15 2016 06:30
it makes sense now!!!
Kyle Morton
@kmorton1988
Mar 15 2016 06:30
Good! that's the goal.
@cannelflow right, but within that .js script, a and b were already defined. Evertying in the text box runs at once, regardless of whether or not they let you edit that section in that lesson
V Arun Kumar
@arunvkumr
Mar 15 2016 06:31
@Francis-p you need help with titlecase?
David Alexis
@r0nind
Mar 15 2016 06:32
Greetings everyone. On the "testing objects for properties" question, I've been stumped. I've tried a variety of things and my latest attempt only gets me so far.
Francis
@Francis-p
Mar 15 2016 06:32
@arunkumrv yes!
cannelflow
@cannelflow
Mar 15 2016 06:32
@kmorton1988 :+1:
David Alexis
@r0nind
Mar 15 2016 06:32

Here's my code: // Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

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

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

Kyle Morton
@kmorton1988
Mar 15 2016 06:32
@r0nind, type ```js, hit enter, paste your code, then hit ctrl-enter
Francis
@Francis-p
Mar 15 2016 06:33
@r0nind hasOwnProperty(checkProp)
Kyle Morton
@kmorton1988
Mar 15 2016 06:33
^
Rex Smith Jr.
@rsmith731
Mar 15 2016 06:33
does code camp have an exercise on Fizz Buzz?
V Arun Kumar
@arunvkumr
Mar 15 2016 06:33
@Francis-p post your code with changes if you did any from the last post. :point_up: March 15, 2016 10:56 AM
Kyle Morton
@kmorton1988
Mar 15 2016 06:33
I don't think so, @rsmith731.
Rex Smith Jr.
@rsmith731
Mar 15 2016 06:33
@kmorton1988 ok thanks
CamperBot
@camperbot
Mar 15 2016 06:33
rsmith731 sends brownie points to @kmorton1988 :sparkles: :thumbsup: :sparkles:
:warning: rsmith731 already gave kmorton1988 points
Francis
@Francis-p
Mar 15 2016 06:33
@arunkumrv i didn’t update anything else from there. got stuck for the whole morning
Kyle Morton
@kmorton1988
Mar 15 2016 06:34
@rsmith731 that test is probably not quite as used as it once was in interviews, btw.
David Alexis
@r0nind
Mar 15 2016 06:34
that helped! Thanks @Francis-p . I appreciate it
CamperBot
@camperbot
Mar 15 2016 06:34
r0nind sends brownie points to @francis-p :sparkles: :thumbsup: :sparkles:
:star: 261 | @francis-p | http://www.freecodecamp.com/francis-p
cannelflow
@cannelflow
Mar 15 2016 06:34
@r0nind if (myObj.hasOwnProperty(checkProp))
V Arun Kumar
@arunvkumr
Mar 15 2016 06:35
@Francis-p alright... you are getting an error somthing like can't read index 1..
Francis
@Francis-p
Mar 15 2016 06:35
@r0nind got the same issue previously
Rex Smith Jr.
@rsmith731
Mar 15 2016 06:35
@kmorton1988 well this recruiter called me about a job today and she told me that the project manager requires the developer to take the test
Kyle Morton
@kmorton1988
Mar 15 2016 06:35
oh fun! haha. That is really exciting.
also, keep in mind, they will probably have you write it out on a whiteboard.
you don't usually HAVE to get syntax exactly right, but it's the logic that they want you to get more than anything
Francis
@Francis-p
Mar 15 2016 06:35
@arunkumrv cannot read property ‘toLowerCase’ of undefined
Rex Smith Jr.
@rsmith731
Mar 15 2016 06:36
@kmorton1988 oh man! kudos for the tips
Kyle Morton
@kmorton1988
Mar 15 2016 06:36
for sure. Good luck, mate!
Francis
@Francis-p
Mar 15 2016 06:36
@Francis-p so i assume is splitSplit[i]
Venutom
@Venutom
Mar 15 2016 06:43

Hey all newb here, I'm extremely lost and stuck in Javascript. On the 'Local Scope and Functions' section of the Javascript "map" I have no idea what they're asking me to do. Here is what I have:function myFunction() {
'use strict';

console.log(myVar);
}
myFunction();
var loc = "myVar";

V Arun Kumar
@arunvkumr
Mar 15 2016 06:44
@Francis-p you are using the i value of the total length of the array of words.. and your if condition will only work once because of the value of i will be 0 only once.. remove the if statement.. and also else... instead of lowercasing one at a time.. when you are spliting them into words there you lowercase them
Ricco
@riccochapa
Mar 15 2016 06:45
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

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

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

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


// Only change code above this line
}

// Change these values to test your function
lookUp("Sherlock", "likes");
Can anyone tell me why it works with the if statement or the if else statement but not both?
cannelflow
@cannelflow
Mar 15 2016 06:46
if you decleare variable here outside the function that variable is global
myFunction() {
'use strict';
if you decleare variable here that variable is local to this function so Declare a local variable myVar inside myFunction
console.log(myVar);
}
@Venutom
V Arun Kumar
@arunvkumr
Mar 15 2016 06:47
@riccochapa to check for property exists or not, you can use hasOwnProperty or check whether the prop is not undefined.. and remove the else-if clause of no such contact completely and return no such contact out of loop
Ricco
@riccochapa
Mar 15 2016 06:48
thanksyou @arunkumrv ... I knew I was missing something but I couldn't figure it out.
@arunkumrv thanks!
CamperBot
@camperbot
Mar 15 2016 06:49
riccochapa sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 365 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Mar 15 2016 06:49
@riccochapa you're welcome.
cannelflow
@cannelflow
Mar 15 2016 06:50
@Venutom ?
Ron Cruz
@Ronolibert
Mar 15 2016 06:53
@venutom what about it do you have a question on?
V Arun Kumar
@arunvkumr
Mar 15 2016 06:53
@riccochapa and one more thing for no such prop clause... you need one more condition in that, to see whether the property exists there must be a contact in the contacts object, check whether the contacts exists and then if he/she has the property if not return no such property if yes return property... after completely looking for the person you didn't find him/her(in this step you will be out of loop, when you are in loop you are still looking for the person so no such contact inside loop wiill break the loop).. the you return no such contact.
Ron Cruz
@Ronolibert
Mar 15 2016 06:56
@Venutom you need to remove the console.log line to pass the exercise
It's trying to illustrate that when you declare variables inside of a function, you cannot access it outside of the function because they are not the same scope
so the myVar that console.log is trying to use does not exist because the variable was declared inside the function, thus not the same scope
Kyle Morton
@kmorton1988
Mar 15 2016 06:59
help falsy bouncer
CamperBot
@camperbot
Mar 15 2016 06:59
no wiki entry for: flasy bouncer
Kyle Morton
@kmorton1988
Mar 15 2016 07:00
help falsy bouncer
CamperBot
@camperbot
Mar 15 2016 07:00

:point_right: algorithm falsy bouncer [wiki]

Problem Explanation:

Remove all falsy values from an array.

:pencil: read more about algorithm falsy bouncer on the FCC Wiki

V Arun Kumar
@arunvkumr
Mar 15 2016 07:00
@Francis-p how is it going on?
Sidharth Kriplani
@sidkrip
Mar 15 2016 07:01
@SaintPeter need help with the bonfire Validate US Telephone Numbers
CamperBot
@camperbot
Mar 15 2016 07:01
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Sidharth Kriplani
@sidkrip
Mar 15 2016 07:02
oh he isnt here. Anyone else done with this bonfire?
Francis
@Francis-p
Mar 15 2016 07:02

@arunkumrv i manage to solve it after a few more tries!

function titleCase(str) {
  var splitJoin = [0];
  var splitSplit;
  var titleStr;
  var splitstr = str.split(" ");
  for (var i = 0; i < splitstr.length; i++){
    splitSplit = splitstr[i].toLowerCase().split("");
    splitSplit[0] = splitSplit[0].toUpperCase();
    splitJoin[i] = splitSplit.join('');
  }
  titleStr = splitJoin.join(" ");
  return titleStr;
}

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

but is there any other way to simplify it?

Venutom
@Venutom
Mar 15 2016 07:02
@cannelflow thank you for that, but I still can't pass this exercise. It says X on "no global myVar variable" do I just erase the function?
CamperBot
@camperbot
Mar 15 2016 07:02
venutom sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
:star: 919 | @cannelflow | http://www.freecodecamp.com/cannelflow
Ron Cruz
@Ronolibert
Mar 15 2016 07:02
@Venutom yes you erase the console.log
since the myVar does not exist in that particular scope
oh
i'm not sure what exercise you're on
Venutom
@Venutom
Mar 15 2016 07:05
There are two console.logs I'm not sure what to delete. I don't understand.
Sidharth Kriplani
@sidkrip
Mar 15 2016 07:06
anyone done with the bonfire Validate US Telephone Numbers?
Ron Cruz
@Ronolibert
Mar 15 2016 07:06
paste your code
@Venutom
Federico Marcos
@marcosfede
Mar 15 2016 07:06
guys I want to flatten out a list of lists recursively, what is wrong in the following code
function steamroller(arr) {
    var result=[];
    if (!(Array.isArray(arr))){ return arr;}
    return result.concat(arr.map(steamroller));
}
Venutom
@Venutom
Mar 15 2016 07:07

function myFunction() {
'use strict';
var myVar="5";

console.log(myVar);
}
myFunction();

// now remove the console log line to pass the test

Ron Cruz
@Ronolibert
Mar 15 2016 07:07
oh
inside myFunction
var myVar = 'use strict'
I was kinda confused by that too when iw as there, since the spacing was weird
bitgrower
@bitgrower
Mar 15 2016 07:08
@marcosfede -- every time you call steamroller, you are setting result to the empty array
Ron Cruz
@Ronolibert
Mar 15 2016 07:08
they want you to assign myVar to 'use strict'
Federico Marcos
@marcosfede
Mar 15 2016 07:08
omg thanks
Sidharth Kriplani
@sidkrip
Mar 15 2016 07:08
wiki Search and Replace
CamperBot
@camperbot
Mar 15 2016 07:08

:point_right: algorithm search and replace [wiki]

Problem Explanation:

  • You will create a program that takes a sentence, then search for a word in it and replaces it for a new one while preserving the uppercase if there is one.
:pencil: read more about algorithm search and replace on the FCC Wiki
Venutom
@Venutom
Mar 15 2016 07:09
@Ronolibert thank you, but the box on the left side keeps saying "console.log never called" no matter which one I delete
CamperBot
@camperbot
Mar 15 2016 07:09
venutom sends brownie points to @ronolibert :sparkles: :thumbsup: :sparkles:
:star: 287 | @ronolibert | http://www.freecodecamp.com/ronolibert
Ron Cruz
@Ronolibert
Mar 15 2016 07:10
function myFunction() {
  var myVar = 'use strict';


  console.log(myVar);
}
myFunction();
V Arun Kumar
@arunvkumr
Mar 15 2016 07:10
@Francis-p
function titleCase(str) {
  var splitJoin = [];
  var splitstr = str.toLowerCase().split(" ");
  for (var i = 0; i < splitstr.length; i++) {
    splitSplit = splitstr[i].split("");
      splitSplit[0] = splitSplit[0].toUpperCase();
    splitJoin[i] = splitSplit.join('');
  }
  return splitJoin.join(' ');
}
Ron Cruz
@Ronolibert
Mar 15 2016 07:10
@Venutom that should be your code
Venutom
@Venutom
Mar 15 2016 07:12

function myFunction() {
var myVar='use strict';

console.log(myVar);
}
myFunction();

I am still being told it's wrong
the red X says "no global myVar variable" and Idk if that means add one or not to add one....
Ron Cruz
@Ronolibert
Mar 15 2016 07:13
What exercise are you on?
Venutom
@Venutom
Mar 15 2016 07:13
Javascript Local Scope and Functions
Francis
@Francis-p
Mar 15 2016 07:13
@arunkumrv okay! thanks!!!
CamperBot
@camperbot
Mar 15 2016 07:13
francis-p sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 366 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Ron Cruz
@Ronolibert
Mar 15 2016 07:14
that's weird, my code worked for me
refresh your page and try again
Mayank Yadav
@mayank-ism
Mar 15 2016 07:14

I have to write a script to check for palindromes. Here is my script:

function palindrome(str) {
str = str.replace(/\W/gi,'').toLowerCase();
//console.log(str);

if (str === str.split('').reverse().join(''))
return true;

return false;
}

palindrome("eye");

I am unable to figure out what's wrong with my script.

Any help?
Venutom
@Venutom
Mar 15 2016 07:15
Ah the ol' refresh trick. Shoulda known thanks @Ronolibert
CamperBot
@camperbot
Mar 15 2016 07:15
venutom sends brownie points to @ronolibert :sparkles: :thumbsup: :sparkles:
:warning: venutom already gave ronolibert points
Ron Cruz
@Ronolibert
Mar 15 2016 07:15
@mayank-ism you cannot have 2 return statements in the same conditional
return exits the entire function
Markus Kiili
@Masd925
Mar 15 2016 07:16
@Ronolibert That is not the problem there.
Mayank Yadav
@mayank-ism
Mar 15 2016 07:16

function palindrome(str) {
str = str.replace(/\W/gi,'').toLowerCase();
//console.log(str);

if (str === str.split('').reverse().join('')) {
return true;
} else {
return false;
}
}

palindrome("eye");

Still wrong :(

V Arun Kumar
@arunvkumr
Mar 15 2016 07:17
@Francis-p or you can make it more simpler by using the substr the code will be hardly 8 lines.
Mayank Yadav
@mayank-ism
Mar 15 2016 07:17
unable to pass this case : palindrome("0_0 (: /-\ :) 0-0")
Markus Kiili
@Masd925
Mar 15 2016 07:17
@mayank-ism You are not removing underscores.
Ron Cruz
@Ronolibert
Mar 15 2016 07:17
oh
Mayank Yadav
@mayank-ism
Mar 15 2016 07:17
okay let me check
V Arun Kumar
@arunvkumr
Mar 15 2016 07:17
@mayank-ism add underscore in your regexp that will work
Mayank Yadav
@mayank-ism
Mar 15 2016 07:18
is underscore a part of alphanumeric?
Francis
@Francis-p
Mar 15 2016 07:18
@arunkumrv alright!
Markus Kiili
@Masd925
Mar 15 2016 07:18
@mayank-ism Yes, part of \w.
Mayank Yadav
@mayank-ism
Mar 15 2016 07:18
gotcha!
Thanks, should have read the documentation properly.
thanks @Masd925
CamperBot
@camperbot
Mar 15 2016 07:23
mayank-ism sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1167 | @masd925 | http://www.freecodecamp.com/masd925
Sidharth Kriplani
@sidkrip
Mar 15 2016 07:26
@Masd925 can you help me with the Validate US Telephone Numbers bonfire and with regexp as well?
CamperBot
@camperbot
Mar 15 2016 07:26
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Colin Thornton
@colinthornton
Mar 15 2016 07:30
Hey guys, I'm on problem #262 "Seek and Destroy" and I think I've found a bug.
Sidharth Kriplani
@sidkrip
Mar 15 2016 07:31
Houston we have a problem. What is it @YouMeWeThem
kirbyedy
@kirbyedy
Mar 15 2016 07:31
@YouMeWeThem if you want to report a problem or bug, check the freecodecamp github, and explain it there
Sidharth Kriplani
@sidkrip
Mar 15 2016 07:32
@kirbyedy ! can you please help ?
Colin Thornton
@colinthornton
Mar 15 2016 07:32
Well, I test all the inputs that it checks for, and I get them all right, but when I hit "run the test" nothing gets checked.
function callback(value){
  return value !== this;
}

function destroyer(arr) {
  for (i = 1; i < arguments.length; i++) {
    arr = arr.filter(callback, arguments[i]);
  }
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Here's my code
kirbyedy
@kirbyedy
Mar 15 2016 07:33
@sidkrip I did not finish that bonfire, sorry... use this site to check your regexp http://www.regexpal.com/
Colin Thornton
@colinthornton
Mar 15 2016 07:34
So this returns [1, 1], which is correct.
kirbyedy
@kirbyedy
Mar 15 2016 07:35
@YouMeWeThem when I run your code, non of the tasks passes
hmmm
Colin Thornton
@colinthornton
Mar 15 2016 07:36
Here, I'm running this
kirbyedy
@kirbyedy
Mar 15 2016 07:36
the console returns this: Uncaught ReferenceError: callback is not defined
Colin Thornton
@colinthornton
Mar 15 2016 07:36
```

function callback(value){
return value !== this;
}

function destroyer(arr) {
for (i = 1; i < arguments.length; i++) {
arr = arr.filter(callback, arguments[i]);
}
return arr;
}
console.log("START");
console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));
console.log(destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3));
console.log(destroyer([3, 5, 1, 2, 2], 2, 3, 5));
console.log(destroyer([2, 3, 2, 3], 2, 3));
console.log(destroyer(["tree", "hamburger", 53], "tree", 53));

ahhh
sorry
function callback(value){
  return value !== this;
}

function destroyer(arr) {
  for (i = 1; i < arguments.length; i++) {
    arr = arr.filter(callback, arguments[i]);
  }
  return arr;
}
console.log("START");
console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));
console.log(destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3));
console.log(destroyer([3, 5, 1, 2, 2], 2, 3, 5));
console.log(destroyer([2, 3, 2, 3], 2, 3));
console.log(destroyer(["tree", "hamburger", 53], "tree", 53));
kirbyedy
@kirbyedy
Mar 15 2016 07:37
your console returns this: Uncaught ReferenceError: callback is not defined
Colin Thornton
@colinthornton
Mar 15 2016 07:38
And my console outputs this START seek-and-destroy:13:1
Array [ 1, 1 ] seek-and-destroy:14:1
Array [ 1, 5, 1 ] seek-and-destroy:15:1
Array [ 1 ] seek-and-destroy:16:1
Array [ ] seek-and-destroy:17:1
Array [ "hamburger" ]
Never mind
My console returns this when I run the above code
START seek-and-destroy:9255:1
Array [ 1, 2, 3, 1, 2, 3 ] seek-and-destroy:9256:1
Array [ 1, 2, 3, 5, 1, 2, 3 ] seek-and-destroy:9257:1
Array [ 3, 5, 1, 2, 2 ] seek-and-destroy:9258:1
Array [ 2, 3, 2, 3 ] seek-and-destroy:9259:1
Array [ "tree", "hamburger", 53 ] seek-and-destroy:9260:1
START seek-and-destroy:14:1
Array [ 1, 1 ] seek-and-destroy:15:1
Array [ 1, 5, 1 ] seek-and-destroy:16:1
Array [ 1 ] seek-and-destroy:17:1
Array [ ] seek-and-destroy:18:1
Array [ "hamburger" ]
So it looks like whatever test the site is running doesn't find the callback() function
kirbyedy
@kirbyedy
Mar 15 2016 07:42
maybe that callback is causing the problem
Markus Kiili
@Masd925
Mar 15 2016 07:43
@YouMeWeThem Inside callback this is always an object (number object in this case). Try using != instead.
Colin Thornton
@colinthornton
Mar 15 2016 07:44
@Masd925 That's the ticket, thanks for the tip.
CamperBot
@camperbot
Mar 15 2016 07:44
youmewethem sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1168 | @masd925 | http://www.freecodecamp.com/masd925
Colin Thornton
@colinthornton
Mar 15 2016 07:45
Phew, I was getting a little annoyed there.
Markus Kiili
@Masd925
Mar 15 2016 07:45
@YouMeWeThem It is better to only filter once and put the loop or indexOf inside the callback.
@YouMeWeThem You could pass arguments in as this and loop inside.
Colin Thornton
@colinthornton
Mar 15 2016 07:45
Okay, I'll see what I can do.
Sidharth Kriplani
@sidkrip
Mar 15 2016 07:45
@Masd925 help please?
Markus Kiili
@Masd925
Mar 15 2016 07:47
@sidkrip Sorry, haven't done that problem yet.
@YouMeWeThem One way then is to use Array.prototype.indexOf.call() inside the callback on this (instead of for loop).
Sidharth Kriplani
@sidkrip
Mar 15 2016 07:49
@Masd925 need help with another one as well. Bonfire Search and Replace
CamperBot
@camperbot
Mar 15 2016 07:49
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Markus Kiili
@Masd925
Mar 15 2016 07:53
@sidkrip I did it with split, map, and join.
Sidharth Kriplani
@sidkrip
Mar 15 2016 07:53
have a look at my code and you will understand what I need to know
function myReplace(str, before, after) {

  var small=new RegExp(/[a-z]/g);
  var caps=new RegExp(/[A-Z]/g);
  var bef=before.split("");
  var aft=after.split("");
  var arr=str.split(' ');
  var ind=arr.indexOf(before);
  if(bef[0].match(small) && aft[0].match(small)) {
    arr[ind]=after;
  }

  arr=arr.join(" ");
  return arr;
}
the other inputs have the argument before having a capital starting letter. So I can hardcode and make the after argument replicate that capital feature of the before. I just want to know how to change the case.
Sidharth Kriplani
@sidkrip
Mar 15 2016 08:00
anyway, I did it now. thanks
wiki Sum All Odd Fibonacci Numbers
CamperBot
@camperbot
Mar 15 2016 08:02

:point_right: algorithm sum all odd fibonacci numbers [wiki]

Explanation:

You will need to gather all the Fibonacci numbers and then check for the odd ones. Once you get the odd ones then you will add them all. The last number should be the number given as a parameter if it actually happens to be an off Fibonacci number.

:pencil: read more about algorithm sum all odd fibonacci numbers on the FCC Wiki

Mas hary
@mas212
Mar 15 2016 08:09
factorialize(20) should return 2432902008176640000 ??
@Masd925 can help me :)
Markus Kiili
@Masd925
Mar 15 2016 08:13
@mas212 Yes, what is the problem there?
Sidharth Kriplani
@sidkrip
Mar 15 2016 08:15
@Masd925 a loop problem here
this is for Sum All Odd Fibonacci Numbers
function sumFibs(num) {
  var result;
  var a=1, b=1, c, sum;
  var arr=[a, b];
  for(var i=0; i<num; i++) {
  c=a+b;
  sum=c+b;
  arr.push(c);
  c=sum;
  b=c;
  }
  return arr;
}
this is crashing my browser which is thankfully Mozilla
Markus Kiili
@Masd925
Mar 15 2016 08:17
@sidkrip Are you generating num Fibonacci numbers or Fibonacci numbers <=num ?
Sidharth Kriplani
@sidkrip
Mar 15 2016 08:18
I am trying to generate "num" Fibonacci terms.
the former I mena
*mean
Markus Kiili
@Masd925
Mar 15 2016 08:19
@sidkrip You should be generating all the Fibonacci numbers that are <=num.
Sidharth Kriplani
@sidkrip
Mar 15 2016 08:20
that I can do later. I want to accept the "num" as the number of Fibonacci terms to generate and do that first.
Francis
@Francis-p
Mar 15 2016 08:20

i am still halfway through this…

function largestOfFour(arr) {
  // You can do this!
  var larger = [0];
  for (var i = 0; i < arr.length; i++) {
    var large = arr[i];
    for (var a = 0; a <large.length; a++) {
      if (larger[0][a] < large[a]) {
        larger[0][a] = large[a];
      }
    }

  }
  return larger;
}

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

trying to figure out what’s wrong

Sidharth Kriplani
@sidkrip
Mar 15 2016 08:21
and I dont know why but my logically correct loop seems to be crashing my browser
J Player
@Heyjp
Mar 15 2016 08:22
@Francis-p alright, so what do you have to do for that challenge?
Sidharth Kriplani
@sidkrip
Mar 15 2016 08:22
wiki Steamroller
CamperBot
@camperbot
Mar 15 2016 08:22

:point_right: algorithm steamroller [wiki]

Explanation:

This problem seems simple but you need to make sure to flatten any array, regardless of the level which is what adds a bit of difficulty to the problem.

:pencil: read more about algorithm steamroller on the FCC Wiki

Francis
@Francis-p
Mar 15 2016 08:23
returning the largest number in the array @Heyjp
sub array i mean
J Player
@Heyjp
Mar 15 2016 08:23
is it in just one array or the largest number in each sub array?
Sidharth Kriplani
@sidkrip
Mar 15 2016 08:30
wiki Arguments Optional
CamperBot
@camperbot
Mar 15 2016 08:30

:point_right: algorithm arguments optional [wiki]

Explanation:

It can be quite complicated to understand what needs to be done. There are always many ways to do something when coding but regardless of the algorithm used, we have to create a program that does the following:

  • It has to add two numbers passed as parameters and return the sum.
  • It has to check if any of the numbers are actual numbers, otherwise return undefined and stop the program right there.
  • It has to check if it has one or two arguments passed. More are ignored.
  • If it has only one argument then it has to return a function that uses that number and expects another one, to then add it.

:pencil: read more about algorithm arguments optional on the FCC Wiki

Francis
@Francis-p
Mar 15 2016 08:31
@Heyjp largest number in each sub array
Sidharth Kriplani
@sidkrip
Mar 15 2016 08:34
wiki Smallest Common Multiple
CamperBot
@camperbot
Mar 15 2016 08:34

:point_right: algorithm smallest common multiple [wiki]

Explanation:

The smallest common multiple between two numbers is the smallest number that
both numbers can divide into. This concept can be extended to more than two
numbers as well.

We can first start with just finding the smallest common multiple between two
numbers. Naively, you can start writing out multiple of each number until you
write a multiple that exists from both numbers.

An example would be the numbers 3 and 4. The multiples of 3 are 3, 6, 9, 12, 15, 18, ... and the multiples of 4 are 4, 8, 12, 16, 20, .... The
first smallest number we run into in both lists is 12 so this is the smallest
common multiple between 3 and 4.

This problem can be confusing because most people look for the smallest common
multiple of just the two numbers but forget the keyword range. However, this
means that if you are given [1,5], then you have to check for the smallest
common multiple for all the numbers [1,2,3,4,5] that is evenly divisible by
all of them.

:pencil: read more about algorithm smallest common multiple on the FCC Wiki

Sidharth Kriplani
@sidkrip
Mar 15 2016 08:35
wiki Drop It
CamperBot
@camperbot
Mar 15 2016 08:35

:point_right: algorithm drop it [wiki]

Explanation:

Basically while the second argument is not true, you will have to remove the first element from the left of the array that was passed as the first argument.

:pencil: read more about algorithm drop it on the FCC Wiki

J Player
@Heyjp
Mar 15 2016 08:36
@Francis-p your for loop is fine, however currently your array isn't ever going to be larger than one element.
V Arun Kumar
@arunvkumr
Mar 15 2016 08:37
@Francis-p remember you are passing 2d array so you have to access each value.. and to find larger elem in sub array use Math.max or sort function..
Geo Galagaran
@geeofree
Mar 15 2016 08:39

Hey guys, is there a better way to write this down?

function end(str, target) {
  var hasSpace = /\s/g.test(str);
  if(hasSpace){
    if(str.substr(-2) === target || str.substr(-4) === target){
      return true;
    }
    else{
      return false;
    }
  }
  else{
    if(str.substr(-1) === target){
      return true;
    }
    else{
      return false;
    }
  }
}

end("Walking on water and developing software from a specification are easy if both are frozen", "specification");

I feel like I rigged it. Is there a way for it to be more "automated" rather than typing out

str.substr(-2) === target || str.substr(-4) === target

to check for the last 2 or last 4 indexes?

Codemzy
@codemzy
Mar 15 2016 08:40
@da7thsin whats the challenge doing? checking if str ends with target?
Geo Galagaran
@geeofree
Mar 15 2016 08:41
@codemzy its the Confirm the Ending challenge.
and yes, it is the checking for str === target
Francis
@Francis-p
Mar 15 2016 08:41
@Heyjp how do i do that?
@arunkumrv what you mean is to sort the array then i return the largest number from there?
Codemzy
@codemzy
Mar 15 2016 08:43
@da7thsin how I did it, was I got the end section of the str matching whatever the length of target was like... strSearch = str.substr(str.length-target.length, target.length); then if it matched target, returned true, if it didnt, returned false
J Player
@Heyjp
Mar 15 2016 08:45
@Francis-p use array.push()
Codemzy
@codemzy
Mar 15 2016 08:45
@da7thsin its an easier way and you dont need to check for spaces, if theres a space in target it will check in your section of the str anyway if it matches
V Arun Kumar
@arunvkumr
Mar 15 2016 08:46
@Francis-p ya, sort the sub arrays so that largerst nums are either at beginning or at end and then directly put them in the larger array... this would be simple.
Or you can take one subarray and compare each elements with each other anf if you find the largest elem put it in larger array same goes for rest of subarrays..
Francis
@Francis-p
Mar 15 2016 08:47
@arunkumrv i wanted to compare it initially but sorting it out can be done too. i will try out
Geo Galagaran
@geeofree
Mar 15 2016 08:47
@codemzy haha yea :P I think my noggin just went "if there was a space, I should do this" when I went through the objectives. Thanks for the input!
CamperBot
@camperbot
Mar 15 2016 08:47
da7thsin sends brownie points to @codemzy :sparkles: :thumbsup: :sparkles:
:star: 730 | @codemzy | http://www.freecodecamp.com/codemzy
Francis
@Francis-p
Mar 15 2016 08:47
@Heyjp noted! totally forgotten about push()! thanks!
CamperBot
@camperbot
Mar 15 2016 08:47
francis-p sends brownie points to @heyjp :sparkles: :thumbsup: :sparkles:
:star: 349 | @heyjp | http://www.freecodecamp.com/heyjp
Codemzy
@codemzy
Mar 15 2016 08:49
@da7thsin :thumbsup: its good to have a few attempts and see other ways of doing it!
Geo Galagaran
@geeofree
Mar 15 2016 08:51
@codemzy definitely! Haha. Thanks again. :smile:
CamperBot
@camperbot
Mar 15 2016 08:51
da7thsin sends brownie points to @codemzy :sparkles: :thumbsup: :sparkles:
:warning: da7thsin already gave codemzy points
Francis
@Francis-p
Mar 15 2016 09:03
@arunkumrv thanks! i manage to solve it with .sort and it’s a cleaner way to code it!
Pedro Abel Díaz Sánchez
@coderHook
Mar 15 2016 09:11

Morning guys,

Any idea on how to delay this call to a function?

function play(x){
  var audio = '';
if(x==1){ audio = document.getElementById("soundPad1");}
else if(x==2){ audio = document.getElementById("soundPad2");}
else if(x==3){ audio = document.getElementById("soundPad3");}
else if(x==4){ audio = document.getElementById("soundPad4");}

       audio.play();
}

function newGame(){
  for(var i=0; i<5; i++){
  var x = Math.floor(Math.random()*4) + 1;
  gameChain = gameChain.concat(x);
  }
  document.getElementById('score').value = '- -'
  console.log(gameChain);
  turn = 1;
  computerGame();
  return gameChain;
} 

function computerGame(){
  gameChain = [4, 1, 1, 3, 4];

  for(var i=0; i < gameChain.length; i++){
    play(gameChain[i]);   //<---------Need To delay this!!

  }

}

I am working on simon game, and all I can get is reproduce all the chain at the same time.

alpox
@alpox
Mar 15 2016 09:13
setTimeout(() => gameChain[i], <somemilliseconds>);
@Abel1987
Pedro Abel Díaz Sánchez
@coderHook
Mar 15 2016 09:16

@alpox I tried this:

function computerGame(){
  gameChain = [4, 1, 1, 3, 4];

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

    setTimeOut(play(gameChain[i]), 1000);   //<---------Need To delay this!!

  }

}

But now It doesn't reproduce any sound.

Alex
@blurges
Mar 15 2016 09:16
hi all. i put in a //noprotect in front of code with an infinite loop, which crashed the exercise page. when i reload the page the code runs right away and page crashes before i can reset the code. :( is there a way to reset the code from outside the exercise page?
alpox
@alpox
Mar 15 2016 09:17
@Abel1987 yeah wait i wrote it wrong anyway. You just call it now you don't delay anything
@Abel1987 setTimeOut(() => play(gameChain[i]), 1000);
@Abel1987 the first argument of setTimeout has to be a function
Pedro Abel Díaz Sánchez
@coderHook
Mar 15 2016 09:20
That's why I was always getting an error there
but @alpox it doesn't work on my code. Here is the project in case you can have a look. I've been trying to fix this all night trying to do it in jquery with delay and with setTimeout, maybe is smt else I am doing wrong.
http://codepen.io/DiazPedroAbel/pen/GZjBWN?editors=0010
In order to check that all is going as I expected I want to reproduce all the chain when I puss start
alpox
@alpox
Mar 15 2016 09:21
@Abel1987 Does it produce any sound with a usual call? I cannot take a look now since i'm at university
Pedro Abel Díaz Sánchez
@coderHook
Mar 15 2016 09:23
@alpox np, Yes, It reproduce single sounds and If inside the loop I do not set the timeOut I get a sound that is like the sound of the whole chain but all at almost the same time.
alpox
@alpox
Mar 15 2016 09:23
@Abel1987 Sure because you delay all of them with 1 second
@Abel1987 you would have to use setTimeout(..., (i+1)*1000);
Pedro Abel Díaz Sánchez
@coderHook
Mar 15 2016 09:24
But right now, I am not getting it delayed.
alpox
@alpox
Mar 15 2016 09:24
@Abel1987 Maybe your browser doesnt support arrow functions
Pedro Abel Díaz Sánchez
@coderHook
Mar 15 2016 09:25
I am using Chrome, and I am working on codepen.
alpox
@alpox
Mar 15 2016 09:25
@Abel1987 try setTimeout(function() { play(gameChain[i]) }, (i+1)*1000);
JiaLe Guo
@gabygoole
Mar 15 2016 09:27
var myStr ="backslash tab \t tab \t carriage-return \t new-line"; // Change this line where am I wrong
alpox
@alpox
Mar 15 2016 09:28
@gabygoole You are not supposed to write the names of these characters
Pedro Abel Díaz Sánchez
@coderHook
Mar 15 2016 09:28
@alpox agg man... nothing, it is a nightmare :S
JiaLe Guo
@gabygoole
Mar 15 2016 09:29
@alpox the quetion is to use /t ?
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr @alpox
alpox
@alpox
Mar 15 2016 09:34
@Abel1987 I see the problem
@Abel1987 That is a nightmare because of callback style... its really arkward to understand for new programmers
@gabygoole Yeah they want you just to write down the equivalences of these words
@gabygoole first 2 in the sequence: \\ \t
Pedro Abel Díaz Sánchez
@coderHook
Mar 15 2016 09:37
@alpox and How can I do it right, or which resource I can read to learn how to do it?
JiaLe Guo
@gabygoole
Mar 15 2016 09:37
can you just give me the final answer, then I will know what you mean @alpox
alpox
@alpox
Mar 15 2016 09:37
@Abel1987
  var factory = function(i) {
    return function() {
      play(gameChain[i]);
    }
  }

  for(var i=0; i < gameChain.length; i++){
    setTimeout(factory(i), (i+1)*1000);   //<---------Need To delay this!!
  }
@gabygoole Thats not good for the understanding :-) i've shown you the first two in the sequence. that are Backslash tab
Javed
@JayBee007
Mar 15 2016 09:38
Hello Fellow Coders, am trying to solve the waypoint profile-lookup...but cant understand what is wrong with my code..
function lookUp(firstName, prop){
// Only change code below this line
  for(var i=0; i<contacts.length;i++ ){
    if(contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)){
        return contacts[i][prop];
    }else if(contacts[i].firstName !== firstName){
      return "No such contact";
    }else if(!contacts[i].hasOwnProperty(prop)){
      return "No such property";
    }
  }
// Only change code above this line
}
JiaLe Guo
@gabygoole
Mar 15 2016 09:39
what dose "first two" mean? @alpox
I am not a native speaker
alpox
@alpox
Mar 15 2016 09:39
@JayBee007 You return in every case in the for loop something. Means that your loop can never enter a second cycle
@gabygoole of your sequence:
backslash tab tab carriage-return new-lineThe first two (words)
Are in the solution:
\\ \t
Tyler Del Rosario
@TylerDelRosario
Mar 15 2016 09:40
lol just woke up. I litteraly dreamed of a solution to a problem I have, then I wake up. Get on the comp and find out that it doesnt work..
Javed
@JayBee007
Mar 15 2016 09:41
@alpox Thanks for answering..so how do I return than..and let the cycle complete..
CamperBot
@camperbot
Mar 15 2016 09:41
jaybee007 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star: 390 | @alpox | http://www.freecodecamp.com/alpox
alpox
@alpox
Mar 15 2016 09:41
@HTMLNoob :D too bad
@JayBee007 Take out the return "No such property" out of your for loop and try to make it work then.
sry wrong
"No such contact" is what i mean to take out
Since you only return that if you didnt find anything else before
So you loop over the elements and try to find what you need and if not (after the cycle) you return "No such contact" because you didnt find anything
JiaLe Guo
@gabygoole
Mar 15 2016 09:43
@alpox var myStr = "\ \t \t \r \n "; still wrong?
var myStr = "\ \t \t \r \n ";
alpox
@alpox
Mar 15 2016 09:44
@gabygoole I don't see it exactly because maybe try to do it with `at beginning and ` at the end (code format)
A backslash is itself for escaping the next character. So to write a backslash, you have to write two backslashes
And i'm not sure if you have to write them without spaces in between
Pedro Abel Díaz Sánchez
@coderHook
Mar 15 2016 09:57
@alpox That works perfecty! Thanks mate. Do you know why it wasn't working? I mean what the diference between calling setTimeout with the gameCahin inside or outside?
CamperBot
@camperbot
Mar 15 2016 09:57
abel1987 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star: 391 | @alpox | http://www.freecodecamp.com/alpox
alpox
@alpox
Mar 15 2016 09:58
@Abel1987 As you see i create another function which creates the function you pass to setTimeout.
@Abel1987 The problem was, that you used the variable i inside the function which gets called 1 second later. This is still the same variable but after 1 second it has changed to gameChain.length and is always out of range
Hari Adhikari
@harryac07
Mar 15 2016 09:59

I want to return all the matched integer from two integer array.
My code is

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

        return arr[i];

      }
    }
    //return false;
  }

But it is returning only one. It gives one matched then stops.
Could you guys give me some idea??

alpox
@alpox
Mar 15 2016 09:59
@Abel1987 To come around that, i produced the callback function with another function with input i. Doing that, the value of i gets copied on call and the later function call gets the new copied version of the variable
Brendan Kinahan
@BKinahan
Mar 15 2016 10:00
@harryac07 as soon as you return something, the function stops. try adding successful matches to a new empty array and then returning that outside of the loops
alpox
@alpox
Mar 15 2016 10:00
This message was deleted
Brendan Kinahan
@BKinahan
Mar 15 2016 10:00
@alpox hi :P
Pedro Abel Díaz Sánchez
@coderHook
Mar 15 2016 10:00
@alpox Ok, I see. I guess that as I want to illuminate every button that is pushed I am going to have to do the same.
Thanks a lot mate!
CamperBot
@camperbot
Mar 15 2016 10:00
abel1987 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:warning: abel1987 already gave alpox points
alpox
@alpox
Mar 15 2016 10:05
@BKinahan Yeah hi :D
@Abel1987 You will have to do a timout too then. But since you just call a simple timout without an input variable which can change you don't have to do the factory thing :-)
Francis
@Francis-p
Mar 15 2016 10:07
do we have to use split and join for chunky monkey?
alpox
@alpox
Mar 15 2016 10:08
@Francis-p I thought we are free to use whatever we want :D
Pedro Abel Díaz Sánchez
@coderHook
Mar 15 2016 10:08
also, I can change the property to button active every time I pass into the factory, right?
Francis
@Francis-p
Mar 15 2016 10:08
@alpox i am slightly clueless to the task. thats why thought of asking
alpox
@alpox
Mar 15 2016 10:09
@Abel1987 hmmh i'm not sure when the sound comes etc. You have to try out when the right moment is
@Francis-p I used push and splice
@Francis-p But you have to know what you're doing when splicing :D
Brendan Kinahan
@BKinahan
Mar 15 2016 10:10
@Francis-p my chunky monkey solution uses push and splice but you can do it any way you like :)
Stefan Gisi
@stgisi
Mar 15 2016 10:11
Has anyone completed the Exact Change challenge?
Francis
@Francis-p
Mar 15 2016 10:11
@alpox what i am splicing! i will try figure it out then.
Brendan Kinahan
@BKinahan
Mar 15 2016 10:11
actually join and split would have issues if any elements were longer than 1 character, probably... @Francis-p
Sanne
@sannek
Mar 15 2016 10:11
@stgisi Yup
Francis
@Francis-p
Mar 15 2016 10:12
@BKinahan that’s what i thought too.
Stefan Gisi
@stgisi
Mar 15 2016 10:12
@sannek Ummm...
@sannek One of the tests says that you need to return Insufficient funds when you have sufficient funds
Hari Adhikari
@harryac07
Mar 15 2016 10:12
@BKinahan how do i filter out those matched array and return unmatched?? Seems basic but need help :D
Stefan Gisi
@stgisi
Mar 15 2016 10:12
@sannek Did you see that?
Brendan Kinahan
@BKinahan
Mar 15 2016 10:13
@Francis-p in the test cases, they're all one character, but you'll probably learn more from imagining they could be any length :P
@harryac07 are you familiar with .filter()?
alpox
@alpox
Mar 15 2016 10:13
@harryac07 You could create a new array and push the elements to that. Or as @BKinahan suggests, use filter.
Sanne
@sannek
Mar 15 2016 10:13
@stgisi Yes, it returns insufficient funds because you can't make exact change
Stefan Gisi
@stgisi
Mar 15 2016 10:14
@sannek Got it! Thanks!!!
CamperBot
@camperbot
Mar 15 2016 10:14
stgisi sends brownie points to @sannek :sparkles: :thumbsup: :sparkles:
:star: 226 | @sannek | http://www.freecodecamp.com/sannek
Brendan Kinahan
@BKinahan
Mar 15 2016 10:14
@stgisi change due = 0.10, and you have one quarter (0.25) for example.
Stefan Gisi
@stgisi
Mar 15 2016 10:14
@BKinahan Roger that! Thanks
CamperBot
@camperbot
Mar 15 2016 10:14
stgisi sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1077 | @bkinahan | http://www.freecodecamp.com/bkinahan
Stefan Gisi
@stgisi
Mar 15 2016 10:14
back to work
Lloyd Consolacion
@cowboybebot
Mar 15 2016 10:18
working on the exact change, i have a pen for testing the code. can anyone help why i'm not getting the expected result? http://codepen.io/cowboybebot/pen/GZNjGG?editors=0012
alpox
@alpox
Mar 15 2016 10:20
@cowboybebot Still have to do that, sry ^^
Lloyd Consolacion
@cowboybebot
Mar 15 2016 10:21
@alpox still can take a look, it's not a working solution :)
alpox
@alpox
Mar 15 2016 10:22
@cowboybebot Well i'm at a statistics lesson :D i should focus a bit ;-)
Lloyd Consolacion
@cowboybebot
Mar 15 2016 10:22
gl!
alpox
@alpox
Mar 15 2016 10:23
@cowboybebot I guess you want to just always take the highest number which fits, but that actually doesnt always work like that
Sanne
@sannek
Mar 15 2016 10:24
@cowboybebot If you add console.log(change) at the end of your while loop, you'll see one of the problems is a lack of rounding.
That doesn't seem to explain why it won't loop again after adding the first quarter, but it's a start.
Lloyd Consolacion
@cowboybebot
Mar 15 2016 10:25
@sannek thanks for the hint!
CamperBot
@camperbot
Mar 15 2016 10:25
cowboybebot sends brownie points to @sannek :sparkles: :thumbsup: :sparkles:
:star: 227 | @sannek | http://www.freecodecamp.com/sannek
Sanne
@sannek
Mar 15 2016 10:26
(and have a look at the condition for exiting the while loop, because it exits too early)
Lloyd Consolacion
@cowboybebot
Mar 15 2016 10:27
there it is...that missing = lol
thanks @sannek
CamperBot
@camperbot
Mar 15 2016 10:27
cowboybebot sends brownie points to @sannek :sparkles: :thumbsup: :sparkles:
:warning: cowboybebot already gave sannek points
Lloyd Consolacion
@cowboybebot
Mar 15 2016 10:28
i hate that when that happens
alpox
@alpox
Mar 15 2016 10:29
I will do that soon i guess :D i'm kinda interested how long it will take me
But validate phone number was already bit lame :-/ i hope its more challenging
Francis
@Francis-p
Mar 15 2016 10:32
@BKinahan i have 1 missing steps. to remove what i have slice…. how do it do that?
function chunk(arr, size) {
  // Break it up.
  var newArr = [];
  for (var i = 1; i <= arr.length/size; i++) {

    var sliceArr = arr.slice(0, size);
    newArr.push(sliceArr);
  }
  return newArr;
}

chunk(["a", "b", "c", "d"], 2);
alpox
@alpox
Mar 15 2016 10:33
@Francis-p arr.length / slice? try it with subtraction
@Francis-p and slice doesnt remove anything
@Francis-p You always just take the first elements
Francis
@Francis-p
Mar 15 2016 10:35
@alpox yup. i realise that. maybe something like .remove()?
alpox
@alpox
Mar 15 2016 10:35
@Francis-p As we both suggested - splice.
@Francis-p But its quite dangerous to remove elements from an array in a for loop
Francis
@Francis-p
Mar 15 2016 10:37
@alpox omg! initially i thought u guys is asking me to slice and splice is a typo -.-
alpox
@alpox
Mar 15 2016 10:38
@Francis-p Hmmh my statistic lesson in which i sit says that the probability that we both make the same typo is not very big :D
Brendan Kinahan
@BKinahan
Mar 15 2016 10:39
@Francis-p might be my fault, I typo'd it in my first mention but then edited the message shortly after :P
Francis
@Francis-p
Mar 15 2016 10:39
@alpox my mistake pal. you do know that the lesson ask us to slice too :smile:
alpox
@alpox
Mar 15 2016 10:40
@Francis-p Don't know that :D but splice is in my eyes the better solution. I already thought that most of the suggestions of the lesson are useless xD
Francis
@Francis-p
Mar 15 2016 10:40
@BKinahan no worries. at least we got it sorted out :laughing:
Brendan Kinahan
@BKinahan
Mar 15 2016 10:40
oh yeah, the instructions explicitly mention push and slice.. huh
Michael Botes
@MichaelFF
Mar 15 2016 10:40
wiki Profile Lookup