These are chat archives for FreeCodeCamp/HelpJavaScript

6th
Mar 2016
Immad Hamid
@immad-hamid
Mar 06 2016 00:01
@bitgrower and tell you what this what I like about you and another guy here. Like you he also never answer straight. If you ask him what is i += 1, he would answer sky is blue and in the end I always find out that it was the right answer and this is why always try to ask questions to either you or @Takumar
Thanks to both of you for helping me getting better
CamperBot
@camperbot
Mar 06 2016 00:01
immad-hamid sends brownie points to @bitgrower and @takumar :sparkles: :thumbsup: :sparkles:
:warning: immad-hamid already gave takumar points
:warning: immad-hamid already gave bitgrower points
Ken Haduch
@khaduch
Mar 06 2016 00:02
@kalmont3 - you need to have a good understanding of exactly what is going on there. You need to mix the access of arrays and objects. It seems that this is a sticking point exercise for many people. You have an array of objects, so you access the objects within that array using square bracket notation. myPlants[0] access the first object, myPlants[1] the second, and if there were more, you would just continue. Then you get an object, so myPlants[0] accesses the first object. Each object has properties, so you want to access those either with myPlants[0].type (if you are explicitly accessing the property, you can use the dot notation.) or myPlants[0].list, which gives you the array with the property name list. Then you just access that like any other array - the second element of the list in the first object would be myPlants[0].list[1]. You will get an object that contains other objects in later problems, so you need to be able to apply the same kind of approach to get that one working. Pay close attention to the lessons in those sections, because it will help you get through those! I hope that helps - good luck!
Nopply
@StandB
Mar 06 2016 00:03
damn, nice explanation @khaduch
bitgrower
@bitgrower
Mar 06 2016 00:03
thanks @immad-hamid :)
CamperBot
@camperbot
Mar 06 2016 00:03
bitgrower sends brownie points to @immad-hamid :sparkles: :thumbsup: :sparkles:
:star: 261 | @immad-hamid | http://www.freecodecamp.com/immad-hamid
Aleksander Gębicki
@Takumar
Mar 06 2016 00:03
@immad-hamid yes, that is true that I try as good as I can describe it in English, to not answer directly.
But! Never say never ;-) Sometimes answer is so simple that it is easier to answer directly and explain why it works, then write puzzle words :-)
bitgrower
@bitgrower
Mar 06 2016 00:04
yeah ... so often when peeps see an array of objects, all they can see is the objects and not the array ...
@Takumar -- yeah, that's true -- especially if they've already made some concentrated effort and they are just missing something stupid (where's your return statement? <-- for instance)
Ken Haduch
@khaduch
Mar 06 2016 00:05
@StandB - thanks... the thing is that I see so many people get bogged down on this section, but there is a logical way to break it down. (I know that I was definitely not clear on this at first, because there are those subtleties like when you can use dot notation and when you have to use square bracket notation... it's a non-obvious concept that you really have to grasp!)
CamperBot
@camperbot
Mar 06 2016 00:05
khaduch sends brownie points to @standb :sparkles: :thumbsup: :sparkles:
:star: 278 | @standb | http://www.freecodecamp.com/standb
bitgrower @bitgrower 's rule ... if you're handed a data structure -- describe what it is ... and double-check to make sure that's what it is ... :)
Immad Hamid
@immad-hamid
Mar 06 2016 00:07
yea I face that all the time.:P
Nopply
@StandB
Mar 06 2016 00:07
Thanks @khaduch of course I have to return the favour now.
CamperBot
@camperbot
Mar 06 2016 00:07
standb sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 653 | @khaduch | http://www.freecodecamp.com/khaduch
Rami
@RNwebdk
Mar 06 2016 00:07
@khaduch well written :)
Aleksander Gębicki
@Takumar
Mar 06 2016 00:07
@bitgrower also sometimes when someone is working on the problem for a week it would be a torture to make her/him wait another 5 minutes for solution ;-)
Ken Haduch
@khaduch
Mar 06 2016 00:07
I like @bitgrower 's rule, too - be sure you know what you have, and double-check it!
bitgrower
@bitgrower
Mar 06 2016 00:08
thanks @khaduch ...
CamperBot
@camperbot
Mar 06 2016 00:08
bitgrower sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 654 | @khaduch | http://www.freecodecamp.com/khaduch
Immad Hamid
@immad-hamid
Mar 06 2016 00:09
@Takumar that's very true
Ken Haduch
@khaduch
Mar 06 2016 00:10
@Takumar - it is a fine line to tread, but you have to be able to deal with frustration in this stuff! I think that they need a couple more lessons on this JSON access with objects, arrays, and the like. It seems like a frequent sticking point for folks asking questions! But I know that things can get really complicated with stuff here, too - so that's where you try to see if outright answering the question is better at some point. It is a downfall of the chatroom format - you can't see or easily interact with how someone is doing!
bitgrower @bitgrower thinks it's on a case by case rule ... depends on where the person is at, what their state is like ...
bitgrower
@bitgrower
Mar 06 2016 00:11
@khaduch -- I'm doing some lessons over at codeschool this weekend on jquery & api -- and while I think I'm relatively comfortable with objects'n' all ... what they are doing with objects definitely takes things into another dimension ...
Aleksander Gębicki
@Takumar
Mar 06 2016 00:12
Okay, I have a nice challenge to solve now :sleeping:
Good night everybody! And dream JS ;-) with a lot of nice CSS of course ;-)
bitgrower
@bitgrower
Mar 06 2016 00:13
g'nite @Takumar ...
Nopply
@StandB
Mar 06 2016 00:13
gn @Takumar
Adam Yuhasz
@jayuhasz
Mar 06 2016 00:13
Hey guys, I'm on the "Arguments Optional" algorithm challenge, but I'm completely not sure of what's being asked of me. Is there another way of explaining the problem?
bitgrower
@bitgrower
Mar 06 2016 00:14
@jayuhasz -- this is going to sound so opposite -- but if you follow the instructions carefully, you can probably solve the problem without really understanding closures too much ... (but you should ... )
Ken Haduch
@khaduch
Mar 06 2016 00:14
playing around with these JSON objects in the javascript console is also a useful exercise - you can do a lot of experimentation quickly!
Jasmin Ibrahim
@jazzofett
Mar 06 2016 00:14
bye @Takumar !
bitgrower
@bitgrower
Mar 06 2016 00:14
oh oh oh do tell, @khaduch -- :)
Nopply
@StandB
Mar 06 2016 00:14

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.

bitgrower
@bitgrower
Mar 06 2016 00:15
I have to admit -- I got thrown by the term "jquery object" ... then I settled down a bit and understood ...
@StandB ... so ... the first part of the program, if you're handed 2 arguments ... that shouldn't be too hard to code, right ?
Adam Yuhasz
@jayuhasz
Mar 06 2016 00:16
Ok, I'll review the documentation there, is there anywhere that explains closures better that you're aware of?
Nopply
@StandB
Mar 06 2016 00:17
@bitgrower are u talking to me or @jayuhasz x)
Ken Haduch
@khaduch
Mar 06 2016 00:17
@bitgrower - I should probably do more of that, too - I get confused by more complicated things in jQuery, but I haven't used them often enough to get a really good foundation. I'm always visiting the jQuery site to read the API docs! :)
Adam Yuhasz
@jayuhasz
Mar 06 2016 00:17
specifically what's getting me is the closures, checking typeOf and adding two passed integers is simple enough.
bitgrower
@bitgrower
Mar 06 2016 00:17

Well .. I read a nice description in the other day in a paid book called effective javascript ... but the author really boiled it down to 3 things ...

@StandB -- responding to the description of the challenge ...

Nopply
@StandB
Mar 06 2016 00:18
Ok @bitgrower
bitgrower
@bitgrower
Mar 06 2016 00:18
So -- in general problem solving .. attack what you know how to do .. and then chip away at the parts you're uncertain of ...
get the stuff you know how to do off your plate so you can concentrate on the stuff that seems less uncertain ... then you can focus on what you don't know, and that alone ...

So ... let's take the hard case .. .that of one argument ... what does it say to do ?

"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."

Okay ... so, you know one thing right off -- you have to return a function. Do you know how to return a function?
...or, alternatively, could you write a function which uses a number and expects another one, and then adds them together ?
let me see if I can pull up the effective js ebook ...
Adam Yuhasz
@jayuhasz
Mar 06 2016 00:21
I guess my issue is, I'm not following specifically how closures work.
bitgrower
@bitgrower
Mar 06 2016 00:23
do you know what first class functions are ?
Vasily Sidorenko
@vsidoren
Mar 06 2016 00:23
function palindrome(str) {
  // Good luck!
  var compare = str.replace(/[,.\s]/g, '').toLowerCase();
  var reverseLetter = str.replace(/[,.\s]/g, '').toLowerCase().split('').reverse().join('');
  if (reverseLetter === compare) {
    return true;
  }
  else {
    return false;
  }
}


palindrome("0_0 (: /-\ :) 0-0");
this last test fails in the palindrome challenge, a console.log returns 0-0):-/:(0_0 so it seems to be dropping one of the / not sure why its doing that
Adam Yuhasz
@jayuhasz
Mar 06 2016 00:24
passing functions as arguments to other functions, yeah?
bitgrower
@bitgrower
Mar 06 2016 00:24
well, basically the idea that variables can contain functions ...
Adam Yuhasz
@jayuhasz
Mar 06 2016 00:26
ahh, crap I think I got it, let me try something
Jasmin Ibrahim
@jazzofett
Mar 06 2016 00:27
can someone help me figure out what im doing wrong in a regexp search?
bitgrower
@bitgrower
Mar 06 2016 00:27
okay ... closures:
  1. functions can refer to variables defined in outer scopes
  2. closures can outlive the function that creates them
  3. closures internally store references to their outer variables, and can both read & update their stored variables ...
Nopply
@StandB
Mar 06 2016 00:28
whats up @jazzofett
Jasmin Ibrahim
@jazzofett
Mar 06 2016 00:28
so I created a function called areYouPlayingBanjo(name) and if a name starts with "S" or "s", I want the output to be "name, you are playing banjo!"
bitgrower
@bitgrower
Mar 06 2016 00:28
basically, in a closure, a function can refer to a variable that, like it says in #1, was defined in an outer scope ...
Jasmin Ibrahim
@jazzofett
Mar 06 2016 00:28
function areYouPlayingBanjo(name) {
var firstLetter;
for (var i = 1; i < name.length; i++){
firstLetter = name[i];
}
if(firstLetter.match(/S/i)){return name + " plays banjo!"}
else {return name + " does not play banjo!"}
}
areYouPlayingBanjo("Scott");
bitgrower
@bitgrower
Mar 06 2016 00:29
ah .. okay, @jayuhasz ... let me know ...
Jasmin Ibrahim
@jazzofett
Mar 06 2016 00:29
unfortunately its not working for any S names. am I doing something wrong in the if statement?
Ken Haduch
@khaduch
Mar 06 2016 00:29
@jazzofett - you have a few errors in your function...
Walk through the method you are using to get the first letter of the name... that's a starting point.
Jasmin Ibrahim
@jazzofett
Mar 06 2016 00:30
@khaduch ahhh I know its super messy, Im trying to think it out in my head
Nopply
@StandB
Mar 06 2016 00:30
Are u also sure you need a for loop @jazzofett
Jasmin Ibrahim
@jazzofett
Mar 06 2016 00:31
so I figured I needed a for loop to go thru the length of a name, and if the first letter matches to S, then I wanted the string "name, plays banjo!" to return
bitgrower
@bitgrower
Mar 06 2016 00:31

... @jazzofett -- you don't get any prizes for doing it in your head ... and using pencil and paper and sketching it out, writing it out, will help you think more clearly about it ...

50% of problem solving is defining the problem ... :)

Jasmin Ibrahim
@jazzofett
Mar 06 2016 00:31
Is there a better method to go through a string?
Ken Haduch
@khaduch
Mar 06 2016 00:31
@jazzofett - remember that array index starts at something other than 1
also, you don't really need to do that if you are familiar with regular expressions.
there is an easy way to match the first letter of a string using regex!
Jasmin Ibrahim
@jazzofett
Mar 06 2016 00:32
im not too familiar with regex :(
bitgrower
@bitgrower
Mar 06 2016 00:32
^^^^!!!!
regexone.com <--- awesome tutorial ...
Jasmin Ibrahim
@jazzofett
Mar 06 2016 00:33
thank you!! ill check it out right now and see if i can figure it out
thank you @bitgrower !
CamperBot
@camperbot
Mar 06 2016 00:33
jazzofett sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Mar 06 2016 00:33
if you want to have a set of extremely powerful tools -- become good friends with regex ... what you can do with them is nothing short of amazing ...
CamperBot
@camperbot
Mar 06 2016 00:33
:star: 736 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 06 2016 00:33
yw @jazzofett
Ken Haduch
@khaduch
Mar 06 2016 00:33
@jazzofett - well then look at regexone.com, and you should see what you are getting in your firstletter variable with your current code. Or use the javascript console and experiment! You can do it basically using the technique you are using, just have to fix the way you are getting the first letter... :)
bitgrower
@bitgrower
Mar 06 2016 00:35
also there are some really good (and short) video challenges on some basic computer/programming topics ... really worth spending the short amount of time to go thru them ...
Jasmin Ibrahim
@jazzofett
Mar 06 2016 00:35
im thinking of using a split to break up the name into an array...i'll experiment and get back to you guys if i dont get it
Ken Haduch
@khaduch
Mar 06 2016 00:35
@jazzofett - good luck! we'll be here... ;)
Jasmin Ibrahim
@jazzofett
Mar 06 2016 00:35
oooo feel free to link me! i definitely need practice on the basic concepts. i want to go through as many problems as i can
Ken Haduch
@khaduch
Mar 06 2016 00:36

@jazzofett

oooo feel free to link me! i definitely need practice on the basic concepts. i want to go through as many problems as i can

Very smart! Very good approach...

Adam Yuhasz
@jayuhasz
Mar 06 2016 00:36
I realized I was spelling "arguments" as "arguements" so that was some of the issue. Thank you @bitgrower for explaining closures a bit. I feel this is something I'm going to need to study up on to really understand
CamperBot
@camperbot
Mar 06 2016 00:36
jayuhasz sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 737 | @bitgrower | http://www.freecodecamp.com/bitgrower
Jasmin Ibrahim
@jazzofett
Mar 06 2016 00:37
i feel like every problem i approach involves yak shaving hahaha! as soon as i dont know one thing, its a dozen more things i need to learn
bitgrower
@bitgrower
Mar 06 2016 00:38
well .. there are always more things to learn ... that part doesn't stop ... but getting to the point where you feel like you have a sufficient number of tools to express yourself in code ... that's where the fun begins ...
Adam Yuhasz
@jayuhasz
Mar 06 2016 00:38
one of my worries is learning how to express code outside of the codepen/freecodecamp ecosystem
Ken Haduch
@khaduch
Mar 06 2016 00:38
@jayuhasz - here's a link. http://javascriptissexy.com/understand-javascript-closures-with-ease/ not sure if it will be helpful more than what you know now?
Adam Yuhasz
@jayuhasz
Mar 06 2016 00:39
@khaduch thanks, I'll give that a read
CamperBot
@camperbot
Mar 06 2016 00:39
jayuhasz sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 655 | @khaduch | http://www.freecodecamp.com/khaduch
bitgrower
@bitgrower
Mar 06 2016 00:40

oooo feel free to link me! i definitely need practice on the basic concepts. i want to go through as many problems as i can

@jazzofett -- they are in the curriculum of FCC -- down toward the bottom ... "video Challenges" ... right above "full Stack Certification"

Jasmin Ibrahim
@jazzofett
Mar 06 2016 00:40
@jayuhasz I get worried about that too. I found an awesome textbook that starts you off on how to write javascript in a natural environment like if youre starting a new job http://www.veidas.lt/wp-content/files_flutter/1331098013JavaScriptTheWebTechnologiesSeries5thEdition.pdf
Adam Yuhasz
@jayuhasz
Mar 06 2016 00:40
@jazzofett awesome! looks like I have a lot of reading to do tonight
Jasmin Ibrahim
@jazzofett
Mar 06 2016 00:41
@bitgrower Ohhh yes those videos!! I know FCC changed so much in the past month with new challenges and resources. thanks for the reminder!
CamperBot
@camperbot
Mar 06 2016 00:41
jazzofett sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: jazzofett already gave bitgrower points
Adam Yuhasz
@jayuhasz
Mar 06 2016 00:41
that reminds me, I need to go back and do the tribute page as they added it when I was in the middle of things.
Alex N.
@N0bl3
Mar 06 2016 00:54
@jayuhasz you can check eloquentjavascript.net which is a known source for JS :)
bitgrower
@bitgrower
Mar 06 2016 00:55
yeah there are tons of free javascript books (good ones) ... in fact I think there's a list on reddit of 100 free js books ... if it's not there, a google search should unearth it ... and, let's not forget these...
help js
CamperBot
@camperbot
Mar 06 2016 00:55

:point_right: challenge accessing nested arrays in json [wiki]

Challenge: Accessing Nested Arrays in JSON

As we have seen in earlier examples, JSON objects can contain both nested objects and nested arrays. Similar to accessing nested objects, Array bracket notation can be chained to access nested arrays.

Here is an example of how to access a nested array:

```js
var ourPets = {
"cats": [
"Meowzer",
"Fluffy",
"Kit-Cat"
],
"dogs": [
"Spot",
"Bowser",
"Frankie"
]
};
ourPets.cats1; // "Fluffy"
:pencil: read more about challenge accessing nested arrays in json on the FCC Wiki

bitgrower
@bitgrower
Mar 06 2016 00:56
oops
wiki js resources
Adam Yuhasz
@jayuhasz
Mar 06 2016 01:01
thank you!
William
@apswak
Mar 06 2016 01:03

How can I flatten an array?
I need to turn

[[1],2,3,4,5,6,7,8,9]

into

[1,2,3,4,5,6,7,8,9]
bitgrower
@bitgrower
Mar 06 2016 01:04
Array.isArray might be helpful ... as well as recursion ...
Kyle Morton
@kmorton1988
Mar 06 2016 01:07
I'm having a hard time trargeting specific values in a nested array
array.pop[0] = array[0];
?
@kreitzo ^
bitgrower
@bitgrower
Mar 06 2016 01:09
do you know how to target an element in a 1 d array ?
Kyle Morton
@kmorton1988
Mar 06 2016 01:09
@bitgrower who are you talking to?
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:09
@kmorton1988 array.pop()
Parentheses
Not brackets
Kyle Morton
@kmorton1988
Mar 06 2016 01:10
right! cause method.
my bad.
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:10
:D
bitgrower
@bitgrower
Mar 06 2016 01:10
@kmorton1988 -- that expresson doesn't make any sense ... what are you trying to do (in words) ... @kmorton1988 -- you
um ... pop is a function, requires parens, not brackets
Kyle Morton
@kmorton1988
Mar 06 2016 01:10
that was an answer to @kreitzo but I guess it's wrong.
right, but my problem is a bit more involved. let me type out the code.
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
that's a nested array, correctg?
bitgrower
@bitgrower
Mar 06 2016 01:11
well ... @kmorton1988 -- what, exactly are you trying to accomplish in this one line of code:
array.pop[0] = array[0];
Kyle Morton
@kmorton1988
Mar 06 2016 01:12
turn
bitgrower
@bitgrower
Mar 06 2016 01:12
@kmorton1988 -- no
it's not
what is the first character after the = sign ?
Kyle Morton
@kmorton1988
Mar 06 2016 01:12
[[1],2,3,4,5,6,7]

into

```
[1,2,3,4,5,6,7]

Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:12
Hmmm...I'm not there yet
But could you pop and unshift?
Kyle Morton
@kmorton1988
Mar 06 2016 01:13
I was thinking you could call the pop method, and capture that back into the 0 slot in the array with the =
bitgrower
@bitgrower
Mar 06 2016 01:13
okay ... well if you want to use pop ... then you need to put the destination variable on the left side ...
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:13
Ermmmm
shift and unshift
Kyle Morton
@kmorton1988
Mar 06 2016 01:13
oh you're right.
bitgrower
@bitgrower
Mar 06 2016 01:13
myVar = array.pop();
Kyle Morton
@kmorton1988
Mar 06 2016 01:14
so it'd be
array[0] = array.pop(array[0])
?
bitgrower @bitgrower is trying to twist her brain cells to figure out what that would do ...
Kyle Morton
@kmorton1988
Mar 06 2016 01:15
assuming:
var array = [[1],2,3,4,5,6,7]
would the above variable declaration turn it into
```
[1,2,3,4,5,6,7]
?
bitgrower
@bitgrower
Mar 06 2016 01:16
no
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:16
I think it would be shift
Not pop
That was my bad
pop takes it off the end
Kyle Morton
@kmorton1988
Mar 06 2016 01:16
oooooooh you're right.
bitgrower
@bitgrower
Mar 06 2016 01:16
check it out here ... pythontutor.com/javascript.html
Kyle Morton
@kmorton1988
Mar 06 2016 01:17
hmm. ok, well that's not even really the problem I'm trying to figure out right now.
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:17
So if I were you I would do array.shift() and then array.unshift(1)
Kyle Morton
@kmorton1988
Mar 06 2016 01:17
this isn't an array, then? cause it starts with curly brackets?
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:17
I mean, just a thought
Valeriav521
@Valeriav521
Mar 06 2016 01:17

// Setup
var a;
var b = 2;

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

help
CamperBot
@camperbot
Mar 06 2016 01:17

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

Basic Commands:

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

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Valeriav521
@Valeriav521
Mar 06 2016 01:17
pls
Jasmin Ibrahim
@jazzofett
Mar 06 2016 01:17
good news guys, I figured out that banjo problem. sigh feelsgood.jpg
bitgrower
@bitgrower
Mar 06 2016 01:17
@kmorton1988 -- objects start with curly braces, arrays start with brackets
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:17
@Valeriav521 a =7, b = a
bitgrower
@bitgrower
Mar 06 2016 01:18
YAY!!!! are you regex expert now, @jazzofett ?
Kyle Morton
@kmorton1988
Mar 06 2016 01:18
ok, I'll have to brush up on calling prop/value things.
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:18
It's an array within an array?
Jasmin Ibrahim
@jazzofett
Mar 06 2016 01:18
using pythontutor.com for JS is super helpful to visualize whats going on
bitgrower
@bitgrower
Mar 06 2016 01:18
basically ... you need to address each element within the array and then stick it in a new array ... :)
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:18
@Valeriav521 You don't need to declare 5 twice
Valeriav521
@Valeriav521
Mar 06 2016 01:19
okay thanks @kristinavandoren
CamperBot
@camperbot
Mar 06 2016 01:19
valeriav521 sends brownie points to @kristinavandoren :sparkles: :thumbsup: :sparkles:
:star: 226 | @kristinavandoren | http://www.freecodecamp.com/kristinavandoren
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:19
If it's an array within an array than if it's the first element of the first array it would be array[0][0]
My pleasure, @Valeriav521 !
bitgrower
@bitgrower
Mar 06 2016 01:19
which challenge is it, @Valeriav521 ?
@kristinavandoren -- exactly ...
Valeriav521
@Valeriav521
Mar 06 2016 01:19
basic JAVAscrpt @bitgrower
Jasmin Ibrahim
@jazzofett
Mar 06 2016 01:19
@bitgrower actually, no! I am VERY confused on how to use regex. Im going thru that website regexone and idk, its not clicking for me. gonna look up tutorials on youtube
Valeriav521
@Valeriav521
Mar 06 2016 01:20
thanks for the tip @kristinavandoren
CamperBot
@camperbot
Mar 06 2016 01:20
valeriav521 sends brownie points to @kristinavandoren :sparkles: :thumbsup: :sparkles:
:warning: valeriav521 already gave kristinavandoren points
bitgrower
@bitgrower
Mar 06 2016 01:21
okay ... sorry ... let me know what resources you find helpful in your understanding of regexs ... basically ... regexes are a way of describing patterns so you can look for pattern matches ...
so ... it uses a LOT of symbols ...
Jasmin Ibrahim
@jazzofett
Mar 06 2016 01:22
thats the confusing part for me! I'll have to keep practicing until im familiar with the symbols and how the brackets work and using backlash to exclude certain symbols, etc
bitgrower
@bitgrower
Mar 06 2016 01:22
need the actual challenge name, @Valeriav521 ...
kalmont3
@kalmont3
Mar 06 2016 01:23
@khaduch thanks
CamperBot
@camperbot
Mar 06 2016 01:23
kalmont3 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 656 | @khaduch | http://www.freecodecamp.com/khaduch
bitgrower
@bitgrower
Mar 06 2016 01:23
if I recall correctly, you need to set a to a number and then you need to set b to a
kalmont3
@kalmont3
Mar 06 2016 01:25
=]
Valeriav521
@Valeriav521
Mar 06 2016 01:25
@bitgrower what do you mean?
sorry I moved on
bitgrower
@bitgrower
Mar 06 2016 01:26
you solved your problem ?
Valeriav521
@Valeriav521
Mar 06 2016 01:26
yes Thank you @bitgrower
CamperBot
@camperbot
Mar 06 2016 01:26
valeriav521 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 738 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 06 2016 01:26
super !!!
Valeriav521
@Valeriav521
Mar 06 2016 01:27
Thanks @bitgrower
CamperBot
@camperbot
Mar 06 2016 01:27
valeriav521 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: valeriav521 already gave bitgrower points
bitgrower
@bitgrower
Mar 06 2016 01:27
keep up the great work! :)
Valeriav521
@Valeriav521
Mar 06 2016 01:29
thanks
AnyOne Wanna chat ?
William
@apswak
Mar 06 2016 01:31
String.prototype.digit = function() {
  return typeof this === "number";
};
Anyone know why that isn't working for checking if input is a digit?
Valeriav521
@Valeriav521
Mar 06 2016 01:33
Sorry NO
bitgrower
@bitgrower
Mar 06 2016 01:35
@kreitzo -- "this" is defined within the scope of the function ... and usually is used as this.<something> ... what are you trying to do ?
Valeriav521
@Valeriav521
Mar 06 2016 01:35

var myVar = 87;

// Only change code below this line
i++;

@bitgrower can you help me?
bitgrower
@bitgrower
Mar 06 2016 01:35
what are you trying to do, @Valeriav521 ?
Valeriav521
@Valeriav521
Mar 06 2016 01:36

Instructions
Change the code to use the ++ operator on myVar.

Run tests (ctrl + enter)
Reset Help Bug

ReferenceError: i is not defined

myVar should equal 88
Use the ++ operator
Do not change code above the line

Increment a number with Javasccipt
@bitgrower
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:37
@Valeriav521 Can you paste your code?
Valeriav521
@Valeriav521
Mar 06 2016 01:38

var myVar = 87;

// Only change code below this line
i++;

bitgrower
@bitgrower
Mar 06 2016 01:38
okay ... you can increment a number in javascript in 3 (well, 4) basic ways ...
i = i +1;
i += 1;
++i;
i++;
Robert Richey
@0x0936
Mar 06 2016 01:38
increment myVar not i
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:38
Yeah, just myVar++
i is a placeholder
Valeriav521
@Valeriav521
Mar 06 2016 01:38
Ohh thank you @kristinavandoren @0x0936
CamperBot
@camperbot
Mar 06 2016 01:38
valeriav521 sends brownie points to @kristinavandoren and @0x0936 :sparkles: :thumbsup: :sparkles:
:warning: valeriav521 already gave kristinavandoren points
:star: 1216 | @0x0936 | http://www.freecodecamp.com/0x0936
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:38
You need to increment the variables you have
No worries, @Valeriav521 !
bitgrower
@bitgrower
Mar 06 2016 01:38
thanks guys ... I wasn't quite able to see what was going on ...
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:39
@bitgrower Yeah, unless they post the code and I look at the exercise I usually have no clue what they're asking :)
golfguy1984
@golfguy1984
Mar 06 2016 01:39
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case 1:
      return "alpha";
      break;
    case 2:
      return "beta";
      break;
    case 3:
      return "gamma";
      break;
    case 4:
      return "delta";
      break;
  }


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

// Change this value to test
myTest(4);
Help! im getting “unreachable break” why? any help is appreciated
Maddah Anass
@unlimiworks
Mar 06 2016 01:40
This message was deleted
bitgrower
@bitgrower
Mar 06 2016 01:40
@golfguy1984 -- first -- don't panic ! :)
which line are you getting the message on ... and is it a warning, or an actual error ?
Maddah Anass
@unlimiworks
Mar 06 2016 01:41
@golfguy1984 What bitgrower said :) I think you're not processing all possible outcomes. Try adding a default case
Oh, nvm
bitgrower
@bitgrower
Mar 06 2016 01:41
I don't think this exercise has the default case ...
Maddah Anass
@unlimiworks
Mar 06 2016 01:41
If you're using return, you don't need break
golfguy1984
@golfguy1984
Mar 06 2016 01:42
@bitgrower @UnlimiWorks the lesson says i need at leas 3 breaks
Maddah Anass
@unlimiworks
Mar 06 2016 01:42
basically, return gets you out of the switch, you never reach the break instruction because of that
bitgrower
@bitgrower
Mar 06 2016 01:42
right -- which was why I was asking about warnings vs. errors ... that sounds like the editor is warning you, but you can ignore it most of the time ...
Maddah Anass
@unlimiworks
Mar 06 2016 01:43
What is the waypoint you're doing ?
golfguy1984
@golfguy1984
Mar 06 2016 01:43
@bitgrower i think im getting a warning
Valeriav521
@Valeriav521
Mar 06 2016 01:43
@bitgrower chat with me !
Claire Walker
@kjarva
Mar 06 2016 01:43

can anyone tell me why this doesn't work? I have gotten it to work using [] notation but I want to know why it doesn't work with . notation - any ideas?
'''
// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
var lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank"
};
var result = lookup.val;
// Only change code above this line
return result;
}

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

CamperBot
@camperbot
Mar 06 2016 01:43
:bulb: to format code use backticks! ``` more info
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:43
@golfguy1984 It's answer = "alpha
NOT return!
answer =
switch(val) {
case 1:
answer = "alpha";
break;
case 2:
answer = "beta";
break;
case 3:
answer = "gamma";
break;
case 4:
answer = "delta";
break;
Maddah Anass
@unlimiworks
Mar 06 2016 01:44
@kjarva try using ``` instead of '''
CamperBot
@camperbot
Mar 06 2016 01:44
:bulb: to format code use backticks! ``` more info
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:44
@kjarva Do you want me to paste my code?
Claire Walker
@kjarva
Mar 06 2016 01:44
can anyone tell me why this doesn't work? I have gotten it to work using [] notation but I want to know why it doesn't work with . notation - any ideas?
// Setup
function phoneticLookup(val) {
var result = "";
// Only change code below this line
var lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank"
};
var result = lookup.val;
// Only change code above this line
return result;
}
// Change this value to test
phoneticLookup("charlie");
Chris Saunders
@canadianchris
Mar 06 2016 01:45
I'm relatively new to JS but I think you always need [] with variables
golfguy1984
@golfguy1984
Mar 06 2016 01:45
@kristinavandoren thanks
CamperBot
@camperbot
Mar 06 2016 01:45
golfguy1984 sends brownie points to @kristinavandoren :sparkles: :thumbsup: :sparkles:
:star: 227 | @kristinavandoren | http://www.freecodecamp.com/kristinavandoren
bitgrower
@bitgrower
Mar 06 2016 01:45
@kjarva -- you can only use .val if it's a property name ...
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:45
@kjarva what's the name of the exercise?
bitgrower
@bitgrower
Mar 06 2016 01:45
...since it is a value containing a key, you need to use the bracket notation
Claire Walker
@kjarva
Mar 06 2016 01:46
the fall down point is the var result statement. I got it to work but I want to know why the dot notation didn't work as with js objects apparently I can use either. @UnlimiWorks thanks for the backtick help ;)
CamperBot
@camperbot
Mar 06 2016 01:46
kjarva sends brownie points to @unlimiworks :sparkles: :thumbsup: :sparkles:
:star: 314 | @unlimiworks | http://www.freecodecamp.com/unlimiworks
Claire Walker
@kjarva
Mar 06 2016 01:46
@kristinavandoren it's Using Objects for Lookups
bitgrower
@bitgrower
Mar 06 2016 01:46
@kjarva -- because where you can use dot notation and where you can use bracket notation are not completely interchangeable ...
Brandon Lee
@brandonlee781
Mar 06 2016 01:47
Why does this code throw a TypeError when the if statement is there, but it doesn't when the if statement is removed?
function largestOfFour(arr) {
  // You can do this!
  var biggest;
  for (var i = 0;i < arr.length;i++) {
    var total = arr[i].reduce(function(previousValue,currentValue){
      return previousValue + currentValue;
    });
    var total2 = arr[i + 1].reduce(function(previousValue,currentValue){
      return previousValue + currentValue;
    });
    if (total > total2) {
      biggest = arr[i];
    } else {
      biggest = arr[i+1];
    }

  }
  return biggest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Claire Walker
@kjarva
Mar 06 2016 01:47
hmmm... I'll need to go lookup that info then because FCC seemed to suggest I can use either/or anytime
Rami
@RNwebdk
Mar 06 2016 01:47
This message was deleted
bitgrower
@bitgrower
Mar 06 2016 01:48
@kjarva -- no you can't ... there are specific places where you can use dot notation, and other places where you MUST use bracket notation ...
Maddah Anass
@unlimiworks
Mar 06 2016 01:48
This message was deleted
My bad
Your code doesn't work because the dot notation doesn't support variables
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:49
@UnlimiWorks OMG, that explains so much!
bitgrower
@bitgrower
Mar 06 2016 01:49
I can have a key "house keys" ... but I cannot use that in a dot notation expression ... I must use bracket notation ...
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 01:49
Thanks, @UnlimiWorks
CamperBot
@camperbot
Mar 06 2016 01:49
kristinavandoren sends brownie points to @unlimiworks :sparkles: :thumbsup: :sparkles:
:star: 315 | @unlimiworks | http://www.freecodecamp.com/unlimiworks
Claire Walker
@kjarva
Mar 06 2016 01:50
got it - I didn't know that :D I read it as I can use it interchangeable whenever - that makes things clearer and at least now I know the reason it worked one way and not the other ;) thanks @UnlimiWorks
CamperBot
@camperbot
Mar 06 2016 01:50
kjarva sends brownie points to @unlimiworks :sparkles: :thumbsup: :sparkles:
:warning: kjarva already gave unlimiworks points
Rami
@RNwebdk
Mar 06 2016 01:50
@kjarva you can't use dot notation on a argument, it's not possible
Maddah Anass
@unlimiworks
Mar 06 2016 01:50
the only way to get the variable's value is through the bracket notation , object[variable] will actually replace variable by its value, whereas object.variable will look for the variable property
You're welcome :)
Chris Saunders
@canadianchris
Mar 06 2016 01:50
@kjarva I had the same confusion going through those exercises
bitgrower
@bitgrower
Mar 06 2016 01:51
it is ... very confusing ...
Chris Saunders
@canadianchris
Mar 06 2016 01:51
thanks @UnlimiWorks that's a concise explanation, straightens things out in my mind
CamperBot
@camperbot
Mar 06 2016 01:51
canadianchris sends brownie points to @unlimiworks :sparkles: :thumbsup: :sparkles:
:star: 316 | @unlimiworks | http://www.freecodecamp.com/unlimiworks
Claire Walker
@kjarva
Mar 06 2016 01:51
glad it's not just me ;) @canadianchris
bitgrower
@bitgrower
Mar 06 2016 01:51
especially when you use brackets for indexing into arrays as well ...
sqibly
@sqibly
Mar 06 2016 01:53

function sumAll(arr) {
arr.sort();
var newArr = [];
var sum = 0;
//for loop that makes an array with all number from 1 to 2
for(var i=arr[0]; i<=arr1; i++) {
newArr.push(i);
}

//for loop that adds the values of the newArr together
for(var ii=0; ii<newArr.length; ii++) {
sum+=newArr[ii];
}
return sum;
}

sumAll([5, 10]); //this returns 0

Claire Walker
@kjarva
Mar 06 2016 01:54
I think I'm going to have to go through the whole objects section again, possibly several times before I really 'get it'
sqibly
@sqibly
Mar 06 2016 01:54
this code returns 0
bitgrower
@bitgrower
Mar 06 2016 01:54
yeah, it can take some doing, @kjarva ... but just keep at it ... it gets easier ...
@sqibly -- can you format your code, please ?
explain format
CamperBot
@camperbot
Mar 06 2016 01:55

: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

Claire Walker
@kjarva
Mar 06 2016 01:55
ooh I just found my backtick key - I've been wondering why my code didn't post right for 2 days lol
bitgrower
@bitgrower
Mar 06 2016 01:55
YAY !!!!
Claire Walker
@kjarva
Mar 06 2016 01:56
this is a backtick thing
:D
bitgrower
@bitgrower
Mar 06 2016 01:56
:)
Valeriav521
@Valeriav521
Mar 06 2016 01:56
anyONe wanna chat just bored?
Daniel J. Bray
@kekkerslawl
Mar 06 2016 01:57
@kjarva haha!
Maddah Anass
@unlimiworks
Mar 06 2016 01:58
@Valeriav521 Aren't we not here ? :)
Join the main chat too
Jasmin Ibrahim
@jazzofett
Mar 06 2016 01:58
fun fact: the opposite of sparkle is darkle
bitgrower
@bitgrower
Mar 06 2016 01:58
function sumAll(arr) {
  arr.sort();
  var newArr = [];
  var sum = 0;
  //for loop that makes an array with all number from 1 to 2
  for(var i=arr[0]; i<=arr[1]; i++) {
    newArr.push(i);
  }

  //for loop that adds the values of the newArr together
  for(var ii=0; ii<newArr.length; ii++) {
    sum+=newArr[ii];
  }
  return sum;
}

sumAll([5, 10]); //this returns 0
^^^ @sqibly 's code
Valeriav521
@Valeriav521
Mar 06 2016 01:59
@UnlimiWorks what main chat?
Maddah Anass
@unlimiworks
Mar 06 2016 02:00
Freecodecamp/Freecodecamp
Ken Haduch
@khaduch
Mar 06 2016 02:01
@jazzofett - thanks for posting that - I saw someone mentioning pythontutor.com just within the last couple days, I haven't used it, but it looks like a great learning tool!
CamperBot
@camperbot
Mar 06 2016 02:01
khaduch sends brownie points to @jazzofett :sparkles: :thumbsup: :sparkles:
:star: 244 | @jazzofett | http://www.freecodecamp.com/jazzofett
bitgrower
@bitgrower
Mar 06 2016 02:01
@sqibly -- you need to use arr.sort correctly ...
Ken Haduch
@khaduch
Mar 06 2016 02:01

@jazzofett

fun fact: the opposite of sparkle is darkle

Never knew that! :)

Maddah Anass
@unlimiworks
Mar 06 2016 02:03
Don't forget about codeschool's free access this weekend guys
Chris Saunders
@canadianchris
Mar 06 2016 02:05
Objects and arrays baking my noodle too. Something isn't quite right with the property checking of this, I can't wrap my head around what's going on
function lookUp(firstName, prop){
// Only change code below this line
  for (i = 0; i < contacts.length; i++){
    if (contacts[i].firstName == firstName) {
      if (contacts[i].hasOwnProperty(prop)){
        return contacts[i][prop];
      } else {
        return "No such property";
      }
    } else {
      return "No such contact";
    }
  }


// Only change code above this line
}
from the "Profile Lookup" exercise
my logic seems ok, it's the references that are whackadoodle. any suggestions would be greatly appreciated
I think it's just the return statement because the negative test for property works
Maddah Anass
@unlimiworks
Mar 06 2016 02:09
Well the logic sure seems okay
Is it returning an error ?
Chris Saunders
@canadianchris
Mar 06 2016 02:10
contacts[i] = the object i'm looking at, shouldn't contacts[i][prop] be the right way to reference the property of the object?
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:10
@canadianchris You can't have two else statements
Chris Saunders
@canadianchris
Mar 06 2016 02:10
@UnlimiWorks it doesn't return properties when it matches
Maddah Anass
@unlimiworks
Mar 06 2016 02:10
Well yes. I don't see anything 'wrong' there
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:10
You can have else if
as many as you like
But only one else
I haven't checked the rest but I can see that right away
Chris Saunders
@canadianchris
Mar 06 2016 02:11
@kristinavandoren those are else for separate if loops
bitgrower
@bitgrower
Mar 06 2016 02:11
@canadianchris -- the first test case is "Kristian", "lastName" -- you go thru the loop and you first look at the "Akira" object ... so, the first fil fils ... then it falls thru the else which is "no such contact" ...
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:11
Ahhh, you're right, my bad :) @canadianchris
bitgrower
@bitgrower
Mar 06 2016 02:11
you need to loop thru the rest of the objects ... you're returning too early ...
Chris Saunders
@canadianchris
Mar 06 2016 02:11
@kristinavandoren all those brackets :)
Maddah Anass
@unlimiworks
Mar 06 2016 02:12
@canadianchris I have the exact same code as you. which worked ages ago
@canadianchris It now gives me an error saying that it fails on 'sherlock', 'likes', which it doesn't
Chris Saunders
@canadianchris
Mar 06 2016 02:13
@bitgrower but doesn't my for statement cover that?
bitgrower
@bitgrower
Mar 06 2016 02:13
not if you do a return ...
when you return, you exit ... you be done
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:13
Can you open it in JS Bin and see what's actually going on?
Chris Saunders
@canadianchris
Mar 06 2016 02:13
@bitgrower ah.
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:13
go to jsbin.com
and make sure to click on console and output
bitgrower
@bitgrower
Mar 06 2016 02:14
or you can see a cool visualization at pythontutor.com/javascript.html
Chris Saunders
@canadianchris
Mar 06 2016 02:14
@bitgrower thanks. I should be dumping results to a variable and then return further out
CamperBot
@camperbot
Mar 06 2016 02:14
canadianchris sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 739 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 06 2016 02:15
well .. if you iterate thru the loop and don't find a match ... then you drop out of the loop and then you can return "no such contact" ... :)
Chris Saunders
@canadianchris
Mar 06 2016 02:16
ya that's why the 2 last checks work. no Bob, and Akira is the first one in the list
ok, back to the drawing board. :)
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:16
@canadianchris Seriously, try it in jsbin
That really helped me today when I was trying to figure out what I was doing
They don't have a console on FCC
Maddah Anass
@unlimiworks
Mar 06 2016 02:17
@bitgrower is right. I overlooked your else. Your return should be outside of the loop
This is my code from when i first did the project :
function lookUp(firstName, prop){
  // Only change code below this line
  for(var i = 0; i < contacts.length; i++) {
    if(firstName === contacts[i].firstName) {
      if(contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
      }
      return "No such property";
    } 
  }
  return "No such contact";
  // Only change code above this line
}

// Change these values to test your function
lookUp("Sherlock", "likes");
@canadianchris
This code now gives me an error on sherlock, which is certainly a bug
Also, it's worth noting that when dealing with returns, you should avoid using else statements as it's only added complexity
Chris Saunders
@canadianchris
Mar 06 2016 02:20
@UnlimiWorks I took out my else statements and it works
now I'm trying to sort that out in my head
bitgrower
@bitgrower
Mar 06 2016 02:22
@UnlimiWorks -- they changed the spelling in the data structure ... they had "intriuging"
and fixed it ...
Maddah Anass
@unlimiworks
Mar 06 2016 02:22
@bitgrower I see. You're certainly miticulous. Thanks ! :)
CamperBot
@camperbot
Mar 06 2016 02:22
unlimiworks sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 740 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 06 2016 02:22
LOL, no @UnlimiWorks -- I ran into the same problem ... :)
Will
@willvlad
Mar 06 2016 02:23
Doesn't seem to work on mine :(
bitgrower
@bitgrower
Mar 06 2016 02:23
working code that stopped working ... like over night ...
Maddah Anass
@unlimiworks
Mar 06 2016 02:23
Glad it was just some simple mispell fix. I saw way worse in production :)
Chris Saunders
@canadianchris
Mar 06 2016 02:23
so maybe I'm obtuse - but @bitgrower you were suggesting a slightly different approach.. I'm using the same logic but instead of putting those returns inside else statements, they return when I'm finished the conditional
bitgrower
@bitgrower
Mar 06 2016 02:24
I'm sorry @willvlad ...
@canadianchris -- that's working too hard ... when you find a match, there's no real reason not to return immediately, you've found what you were looking for ... the problem is only when you are not finding what you are looking for ... :)
@UnlimiWorks' code works beautifully ... and I would say 90% of the people who do this challenge, solve it in essentially the same way ... :)
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:28
Blargh, can someone help with Accessing Nested Arrays in JSON?
Will
@willvlad
Mar 06 2016 02:28
I found the error ! the last return has to be OUTSIDE the for loop!
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:28
I am having way too much trouble with JSON
var secondTree = myPlants.type.list1; /
There are brackets around the 1 but they are not showing up
Will
@willvlad
Mar 06 2016 02:28
i was putting it INSIDE hence it didn't do the first three tests...
bitgrower
@bitgrower
Mar 06 2016 02:29
@kristinavandoren -- describe the data structure you are given ... in words ... :)
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:30
@bitgrower Fair enough! Basically, I need to access "pine"

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

// Only change code below this line

var secondTree = myPlants.type.list1; // Change this line

bitgrower
@bitgrower
Mar 06 2016 02:30
but what kind of data structure is myPlants ?
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:31
@bitgrower Don't understand your question
bitgrower
@bitgrower
Mar 06 2016 02:31
(hint: the name of the challenge gives it away ... )
CamperBot
@camperbot
Mar 06 2016 02:31
Set a bonfire to talk about with bonfire name
Moisés Man
@moigithub
Mar 06 2016 02:31
myPlants is an Array with 2 objects... so to access first element / or second.. u need to use indices like myArr[0] or myArr1.. that will give u an object... once u have the object.... u can use bracket OR dot notation to access the property value
@kristinavandoren
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:31
@moigithub So even though it's in brackets it's just considered an array?
I think that was my confusion
Moisés Man
@moigithub
Mar 06 2016 02:31
yep...
Chris Saunders
@canadianchris
Mar 06 2016 02:31
an array of objects
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:32
Thanks, @moigithub ! Let me play with it for a bit and see if it works
CamperBot
@camperbot
Mar 06 2016 02:32
kristinavandoren sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 728 | @moigithub | http://www.freecodecamp.com/moigithub
bitgrower
@bitgrower
Mar 06 2016 02:32
because it is in brackets it IS an array ... the other bracket notation is used within js for addressing parts of objects ..
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:32
(that's what she said!)
bitgrower
@bitgrower
Mar 06 2016 02:32
...but if it's a data structure ... a bracket means array
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:32
Got it
Thanks, @bitgrower !
CamperBot
@camperbot
Mar 06 2016 02:32
kristinavandoren sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 741 | @bitgrower | http://www.freecodecamp.com/bitgrower
Moisés Man
@moigithub
Mar 06 2016 02:32
there are a video whre says.. whatever in square brackets === Array..
and curly brackets === Object
bitgrower
@bitgrower
Mar 06 2016 02:32
yw ~
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:33
Let me fiddle and come back
bitgrower
@bitgrower
Mar 06 2016 02:33
yeah, we were just having an extensive discussion about bracket & dot notation addressing for objects, @moigithub -- which is why I didn't use that simple declaration ... :)
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:33
Okay, nevermind, I'm still stuck
I tried to shortcut and put myPlants1
But that didn't work
Chuck Adams
@chuckadams
Mar 06 2016 02:34
this is why i talk about foo.bar vs foo[bar] notation rather than confusing people about which context of brackets you're talking about
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:34
Argh!
I have two brackets there
myPlants 1
Okay, I give up
Chuck Adams
@chuckadams
Mar 06 2016 02:35
use backticks in gitter to quote stuff
`like so`
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:35
@chuckadams Good call
Chris Saunders
@canadianchris
Mar 06 2016 02:35
no giving up allowed :)
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:35
And I figured it out
bitgrower
@bitgrower
Mar 06 2016 02:35
right ... well, just because you got the first part of the addressing right doesn't mean the rest of the code is right, @kristinavandoren ... but ... you definitely need to use brackets to address which of the 2 array elements in myPlants you want to access ...
Kristina Van Doren-Shulkin
@kristinavandoren
Mar 06 2016 02:35
Right, I just looked at it again and slapped my forehead
Thanks for all your help, fellas!
Maddah Anass
@unlimiworks
Mar 06 2016 02:41
TIme to finish that wiki viewer. Later folks
Chris Saunders
@canadianchris
Mar 06 2016 02:46
have a great night @UnlimiWorks
or... morning/afternoon.. wherever you may be!
MD Alsaffar
@Cyberistic
Mar 06 2016 03:21
Need help with the Record Collection challenge, here's my code:
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
Moisés Man
@moigithub
Mar 06 2016 03:25
"space" is not the same as "empty" @Cyberistic
MD Alsaffar
@Cyberistic
Mar 06 2016 03:26
@moigithub Ahh! figured that out. Thanks anyways.
CamperBot
@camperbot
Mar 06 2016 03:26
cyberistic sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 729 | @moigithub | http://www.freecodecamp.com/moigithub
Raghuram
@Raghuram1994
Mar 06 2016 03:29
var Car=new Car;
myCar.nickname="nick";
//???
whats wrong with dis code?
bigbeno37
@bigbeno37
Mar 06 2016 03:32
Hey guys, anyone doing the profile lookup challenge?
Raghuram
@Raghuram1994
Mar 06 2016 03:32
i completed it @bigbeno37
Ken Haduch
@khaduch
Mar 06 2016 03:32

@Cyberistic - just a point of note - you could simplify your test conditions a little and make the code look less complicated. Something like this, just factoring out common things from your code and eliminating unnecessary additional tests:

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

Not sure if I balanced out all of the parens and got proper indentation, but it cleans up your code a bit. Just something that you can watch out for as you go along.

bigbeno37
@bigbeno37
Mar 06 2016 03:33
@Raghuram1994 I need some help in figuring out the logic behind it
Ken Haduch
@khaduch
Mar 06 2016 03:34
@Raghuram1994 - you are declaring a variable var Car, but then trying to use myCar to access it... that might be a problem, at least one of them.
Raghuram
@Raghuram1994
Mar 06 2016 03:35
@bigbeno37 message me brotha
andreyorlov33
@andreyorlov33
Mar 06 2016 03:44

@tvdeleon24

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

}

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

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

DJ
@qualitymanifest
Mar 06 2016 03:46
@andreyorlov33 no need for the parenthesis. answer = "apple";
tia
@tvdeleon24
Mar 06 2016 03:49
@andreyorlov33 what he said.
Alfred Thomas Torres
@sup3rpr0xy
Mar 06 2016 03:51
I created an instance of an object constructor (Sorry if I messed up with the terms. Correct me if I did). It asked me to change some property/values but it’s not taking it. Can you please check my code? Thank you.
Nevermind.. I figured it out...
Thank you
facepalm
Ruzanna
@ruzzyx
Mar 06 2016 03:55

I've been staring at this for an hour... Record Collection challenge:

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

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

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

} else if (collection[id][prop][value] === "") {
  delete collection[id][prop];
}


  return collection;
}

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

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

For the given id in collection:

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

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

If value is blank, delete that prop.

Always return the entire collection object."

Please help?
Console says that the TypeError: Cannot read property 'ABBA' of undefined.
CamperBot
@camperbot
Mar 06 2016 03:58
no wiki entry for: with httpwwwfreecodecampcomchallengesescape-sequences-in-strings
Alfred Thomas Torres
@sup3rpr0xy
Mar 06 2016 04:00

Hi @GPerk, you just type in the code that it needs. So for backslash tab…. You look at the code table, Backslash equals to \ then tab equals to \t so the first two would be

\ \t

then continue on with the rest

Jasmin Ibrahim
@jazzofett
Mar 06 2016 04:00
is there something wrong with my regex here to remove a space between a string?
function underToCamel(underName) {
var removeScore = underName.replace("_", " ",/\s+/g,'');
/ here we get "first name"/
return removeScore;
}
oh wait maybe trim would be better?
nvm sorry, still gotta think this problem through
bigbeno37
@bigbeno37
Mar 06 2016 04:10
Thanks @Raghuram1994
CamperBot
@camperbot
Mar 06 2016 04:10
bigbeno37 sends brownie points to @raghuram1994 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for raghuram1994
Ken Haduch
@khaduch
Mar 06 2016 04:21
@ruzzyx - hello there.
@ruzzyx - :point_up: March 5, 2016 10:55 PM -the first thing that you want to do is check the values of the parameters that you are receiving as function arguments. You are looking at values within the objects, that is not where you start with this one. If the value coming into the function is not blank, then you do (whatever), either something with the 'tracks' or add another property to the object... does that clarify things for you?
Raghuram
@Raghuram1994
Mar 06 2016 04:27
var myCar=new Car();
var myCar; //how to give nickname to my car
Ken Haduch
@khaduch
Mar 06 2016 04:27
@ruzzyx - I can see where you might have slightly misinterpreted what they were asking for, but if you re-read the problem statement, they kind of give the simple tests that they want you to do on the function arguments.
@Raghuram1994 - which exercise is this? One thing that you have is declaring a var myCar, and you do not want to use the var keyword the second time that you are trying to use that value. But if I know which exercise it is, then I can give more help? It might be as simple as writing myCar.nickname = "wheelie"; ???
bitgrower
@bitgrower
Mar 06 2016 04:31
@khaduch -- think it's something about private properties
Raghuram
@Raghuram1994
Mar 06 2016 04:31
Make Instances of Objects with a Constructor Function @khaduch
bitgrower
@bitgrower
Mar 06 2016 04:31
oh wait, maybe not ..
Raghuram
@Raghuram1994
Mar 06 2016 04:32
cleared it thankyou @khaduch
bitgrower
@bitgrower
Mar 06 2016 04:33
one of the great scary oddities of js ... you can just create a new property for an object name using it ... poor typists might have a whole plethora of properties ... unintended ...
Ken Haduch
@khaduch
Mar 06 2016 04:33
@Raghuram1994 - that's good - you're welcome
@bitgrower - you said it! :scream:
JackeL
@jackel27
Mar 06 2016 04:36

We need people to work on CodeSchool with us! If you want to help us PM me Trying to reach top of leaderboards to represent the FCC account :)

bitgrower
@bitgrower
Mar 06 2016 04:37
hahahahaha ... how does that work @jackel27 ?
JackeL
@jackel27
Mar 06 2016 04:37
@bitgrower Wes setup an FCC account for it lol. so far me and Akira plowing through the courses. You can log in at the same time.
@bitgrower but, we definitely could use more people :)
bitgrower
@bitgrower
Mar 06 2016 04:41
ah ... well, already started on my own ...
you should get @AkiraLaine to live stream it ... :)
JackeL
@jackel27
Mar 06 2016 04:42
@bitgrower he is lol
bitgrower
@bitgrower
Mar 06 2016 04:43
ahhhh .... well, see ... you should get people to go over twitch.tv ... and then have a banner going across to recruit more peeps to join in !!!!
I've been in most the most active channels all day and this is the first I've heard!!!
JackeL
@jackel27
Mar 06 2016 04:44
LiveCoding channel?
Yeah, kinda late notice lol. Wes setup account about 6 hours ago or so
Septimus*
Richard Corbett
@reacorbett
Mar 06 2016 04:50
hello everyone!! :)
Wheepwhoop
@Wheepwhoop
Mar 06 2016 04:51
Hey so I was just reading through another Javascript book
"mixu's node book"
bitgrower
@bitgrower
Mar 06 2016 04:52
hi there @reacorbett ..
is it about node.js ?
Wheepwhoop
@Wheepwhoop
Mar 06 2016 04:52
and I keep finding little pieces in the example code that look like this var messages = ["testing"];
var clients = [];
wait
whoa
the mark up went away
Never mind!
Thanks!
Richard Corbett
@reacorbett
Mar 06 2016 04:54
one more of Basic Algorithm Scripting challenges to go.
Jasmin Ibrahim
@jazzofett
Mar 06 2016 04:56
When reversing a number , is there a better approach than converting the number to a string to utilize the split, reverse, join function?
bitgrower
@bitgrower
Mar 06 2016 04:56
awesome saucce
Jasmin Ibrahim
@jazzofett
Mar 06 2016 04:56
I feel like converting numbers to an array of strings is pretty messy, like so : function reverse(s) {
return s.toString().split('').reverse('').join('');
}
reverse(191820);
bitgrower
@bitgrower
Mar 06 2016 04:57
"reversing a number" .. you mean take 123456789 and turn it into 987654321 ?
Jasmin Ibrahim
@jazzofett
Mar 06 2016 04:57
yes exactly
bitgrower
@bitgrower
Mar 06 2016 04:57
on first glance it seems reasonable ...
Jasmin Ibrahim
@jazzofett
Mar 06 2016 04:57
the code works but do you guys think theres a better way?
bitgrower
@bitgrower
Mar 06 2016 04:58
I don't dwell too much in the world of "better way" unless it's obvious to me the current way needs serious improvement ...
sorry .. I'm not very fun that way ...
Jasmin Ibrahim
@jazzofett
Mar 06 2016 04:58
hahaha youre right, i should be happy im getting it to work in the first place
bitgrower
@bitgrower
Mar 06 2016 04:59
feel free to ask in the CodeReview room ...
Jasmin Ibrahim
@jazzofett
Mar 06 2016 04:59
ooo great idea! thanks for the tip!
bitgrower
@bitgrower
Mar 06 2016 04:59
help rooms
CamperBot
@camperbot
Mar 06 2016 04:59

:point_right: help rooms [wiki]

Help Rooms

Choose the right room for your question!
:pencil: read more about help rooms on the FCC Wiki
Raghuram
@Raghuram1994
Mar 06 2016 05:00
can anyone explain this concept
Make Object Properties Private
Nazim
@nazimkazim
Mar 06 2016 05:00
how to solve this algorithm? What is wrong?
function where(collection, source) {
  var arr = [];
  var ne;

  // What's in a name?
  for (var i=0; i<collection.length; i++) {
    ne= collection[i];
    if (Object.keys(ne)===Object.keys(source)) {

     arr.push(collection[i]);

    }

  }

  return arr;
}

where([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
bitgrower
@bitgrower
Mar 06 2016 05:01
where art thou ?
Nazim
@nazimkazim
Mar 06 2016 05:01
yes
bitgrower
@bitgrower
Mar 06 2016 05:02
so you have a source object (which can be of 1 or more keys) and you need to look thru the array of objects (the first argument, aka "collection") -- to find any that match, and create an array of them, right ?
first, you probably want to make an array out of the Object.keys(source) ... because you'll need the array of keys to look at each of the objects within the collection array to see if there is a match ...
I would also highly recommend commenting your code so it's obvious what you are trying to do ...
if (Object.keys(ne)===Object.keys(source)) { <--- this is comparing an array to an array ... I don't even know what this actually would do in js ...
Nazim
@nazimkazim
Mar 06 2016 05:07
This message was deleted
@bitgrower Thanks for tips i will try to fix it
bitgrower
@bitgrower
Mar 06 2016 05:09
...but, at the very least, your Object.keys(source) is going to result in a static array of keys ... so you don't need to keep doing Object.keys(source) every time through the array .. even if it made sense ...
you are wlecome @nazimkazim
1ety
@1ety
Mar 06 2016 05:09
why is the following object's property has quotation mark where the second doesn't?
khaduch @khaduch - leaving the campground for the night... have a good time everyone! Good luck with the programming challenges...
bitgrower @bitgrower kicks @camperbot ... give me my brownie point ...
1ety
@1ety
Mar 06 2016 05:09
var car = {
  "wheels":4,
  "engines":1,
  "seats":5
};
bitgrower
@bitgrower
Mar 06 2016 05:10
g'nite @khaduch -- where are you located ?
1ety
@1ety
Mar 06 2016 05:10
var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
delete person.age;
bitgrower
@bitgrower
Mar 06 2016 05:10
@1ety -- you can use either ...
AudioGen
@AudioGen
Mar 06 2016 05:10
anyone want to help me ?
bitgrower
@bitgrower
Mar 06 2016 05:11
maybe ... whaddya need ? :) ;)
Nazim
@nazimkazim
Mar 06 2016 05:11
@bitgrower Ok
AudioGen
@AudioGen
Mar 06 2016 05:11
lol
ummm.... well coding wise, I need help with this exercise
bitgrower
@bitgrower
Mar 06 2016 05:11
LOL ...
1ety
@1ety
Mar 06 2016 05:12
@bitgrower , would it be the same?
bitgrower
@bitgrower
Mar 06 2016 05:12
that's probably about the only thing I could help you with, @AudioGen ... so ... which exercise, & you know the drill ... front & center with your code, mister ...
AudioGen
@AudioGen
Mar 06 2016 05:12
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
bitgrower
@bitgrower
Mar 06 2016 05:12
@1ety ... for strings, yeah, for numbers ... not sure ...
AudioGen
@AudioGen
Mar 06 2016 05:13
Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

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

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

If value is blank, delete that prop.
bitgrower
@bitgrower
Mar 06 2016 05:13
@1ety -- there are some exercises that talk about it, I think -- the ones dealing with JSON objects ...
okay @AudioGen ... tell me what your data structure is made up of ...
1ety
@1ety
Mar 06 2016 05:14
However, the property once written with quotation mark and the other time with out
AudioGen
@AudioGen
Mar 06 2016 05:14
id, prop, and value?
so number, string and string
bitgrower
@bitgrower
Mar 06 2016 05:15

@1ety -- sorry, I don't understand what you mean ...

@AudioGen ... things like objects, arrays, arrays of objects, etc ...

AudioGen
@AudioGen
Mar 06 2016 05:15
oh
Nested objects and likes property consists of an array
or excuse me the tracks property
bitgrower
@bitgrower
Mar 06 2016 05:16
k ... so .. you have 1 object which contains a bunch of key value pairs ...
Pradeep CE
@cepradeep
Mar 06 2016 05:16

Hi everyone, I need help with Symmetric Difference from Advanced Algorithm Scripting. My code satisfies the "should return" constraints, but fails the "should contain only x elements" constraint.

function sym(args) {
  var argss = [].concat.apply(arguments, arguments).splice(1);
  var perargs = Array.prototype.slice.call(arguments);

  if (perargs.length >= 3) {
      var newargs = perargs.slice(1);
      var t = sym(perargs[0], sym.apply(this, newargs)); 
      console.log(t.length);
      return t;
    }
  else {
    return (argss.filter(function(val) {
    var tmp = perargs.reduce(function(p, c) {
     return c.indexOf(val) >= 0 ? p + 1 : p;
    }, 0);
    return tmp < 2;
  })).sort(function(a, b) { return a - b; });
  }
}

sym([1, 2, 3], [5, 2, 1, 4]);

Any ideas?

1ety
@1ety
Mar 06 2016 05:17
in this object the property come with "";
bitgrower
@bitgrower
Mar 06 2016 05:17
only that it's a challenging one, @pradeepce
not really sure @1ety ...
1ety
@1ety
Mar 06 2016 05:18
This message was deleted
bitgrower
@bitgrower
Mar 06 2016 05:19
@AudioGen -- which challenge is this ?
AudioGen
@AudioGen
Mar 06 2016 05:20
@bitgrower http://www.freecodecamp.com/challenges/record-collection#?solution=%2F%2F%20Setup%0Avar%20collection%20%3D%20{%0A%20%20%20%202548%3A%20{%0A%20%20%20%20%20%20album%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20tracks%3A%20[%20%0A%20%20%20%20%20%20%20%20%22Let%20It%20Rock%22%2C%20%0A%20%20%20%20%20%20%20%20%22You%20Give%20Love%20a%20Bad%20Name%22%20%0A%20%20%20%20%20%20]%0A%20%20%20%20}%2C%0A%20%20%20%202468%3A%20{%0A%20%20%20%20%20%20album%3A%20%221999%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20tracks%3A%20[%20%0A%20%20%20%20%20%20%20%20%221999%22%2C%20%0A%20%20%20%20%20%20%20%20%22Little%20Red%20Corvette%22%20%0A%20%20%20%20%20%20]%0A%20%20%20%20}%2C%0A%20%20%20%201245%3A%20{%0A%20%20%20%20%20%20artist%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20tracks%3A%20[%20]%0A%20%20%20%20}%2C%0A%20%20%20%205439%3A%20{%0A%20%20%20%20%20%20album%3A%20%22ABBA%20Gold%22%0A%20%20%20%20}%0A}%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse%28JSON.stringify%28collection%29%29%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20update%28id%2C%20prop%2C%20value%29%20{%0Aif%28%28collection.value%20!%3D%3D%20%22%22%29%26%26%28collection.prop%20!%3D%3D%20%22tracks%22%29%29{%0A%20%20collection.prop%20%3D%20value%3B%0A}%0A%20%20else%20if%28collection.prop%20%3D%3D%3D%20%22tracks%22%29%0A%20%20return%20collection%3B%0A}%0A%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0Aupdate%285439%2C%20%22artist%22%2C%20%22ABBA%22%29%3B%0A%0A
sorry
Pradeep CE
@cepradeep
Mar 06 2016 05:20
@bitgrower lol :P
I've been at this one for over four days now, and this must be, like, the 100th revision of this code... Am I missing an obvious bug in my code?
Ken Haduch
@khaduch
Mar 06 2016 05:22
@bitgrower Massachusetts is wherever i am. You?
bitgrower
@bitgrower
Mar 06 2016 05:22
sorry, pradeece -- I solved the problem for 2 arrays ... and someone helped me with expanding it to handle more than 2 ... but I've not sat down to understand the code .... and I'm not very good with array.reduce, alas ...
@khaduch -- I'm a Valley Girl ... A Silicon Valley Girl ... :)
So, the wonderful thing about identifying what this data structure is, @AudioGen -- is because we can just ask if there is a key within the object and we don't have to do any iterating ... it just gets accessed ...
some people would analogize this to something called associative arrays ... :)
each of your keys has a value of an object ...
for us, id is the key we are looking for ...
Pradeep CE
@cepradeep
Mar 06 2016 05:26
@bitgrower Ah! Anyways, thank you :)
CamperBot
@camperbot
Mar 06 2016 05:26
pradeepce sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 743 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 06 2016 05:26
so ... happily, we can just address an item within this data structure starting with collection[id]
Richard Corbett
@reacorbett
Mar 06 2016 05:27
this ceaser cioher is a booger.
bitgrower
@bitgrower
Mar 06 2016 05:27
that now accesses the "value" of the key value pair ... the object ...
Richard Corbett
@reacorbett
Mar 06 2016 05:27
cipher*
AudioGen
@AudioGen
Mar 06 2016 05:28
@bitgrower I'm not getting it ;(
bitgrower
@bitgrower
Mar 06 2016 05:28

LOL ...

@reacorbett ... you need to do 3 basic things ...

  1. convert characters to character codes
  2. apply the cipher algo, as appropriate
  3. return the character codes back to characters...
@AudioGen .... yeah, I know, I'm taking the long & winding road ...
...but it's important to understand that a js object is made up of key value pairs ... and then the value can be anything ... an object,, an array, some mixture of them ... etc...
so your first constraint is to check whether the value argument you've been passed is empty ... because you just have to delete the property in that case ...
can you write code to check if the argument "value" is blank ?
Richard Corbett
@reacorbett
Mar 06 2016 05:30
i am guessing charCodeAt() will do #1. and fromCharCode() will do #3. @bitgrower
bitgrower
@bitgrower
Mar 06 2016 05:31
pretty much @reacorbett ... :)
AudioGen
@AudioGen
Mar 06 2016 05:31
if(collection.id.value !== "") { }'
or it would be === if we want to check if it is blank
bitgrower
@bitgrower
Mar 06 2016 05:32
@audioGen -- you are just checking an incoming parameter ...
not even looking at the object yet ...
AudioGen
@AudioGen
Mar 06 2016 05:32
oh
Alfred Thomas Torres
@sup3rpr0xy
Mar 06 2016 05:32

I don’t understand the exercise Bonfire: Meet Bonfire - http://www.freecodecamp.com/challenges/get-set-for-our-algorithm-challenges

Is it just an intro? I’m assuming it’s just an intro

Richard Corbett
@reacorbett
Mar 06 2016 05:33
will charCodeAt() will only accept numbers?
AudioGen
@AudioGen
Mar 06 2016 05:33
so if(value ===""){}
bitgrower
@bitgrower
Mar 06 2016 05:33
@sup3rpr0xy -- yes, it's just an intro
@AudioGen -- yup
Richard Corbett
@reacorbett
Mar 06 2016 05:33
nm
Alfred Thomas Torres
@sup3rpr0xy
Mar 06 2016 05:33
ah ok, thank you so much. I was about to open dev tools to check the code. Thanks again
bitgrower
@bitgrower
Mar 06 2016 05:33
LOL ... you bet .. have a good day ...
Alfred Thomas Torres
@sup3rpr0xy
Mar 06 2016 05:34
Thanks @bitgrower
CamperBot
@camperbot
Mar 06 2016 05:34
sup3rpr0xy sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 744 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 06 2016 05:34
yw
AudioGen
@AudioGen
Mar 06 2016 05:35
@bitgrower How do I set the value for the prop?
]\
bitgrower
@bitgrower
Mar 06 2016 05:36

so ... the simplest (?) case is to just see if you can code the first constraint of the challenge ...

if the value is blank, then you will use the id and the prop parameters to delete that property ...

LOL ... the names they've chosen for the parameters make this tricky to talk about ... LOL ...
start with the first case, @AudioGen ...
which I'm saying is ... if the value is blank, delete the property (prop === key)
AudioGen
@AudioGen
Mar 06 2016 05:41
Not getting it
bitgrower
@bitgrower
Mar 06 2016 05:42

basically, you are going to access a part of this object and do something with it ...

either

  1. you delete the property (id, in this case) -- which deletes the entire key:value pair
  2. you push the value onto the end of the tracks array
    or
  3. you update or set the value for the given property (which is,, as I've said, is "id" ...
yeah .. .the problem has a bit to do with the terminology used with objects ...
the "id" parameter carries a number which "should be" a property of the object ...
AudioGen
@AudioGen
Mar 06 2016 05:44
how do I update or set the value?
bitgrower
@bitgrower
Mar 06 2016 05:44
in order to look at the object which is associated with a particular id, you need to address it ...
AudioGen
@AudioGen
Mar 06 2016 05:45
right now I got value = id.prop;
bitgrower
@bitgrower
Mar 06 2016 05:45
value is a parameter you have been passed, don't create a local variable with that name ... :)
you can't use dot notation unless you are using the property name specifically ...
AudioGen
@AudioGen
Mar 06 2016 05:46
oh ok
bitgrower
@bitgrower
Mar 06 2016 05:47
so ... if you have an id, how would you point to the property in this object with that particular id ... how would you address it ?
bitgrower @bitgrower can understand why people have trouble with this ... it's a bit hard to explain ... for instance ... there are objects within the object ... and THOSE objects have properties as well ... so you have 2 levels (at least!) of objects ...
bitgrower
@bitgrower
Mar 06 2016 05:50
in this particular case ... both id and prop are actually properties of an object ... id is a property of the "outer"object, and "prop" is a property of the "inner" objects ...
I'm sorry ... I'm not doing a very good job here of explaining this (less practice on this one ... )
AudioGen
@AudioGen
Mar 06 2016 05:55
@bitgrower Yah I'm close here, I only have one callback incorrect, I'm just not getting it
lyrehs
@lyrehs
Mar 06 2016 05:56

Hiya! I understand the concept here but I can't seem to make a happy solution. This is the challenge: Understand String Immutability.
In Javascript, String values are immutable, which means that they cannot be altered once created.

For example, the following code:

var myStr = "Bob";
myStr[0] = "J";
cannot change the value of myStr to "Job", because the contents of myStr cannot be altered. Note that this does not mean that myStr cannot be changed, just that the individual characters of a string literal cannot be changed. The only way to change myStr would be to assign it with a new string, like this:

var myStr = "Bob";
myStr = "Job";
Instructions
Correct the assignment to myStr to achieve the desired effect.

// Setup
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "J"; // Fix Me

AudioGen
@AudioGen
Mar 06 2016 05:58
you have to rewrite the variable name and assign it the correct string
Andrew Irwin
@someonefromcanada38
Mar 06 2016 05:59
Can anyone recommend some kind of development platform where I can test my javascript code? I'm finding that it is difficult to do the larger projects without being able to use console logs and other debugging tools to find mistakes I may have made.
bitgrower
@bitgrower
Mar 06 2016 05:59
have you tried codepen.io ?
lyrehs
@lyrehs
Mar 06 2016 05:59
@AudioGen in response to me? Yes, that is just what I thought but that did not seem to go. I will try again again.
bitgrower
@bitgrower
Mar 06 2016 05:59
you can use console.log on the challenges ...
Andrew Irwin
@someonefromcanada38
Mar 06 2016 06:00
I attempt to use console.logs on the challenges but nothing shows up in my logs
bitgrower
@bitgrower
Mar 06 2016 06:01
I think there are some video challenges way down at the bottom of the map, just above the full stack certification stuff, which talks about using the chrome developer tools ... I use console.log all the time on the challenges, so I'm not sure what might be going wrong for you ...
Markus Kiili
@Masd925
Mar 06 2016 06:01
@someonefromcanada38 Are you using developer tools console on your browser?
Andrew Irwin
@someonefromcanada38
Mar 06 2016 06:01
nope
AudioGen
@AudioGen
Mar 06 2016 06:01
@lyrehs do you want to post your code?
Markus Kiili
@Masd925
Mar 06 2016 06:02
@someonefromcanada38 On Firefox and Chrome, you can press F12
Andrew Irwin
@someonefromcanada38
Mar 06 2016 06:02
sweet I can see some logs now, Thanks!
lyrehs
@lyrehs
Mar 06 2016 06:03

@AudioGen sure. Thanks.

// Setup
var myStr = "Jello World";

// Only change code below this line

var myStr = "Hello World";
myStr[0] = "H";

CamperBot
@camperbot
Mar 06 2016 06:03
lyrehs sends brownie points to @audiogen :sparkles: :thumbsup: :sparkles:
:star: 278 | @audiogen | http://www.freecodecamp.com/audiogen
lyrehs
@lyrehs
Mar 06 2016 06:04
yes I do
Markus Kiili
@Masd925
Mar 06 2016 06:04
@someonefromcanada38 repl.it site is also a good place to test JS code. Shows arrays and error values better than FCC.
asaki444
@asaki444
Mar 06 2016 06:04
function titleCase(str) {
  var string = str.split(' ');
  var a = ' ';
  for (var i = 0; i < string.length;i++){
    a = string[i].charAt(0).toUpperCase() + string[i].substring(1).toLowercase();
  }
  return a;

}

titleCase("I'm a little tea pot");
I am working on the titleCaseSentence
it keepsgiving me error messages
that i dont have a method for the lowercase fucntion
HELP!
CamperBot
@camperbot
Mar 06 2016 06:05

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

Basic Commands:

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

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Markus Kiili
@Masd925
Mar 06 2016 06:05
@asaki444 You are overwriting the result string over and over again.
AudioGen
@AudioGen
Mar 06 2016 06:06
@lyrehs delete the line with the undeclared variable and index
asaki444
@asaki444
Mar 06 2016 06:06
@Masd925 by writing the string[i] twice?
AudioGen
@AudioGen
Mar 06 2016 06:06
@AudioGen probably don't even need to type in var again btw
lyrehs
@lyrehs
Mar 06 2016 06:08
thanks@AudioGen that did it. Seemed like it should like it should have been more complicated then that!
AudioGen
@AudioGen
Mar 06 2016 06:09
yep
Markus Kiili
@Masd925
Mar 06 2016 06:09
@asaki444 It is toLowerCase() with capital C
Richard Lee
@kaashin
Mar 06 2016 06:09
Algoraithm Friendly Date Ranges
Markus Kiili
@Masd925
Mar 06 2016 06:10
@asaki444 Do: a = a + ...
asaki444
@asaki444
Mar 06 2016 06:10
ohh okay
@Masd925 thanks :)
CamperBot
@camperbot
Mar 06 2016 06:10
asaki444 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1135 | @masd925 | http://www.freecodecamp.com/masd925
Arnaud Casamé
@arnaudcasame
Mar 06 2016 06:11
'''js
CamperBot
@camperbot
Mar 06 2016 06:11
:bulb: to format code use backticks! ``` more info
Arnaud Casamé
@arnaudcasame
Mar 06 2016 06:14
```js
var ourPets = {
"cats": [
"Meowzer",
"Fluffy",
"Kit-Cat"
],
"dogs": [
"Spot",
"Bowser",
"Frankie"
]
};
ourPets.cats1; // "Fluffy"
Rita Alfonso
@alfonsotech
Mar 06 2016 06:19
@djcase001 HI, you forgot the three back ticks on a separate line at the end of your code
FriendOfDog
@friendofdog
Mar 06 2016 06:21
Has anyone figured out Make Object Properties Private? What am I doing wrong here?
var Bike = function() {
var gear = 1;
this.setGear = function(shift) {
gear += shift;
};
this.getGear = function() {
return (gear);
};
};
var myBike = new Bike(2);
Luis Felipe López G.
@luishendrix92
Mar 06 2016 06:23
your bike function isn't receiving any parameters and you're passing "2" as an argument
1ety
@1ety
Mar 06 2016 06:24
what is wrong with the following code?
var Car = function() {
  this.wheels = 4;
  this.engines = 1;
  this.seats = 1;
};

// Only change code below this line.

var myCar=new  car();
myCar.nickname ="Toyota";
Luis Felipe López G.
@luishendrix92
Mar 06 2016 06:25
@1ety lowercase car() and it should be Car()
1ety
@1ety
Mar 06 2016 06:26
Thank you @
FriendOfDog
@friendofdog
Mar 06 2016 06:27

@luishendrix92 I'm not sure how to rectify that. My code is almost identical to the provided example...
var Car = function() {
// this is a private variable
var speed = 10;

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

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

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

var myCar = new Car(2);

Rita Alfonso
@alfonsotech
Mar 06 2016 06:27
@1ety ^ var Car = function() car should be lowercase here but var myCar=new car(); "new Car" is uppercase
oops too late
@friendofdog Is this what you are working on? Now try it yourself! Modify the Bike constructor to have a private property called gear and two public methods called getGear and setGear to get and set that value.
FriendOfDog
@friendofdog
Mar 06 2016 06:31
yes, that's the one
Rita Alfonso
@alfonsotech
Mar 06 2016 06:33
This message was deleted
Sorry, let me try that again.
Rita Alfonso
@alfonsotech
Mar 06 2016 06:38
First, it looks like you are setting your gear to 1, but it should be an empty var. Second this.setGear = function(change){ gear = change; };
Richard Corbett
@reacorbett
Mar 06 2016 06:39
im having a hard time figuring out how to push the content of an array to .charCodeAt()
Rita Alfonso
@alfonsotech
Mar 06 2016 06:39
@reacorbett Okay, post your code
what you have so far
@friendofdog work?
FriendOfDog
@friendofdog
Mar 06 2016 06:41
@alfonsotech That did it - thanks! I had followed the example too closely, set gear to "1" because I thought it necessary. But yeah, makes more sense your way.
CamperBot
@camperbot
Mar 06 2016 06:41
friendofdog sends brownie points to @alfonsotech :sparkles: :thumbsup: :sparkles:
:star: 358 | @alfonsotech | http://www.freecodecamp.com/alfonsotech
Richard Corbett
@reacorbett
Mar 06 2016 06:41
@alfonsotech hold up a sec. i have to rewrite it.
Rita Alfonso
@alfonsotech
Mar 06 2016 06:42
@friendofdog :thumbsup:
Richard Corbett
@reacorbett
Mar 06 2016 06:43
dont make fun
function rot13(str) { // LBH QVQ VG!
  var strArr = str.split("");
  var deArr = [];

  for(var i = 0; i < strArr.length; i++){
    deArr.push(strArr[i].charCodeAt(13));
  }

  return deArr;

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Rita Alfonso
@alfonsotech
Mar 06 2016 06:45
@reacorbett Wouldn't dream of making fun - I get stuck every day of the week. :-)
Richard Corbett
@reacorbett
Mar 06 2016 06:48
@alfonsotech str.charCodeAt(13) gives me the character code - 13 for the first letter of the str. i thought this would give me the same result but for every item of the new array.
but i just get null.
Rita Alfonso
@alfonsotech
Mar 06 2016 06:49
@reacorbett This syntax doesn't look quite right deArr.push(strArr[i].charCodeAt(13))What is the name of the challenge, I'll take a look at how I did it.....
Don't want to make a guess and give you bad advice
1ety
@1ety
Mar 06 2016 06:49
ll
Richard Corbett
@reacorbett
Mar 06 2016 06:50
ceasars cipher. i really would like to figure out the challenge on my own. I just need a .push() in the right direction.
Rita Alfonso
@alfonsotech
Mar 06 2016 06:50
Yes, I wont give you the solution, let me refresh my menmory
asaki444
@asaki444
Mar 06 2016 06:50
function titleCase(str) {
  var string = str.split(' ');
  var a;
  var b;
  var c;
  var entire = "";

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

  }
  return entire;
  }


titleCase("I'm a little tea pot") ;
the code runs but it is still not going through the next round. :-/ . I am on Title Case a Sentece
sentence
Richard Corbett
@reacorbett
Mar 06 2016 06:52
@asaki444 look into.replace()
Rohit Choudhary
@maverick2
Mar 06 2016 06:52
bonfire falsy bouncer
CamperBot
@camperbot
Mar 06 2016 06:52

:fire:Bonfire: Falsy Bouncer :link:

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  return arr;
}

bouncer([7, 'ate', '', false, 9]);

Remove all falsy values from an array.

more info:  bf details | bf links | hint

Rita Alfonso
@alfonsotech
Mar 06 2016 06:52
@reacorbett Okay, I see what you are trying to do. Try setting your strArr[i].charCodeAt(13) to a var, then push that var into your string. Two steps.
Rohit Choudhary
@maverick2
Mar 06 2016 06:52
hint
CamperBot
@camperbot
Mar 06 2016 06:52
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Rita Alfonso
@alfonsotech
Mar 06 2016 06:55
@asaki444 Nice approach.
Richard Corbett
@reacorbett
Mar 06 2016 06:56
@alfonsotech ????
for(var i = 0; i < strArr.length; i++){
    var numArr = strArr[i].charCodeAt(13);
    deArr.push(numArr);
  }
apklip
@apklip
Mar 06 2016 06:56
FCC keeps on freezing for me.
Rita Alfonso
@alfonsotech
Mar 06 2016 07:01
@reacorbett Yes, if you console.log this you should get the result you said you wanted. Without the rest of the code and context, I can't tell you what else you need for the challenge tho. I can tell you that for that challenge, you will need a conditional if/else if structure inside your for loop.
Richard Corbett
@reacorbett
Mar 06 2016 07:01
@alfonsotech is there a problem with strArr[i].charCodeAt(13)?
is that always going to return a null value?
Rita Alfonso
@alfonsotech
Mar 06 2016 07:02
No, the syntax looks right to me.
Richard Corbett
@reacorbett
Mar 06 2016 07:03
@alfonsotech thanks for the help.
CamperBot
@camperbot
Mar 06 2016 07:03
reacorbett sends brownie points to @alfonsotech :sparkles: :thumbsup: :sparkles:
:star: 359 | @alfonsotech | http://www.freecodecamp.com/alfonsotech
Richard Corbett
@reacorbett
Mar 06 2016 07:04
@alfonsotech deArr is still returning [null, null, null, null]
Rita Alfonso
@alfonsotech
Mar 06 2016 07:05
@reacorbett Can you post the whole code block?
Richard Corbett
@reacorbett
Mar 06 2016 07:05
function rot13(str) { // LBH QVQ VG!
  var strArr = str.split("");
  var deArr = [];

  for(var i = 0; i < strArr.length; i++){
    var numArr = strArr[i].charCodeAt(13);
    deArr.push(numArr);
  }

  return deArr;

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
I just wanted to say that most fpeople in this chat are so helpful, patient, and friendly. I am glad i came across FCC.
asaki444
@asaki444
Mar 06 2016 07:09
@alfonsotech thanks @reacorbett I ran this on repl.it, and it resulted in "I/'m" instead of "I'm". I looked into .replace(); and I tried to replace the slash but it says ILLEGAL
CamperBot
@camperbot
Mar 06 2016 07:09
asaki444 sends brownie points to @alfonsotech and @reacorbett :sparkles: :thumbsup: :sparkles:
:star: 360 | @alfonsotech | http://www.freecodecamp.com/alfonsotech
:star: 286 | @reacorbett | http://www.freecodecamp.com/reacorbett
Richard Corbett
@reacorbett
Mar 06 2016 07:12
@asaki444 ok, now look into regular expressions. and that should solve that problem.
Rita Alfonso
@alfonsotech
Mar 06 2016 07:19
Sorry, I got distracted over here.
Richard Corbett
@reacorbett
Mar 06 2016 07:19
not a problem at all.
Rita Alfonso
@alfonsotech
Mar 06 2016 07:27
So I think the problem is that charCodeAt is a method for strings, and you are using it on an array (since you split the string into the array in the line previous var strArr = str.split("");.
Richard Corbett
@reacorbett
Mar 06 2016 07:28
@alfonsotech That is what i was afraid of.
Rita Alfonso
@alfonsotech
Mar 06 2016 07:28
So, you need to first iterate through the string, then push into an array, then join the array up again
Can you do that?
Richard Corbett
@reacorbett
Mar 06 2016 07:30
I think so.
ahh. the array and for loop is the only way i could think of. I will do some more research.
nm I can do it without splitting it into an array. Duh!!!!
Rita Alfonso
@alfonsotech
Mar 06 2016 07:33
yes :thumbsup:
how to solve this challenge can anybody tell me little hints
Rita Alfonso
@alfonsotech
Mar 06 2016 07:35
@MaheshProgrammerz Can you share you code so far, what you've tried?
MaheshProgrammerz
@MaheshProgrammerz
Mar 06 2016 07:35
@alfonsotech sure here is my code

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

return item; // Change this line
}

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

here is instruction
@alfonsotech Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed.
Richard Lee
@kaashin
Mar 06 2016 07:38
Can someone help me, I'm doing the "Make a Person" challenge, and I don't know what I'm doing wrong to not get bob to be an instanceof Person. This is what my code is so far:
var Person = function (firstAndLast) {
  strArr = firstAndLast.split(' ');

  return {
    getFirstName: function() {
      return strArr[0];
    },
    getLastName: function() {
      return strArr[1];
    },
    getFullName: function() {
      return strArr[0] + " " + strArr[1];
    },
    setFirstName: function(first) {
      strArr[0] = first;
    },
    setLastName: function(last) {
      strArr[1] = last;
    },
    setFullName: function(firstAndLast) {
      strArr = firstAndLast.split(' ');
    }
  };
};

var bob = new Person('Bob Ross');
bob.getFullName();
Rita Alfonso
@alfonsotech
Mar 06 2016 07:40
@MaheshProgrammerz Okay, but you haven't tried anything yet. First, you need to push the arr onto your testArr, right, so can you do that?
help formatting
CamperBot
@camperbot
Mar 06 2016 07:41

: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

Rita Alfonso
@alfonsotech
Mar 06 2016 07:41
@kaashin ^
Richard Lee
@kaashin
Mar 06 2016 07:41
oops
Rita Alfonso
@alfonsotech
Mar 06 2016 07:42
@MaheshProgrammerz You can google how to push into an array in javascript: http://www.w3schools.com/jsref/jsref_push.asp
w3schools always has great explanations to begin with
Richard Lee
@kaashin
Mar 06 2016 07:44
thanks @alfonsotech
CamperBot
@camperbot
Mar 06 2016 07:44
kaashin sends brownie points to @alfonsotech :sparkles: :thumbsup: :sparkles:
:star: 361 | @alfonsotech | http://www.freecodecamp.com/alfonsotech
Richard Corbett
@reacorbett
Mar 06 2016 07:47
@alfonsotech every way I think this would work, it doesn't.
function rot13(str) { // LBH QVQ VG!

  var deArr = [];

  for(var i = 0; i < str.length; i++){
    var numChg = str[i];
   deArr.push(numChg.charCodeAt(13));

  }
  return deArr;



}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Rita Alfonso
@alfonsotech
Mar 06 2016 07:49
@kaashin I haven't done that challenge yet and I don't see anything off hand that seems wrong to me.
Richard Lee
@kaashin
Mar 06 2016 07:52
@alfonsotech Yeah I'm stumped. All the other tests are passing though.
Richard Corbett
@reacorbett
Mar 06 2016 07:52
charCodeAt() just doesn't work with srt[i] any way I do it. I will have to find another way to iterate throught my string.
Rita Alfonso
@alfonsotech
Mar 06 2016 07:53
testing
This message was deleted
demipixel
@demipixel
Mar 06 2016 08:00
@reacorbett It's
str.charCodeAt(index);
Richard Corbett
@reacorbett
Mar 06 2016 08:00
i tried ```js it didnt work
demipixel
@demipixel
Mar 06 2016 08:01

So for example:

"hello".charCodeAt(4);

finds the char code of "o"

Rita Alfonso
@alfonsotech
Mar 06 2016 08:01
If what you want is the value at position 13 of an array, you could just use array[12] notation
Richard Corbett
@reacorbett
Mar 06 2016 08:01
oh crap!!!!!!! Duh!!!!!! @demipixel thanks
CamperBot
@camperbot
Mar 06 2016 08:01
reacorbett sends brownie points to @demipixel :sparkles: :thumbsup: :sparkles:
:star: 144 | @demipixel | http://www.freecodecamp.com/demipixel
demipixel
@demipixel
Mar 06 2016 08:02
@reacorbett haha np :P
Rita Alfonso
@alfonsotech
Mar 06 2016 08:03
lol, :thumbsup:
@demipixel thanks for taking over for a bit?
CamperBot
@camperbot
Mar 06 2016 08:04
alfonsotech sends brownie points to @demipixel :sparkles: :thumbsup: :sparkles:
:star: 145 | @demipixel | http://www.freecodecamp.com/demipixel
demipixel
@demipixel
Mar 06 2016 08:04
uuuhhh
wait is that question or
Rita Alfonso
@alfonsotech
Mar 06 2016 08:04
lol
hang out for a while, get nice and comfy
Code School is free this weekend, so I'm heading back to do coursework. I'll be in and out of FCC chat...
Richard Corbett
@reacorbett
Mar 06 2016 08:07
function rot13(str) { // LBH QVQ VG!

  var deArr = [];

  for(var i = 0; i < str.length; i++){
    deArr.push(str.charCodeAt(i));


  }
  return deArr;



}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Got It!!
well just what i was trying to acheive
Rita Alfonso
@alfonsotech
Mar 06 2016 08:08
@reacorbett :thumbsup:
Sumeet Batheja
@bathejasumeet
Mar 06 2016 08:24
Hi people
demipixel
@demipixel
Mar 06 2016 08:24
Hey @bathejasumeet
However, @bathejasumeet , we are not people
We are aliens
Sumeet Batheja
@bathejasumeet
Mar 06 2016 08:25
@demipixel : well, then I am a predator :smile:
Richard Corbett
@reacorbett
Mar 06 2016 08:49
ARRR!!!! I am having trouble with fromCharCode().
Kyle Morton
@kmorton1988
Mar 06 2016 08:50
How would I target a specific value in an object?
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
Ryan Price
@rsprice
Mar 06 2016 08:51
@kmorton1988 by accessing the key associated with that value
Kyle Morton
@kmorton1988
Mar 06 2016 08:51
if I'm trying to change the property of album in property 5439, how do I do it? the syntax is confusing to me.
I can't wrap my head around it
Ryan Price
@rsprice
Mar 06 2016 08:51
@kmorton1988 collection.5439 or collection['5439']
Kyle Morton
@kmorton1988
Mar 06 2016 08:52
I got that far, but let's say I have a function that takes an id, a property and a value in as arguments
ie:
update(id, prop, value)
Benjamin Minixhofer
@bminixhofer
Mar 06 2016 08:53
collection[id][prop] = value
or collection.id.prop = value
Kyle Morton
@kmorton1988
Mar 06 2016 08:54
hmm...That's what I"m trying. That's pretty much exactly what I have, except I keep getting an error "TypeError: Cannot read property '<CurrentValue>' of undefined"
Benjamin Minixhofer
@bminixhofer
Mar 06 2016 08:54
can you post your code?
Kyle Morton
@kmorton1988
Mar 06 2016 08:54
function update(id, prop, value) {

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


  return collection;
}
Richard Corbett
@reacorbett
Mar 06 2016 08:55
function rot13(str) { // LBH QVQ VG!

  var numArr = [];

//turns string into char. number array, and subtracts 13 from the value

  for(var i = 0; i < str.length; i++){
    numArr.push(str.charCodeAt(i)); 
    if(numArr[i] !== 32){
      numArr[i] = numArr[i] - 13;
    }
    else{
      numArr[i] = 32;
    }
  }
return numArr;
}   



// Change the inputs below to test
rot13("SERR PBQR PNZC");
Ok, so, I have got this far in the ceasar cipher. I am having trouble figuring out how to use fromCharCode().
Nopply
@StandB
Mar 06 2016 08:56
whats the challenge name? @kmorton1988
Kyle Morton
@kmorton1988
Mar 06 2016 08:56
Record Collection
Benjamin Minixhofer
@bminixhofer
Mar 06 2016 08:56
you are trying to get the value property of `collection[id][prop], thats undefined
@kmorton1988
Kyle Morton
@kmorton1988
Mar 06 2016 08:57
Which if statement?
Benjamin Minixhofer
@bminixhofer
Mar 06 2016 08:57
so try only collection[id][prop]
Kyle Morton
@kmorton1988
Mar 06 2016 08:57
@bminixhofer
Benjamin Minixhofer
@bminixhofer
Mar 06 2016 08:57
the first one
Kyle Morton
@kmorton1988
Mar 06 2016 08:57
omg duh.
ok, that gives me a good head start.
was diving one level too deep.
Benjamin Minixhofer
@bminixhofer
Mar 06 2016 08:58
exactly :)
Kyle Morton
@kmorton1988
Mar 06 2016 08:58
Thanks, @bminixhofer . Helps a lot.
CamperBot
@camperbot
Mar 06 2016 08:58
kmorton1988 sends brownie points to @bminixhofer :sparkles: :thumbsup: :sparkles:
:star: 395 | @bminixhofer | http://www.freecodecamp.com/bminixhofer
Nopply
@StandB
Mar 06 2016 08:59
collection[id][prop][value] !== "" && prop != "tracks" notice that u use !== and != there @kmorton1988
Kyle Morton
@kmorton1988
Mar 06 2016 08:59
!== i thought was only required if you were comparing against ""?
Benjamin Minixhofer
@bminixhofer
Mar 06 2016 09:00
you made a similar mistake at collection.push([id][prop][value]); [id][prop][value] are only the properties without any object
Kyle Morton
@kmorton1988
Mar 06 2016 09:00
yeah, i fixed that after the last realization.
Benjamin Minixhofer
@bminixhofer
Mar 06 2016 09:01
@kmorton1988 if you remove the [value] the first if statement should be fine
Kyle Morton
@kmorton1988
Mar 06 2016 09:02
@bminixhofer yeah, it worked, and I'm now passing th efirst test, but the second one isn't going through now.
actually, the third one. or the second one.
Gah, I need to rest my brain. I will try again in the morning, Thanks again for the help @bminixhofer
CamperBot
@camperbot
Mar 06 2016 09:02
kmorton1988 sends brownie points to @bminixhofer :sparkles: :thumbsup: :sparkles:
:warning: kmorton1988 already gave bminixhofer points
Benjamin Minixhofer
@bminixhofer
Mar 06 2016 09:03
@kmorton1988 good luck :) youre close
Kyle Morton
@kmorton1988
Mar 06 2016 09:04
thanks :) Will hopefully have a eureka moment tomorrow lol.
Richard Corbett
@reacorbett
Mar 06 2016 09:12
function rot13(str) { // LBH QVQ VG!

  var numArr = [];

//turns string into char. number array, and subtracts 13 from the value

  for(var i = 0; i < str.length; i++){
    numArr.push(str.charCodeAt(i)); 
    if(numArr[i] !== 32){
      numArr[i] = numArr[i] - 13;
    }
    else{
      numArr[i] = 32;
    }
  }
return String.fromCharCode();
}   



// Change the inputs below to test
rot13("SERR PBQR PNZC");
I want to take the content of the numArr array and push it to .fromCharCode(). Can someone point me in the right direction?
Benjamin Minixhofer
@bminixhofer
Mar 06 2016 09:15
array.map might help you
Rachel
@chellybear
Mar 06 2016 09:16

the help room seems a bit inactive right now so i figure i'll ask here since it's a problem with my JS:

can someone take a look at my wikipedia viewer and tell me why ajax isn't returning as a success? http://codepen.io/chellybear/pen/RaWdvE please and thanks :)

i tested prior to using the ajax function to see if maybe the url isn't returning anything but it's working fine
and i had no problems with my previous zipline when i tried to pass a value into ajax to get the url
kirbyedy
@kirbyedy
Mar 06 2016 09:18
@chellybear you have to include the callback inside your call
also your console log says: Uncaught ReferenceError: data is not defined
Rachel
@chellybear
Mar 06 2016 09:26
@kirbyedy so if i'm understanding correctly, if i don't include a callback, it won't execute whatever it is that i put in success?
Richard Corbett
@reacorbett
Mar 06 2016 09:31
AHH!!! javascript your a big pain!!!!!!!!!!!
Rachel
@chellybear
Mar 06 2016 09:32
@reacorbett right? :laughing: i like it better than java though :(
Richard Corbett
@reacorbett
Mar 06 2016 09:33
function rot13(str) { // LBH QVQ VG!

  var numArr = [];

//turns string into char. number array, and subtracts 13 from the value

  for(var i = 0; i < str.length; i++){
    numArr.push(str.charCodeAt(i)); 
    if(numArr[i] !== 32){
      numArr[i] = numArr[i] - 13;
    }
//Leaves the spaces as their char. number value
    else{
      numArr[i] = 32;
    }
  }

return String.fromCharCode();
}   



// Change the inputs below to test
rot13("SERR PBQR PNZC");
I cant figure out how to use fromCharCode to convert my array back into a character string.
Kalon
@kaloncpu57
Mar 06 2016 09:34
@reacorbett You'll want to use ```
Oops
Richard Corbett
@reacorbett
Mar 06 2016 09:35
I tried using Oops it didnt work
Kalon
@kaloncpu57
Mar 06 2016 09:35
haha Hang on one second
Benjamin Minixhofer
@bminixhofer
Mar 06 2016 09:36
@reacorbett try var arr = numArr.map(function(value) { return String.fromCharCode(value) } );
Kalon
@kaloncpu57
Mar 06 2016 09:37
String.fromCharCode(13); //needs a code to be passed in order to convert back to a string
You'll have to convert each character back after you get its CharCode
Boris
@boris-in-london
Mar 06 2016 09:38
@bminixhofer try the new arrow function notation in es6, its so much cleaner var arr = numArr.map( value => String.fromCharCode( value ) );
Claire Walker
@kjarva
Mar 06 2016 09:38
could someone take a look at my code and give me a vague idea of why it's not working? This is for the record collection challenge. I'm still not 100% on JSON, so not quite sure where I'm going wrong :(
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
Nopply
@StandB
Mar 06 2016 09:38
Anyone know of a good random qoute api, for the qoute machine zipline? :D
Benjamin Minixhofer
@bminixhofer
Mar 06 2016 09:38
@boris-in-london oh i didnt even know about that, thanks :)
CamperBot
@camperbot
Mar 06 2016 09:38
bminixhofer sends brownie points to @boris-in-london :sparkles: :thumbsup: :sparkles:
:star: 316 | @boris-in-london | http://www.freecodecamp.com/boris-in-london
Claire Walker
@kjarva
Mar 06 2016 09:41
I'm getting an output from it but it's not updating artist or tracks
It's probably simple but I've not found the problem so far
RazielGhul
@RazielGhul
Mar 06 2016 09:42
@kjarva van you give me the link to the challenge?
Richard Corbett
@reacorbett
Mar 06 2016 09:43
@kaloncpu57 I know that. I already have my string converted into char code. I cant figure out how to pass my array of char codes throught fromCharCode.
@bminixhofer @boris-in-london ?? I dont understand.
RazielGhul
@RazielGhul
Mar 06 2016 09:44
`js collection[value] = prop;
should look like :
collection[id][prop] = value;
Kalon
@kaloncpu57
Mar 06 2016 09:45
@reacorbett If you have an array of codes, you should loop through it and pass each code to String.fromCharCode(/CharCode goes here/)
RazielGhul
@RazielGhul
Mar 06 2016 09:45
since you know the id, but the prop is unkown, so you need to lookup both for the first case
Claire Walker
@kjarva
Mar 06 2016 09:45
got it - thanks @RazielGhul !
CamperBot
@camperbot
Mar 06 2016 09:45
kjarva sends brownie points to @razielghul :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for razielghul
RazielGhul
@RazielGhul
Mar 06 2016 09:46
@kjarva and if you want to ADD a track, you should use push(value) , since you don't want to throw everything else away
Devlin S Healy
@soaren
Mar 06 2016 09:46

Would appreciate a hand: Add the number to the end of the array, then remove the first element of array.

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

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

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

Claire Walker
@kjarva
Mar 06 2016 09:48
I used push in my first version but actually thought it was the push that was breaking it ;) I'll go through it again
RazielGhul
@RazielGhul
Mar 06 2016 09:48
Give 'em hell
Claire Walker
@kjarva
Mar 06 2016 09:49
@soaren you're pushing to item but you haven't told it what to push
so it should be arr.push(item);
Nopply
@StandB
Mar 06 2016 09:49
@soaren with removing the first element with shift u dont need to specify the index, so it should be arr.shift();
Claire Walker
@kjarva
Mar 06 2016 09:50
holy sh*t I actually understood what I just said from looking at @soaren 's code
Devlin S Healy
@soaren
Mar 06 2016 09:50
hahaha
Claire Walker
@kjarva
Mar 06 2016 09:50
lol - go me I understand push
anthonygallina1
@anthonygallina1
Mar 06 2016 09:51
@kjarva :+1:
Claire Walker
@kjarva
Mar 06 2016 09:52
:D
Richard Corbett
@reacorbett
Mar 06 2016 09:52
function rot13(str) { // LBH QVQ VG!

  var numArr = [];
  var decode = [];
//turns string into char. number array, and subtracts 13 from the value

  for(var i = 0; i < str.length; i++){
    numArr.push(str.charCodeAt(i)); 
    if(numArr[i] !== 32){
      numArr[i] = numArr[i] - 13;
    }
//Leaves the spaces as their char. number value
    else{
      numArr[i] = 32;
    }
  }
for(var j = 0; j < numArr.length; j++){
  decode.push(String.fromCharCode(j));
}
  return decode;
}   



// Change the inputs below to test
rot13("SERR PBQR PNZC");
So, that loop just gave me some really messed up values. I dont understand.
anyone know why?