These are chat archives for FreeCodeCamp/HelpJavaScript

18th
Apr 2016
jonathanzach
@jonathanzach
Apr 18 2016 00:06 UTC
how do I Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator. how do you write this in Javascript ?
Bent Cardan
@reqshark
Apr 18 2016 00:08 UTC
@jonathanzach 11%3
var remainder = 11 % 3;
remainder would be equal to 2
jonathanzach
@jonathanzach
Apr 18 2016 00:09 UTC
thnxx, i wrote : val remainder; 11 % 3
mikeyb131
@mikeyb131
Apr 18 2016 00:18 UTC
hi guys i seem to be struggling on the Counting Cards for some reason, yet I think my code looks the same as what I have just seen on this forum....

var count = 0;

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

case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
  count--;
break;

}
if (count >= 1) {
return "Bet";
}
else {
return "Hold";
}

// Only change code above this line
}

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

just wondering if I have missed something obvious....
Moisés Man
@moigithub
Apr 18 2016 00:26 UTC
@mikeyb131 ur code should returning
example..
"1 Bet"
or "0 Hold"
mikeyb131
@mikeyb131
Apr 18 2016 00:27 UTC
Ah I see - thanks, how do I corect for that?
Moisés Man
@moigithub
Apr 18 2016 00:28 UTC
u need to include the variable count on ur returning string
return variable+" string";
mikeyb131
@mikeyb131
Apr 18 2016 00:29 UTC
thanks for the help - I will add that in. I had that initially but it wasn't passing
Moisés Man
@moigithub
Apr 18 2016 00:29 UTC
probably missing the space. between
"0Bet" vs "0 Bet"
mikeyb131
@mikeyb131
Apr 18 2016 00:30 UTC
ah yep you're right
Dylan
@dhcodes
Apr 18 2016 00:30 UTC
:musical_note: "the space between..."
lol dave matthews
mikeyb131
@mikeyb131
Apr 18 2016 00:30 UTC
thanks a lot for your help mate - much appreciated
Moisés Man
@moigithub
Apr 18 2016 00:31 UTC
:)
Frank XC
@tenkdayz
Apr 18 2016 00:59 UTC
help Make a Person
CamperBot
@camperbot
Apr 18 2016 00:59 UTC

:point_right: algorithm make a person [wiki]

Explanation:

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

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

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

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

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

Thom
@Hart2014
Apr 18 2016 01:00 UTC

Can anyone help me with JS, I'm on "Word Blanks", and the requirement is: wordBlanks("","","","") should return a string.
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).

The code is here: unction wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

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

Epety
@epety
Apr 18 2016 01:05 UTC
find js
Frank XC
@tenkdayz
Apr 18 2016 01:06 UTC
@Hart2014 you have to build a sentence with the provided noun adj verb adv
Thom
@Hart2014
Apr 18 2016 01:06 UTC
This is what I've done: result += myNoun + " " + myAdjective + " " + myVerb + " " + myAdverb;
Frank XC
@tenkdayz
Apr 18 2016 01:07 UTC
@Hart2014 add "The "+ at the beginning. if that doesnt work
Thom
@Hart2014
Apr 18 2016 01:08 UTC
I'll try that
'''
CamperBot
@camperbot
Apr 18 2016 01:08 UTC
:bulb: to format code use backticks! ``` more info
Thom
@Hart2014
Apr 18 2016 01:09 UTC
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  result += "The" + myNoun + " " + myAdjective + " " + myVerb + " " + myAdverb;


  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
No good there, either
Moisés Man
@moigithub
Apr 18 2016 01:09 UTC
"Thedog" is outputing...
Thom
@Hart2014
Apr 18 2016 01:09 UTC
True
Moisés Man
@moigithub
Apr 18 2016 01:10 UTC
u forgot something in middle
Thom
@Hart2014
Apr 18 2016 01:10 UTC
It should still work
Moisés Man
@moigithub
Apr 18 2016 01:10 UTC
what test is failing ?
Thom
@Hart2014
Apr 18 2016 01:10 UTC
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
Frank XC
@tenkdayz
Apr 18 2016 01:12 UTC
@Hart2014 "The "
Moisés Man
@moigithub
Apr 18 2016 01:12 UTC
This message was deleted
the extra words are optional... as long as ur variables are separated by something
probably u need to refresh ur browser.. or reset code.. do again
@Hart2014
Thom
@Hart2014
Apr 18 2016 01:14 UTC
Maybe refresh my browser
Oh my gosh
That worked
Moisés Man
@moigithub
Apr 18 2016 01:14 UTC
:D
Thom
@Hart2014
Apr 18 2016 01:14 UTC
I've been entering that for an hour now
Thank you @moigithub .
CamperBot
@camperbot
Apr 18 2016 01:14 UTC
hart2014 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 945 | @moigithub | http://www.freecodecamp.com/moigithub
AaronCs
@AaronCs
Apr 18 2016 01:19 UTC
hey guys, what's a good resource for learning ajax?
Alba
@bitavee
Apr 18 2016 01:22 UTC
I need help :( Im stuck on the "Stand in Line" under JS. I got the first 2 check marks and the last but I can't get the third: nextInLine([5,6,7,8,9], 1) should return 5
This message was deleted
Coy Sanders
@coymeetsworld
Apr 18 2016 01:22 UTC
can you post your code @bitavee ?
Amande
@wormwoods
Apr 18 2016 01:23 UTC
function convertToF(celsius) {
  // Only change code below this line


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

// Change the inputs below to test your code
convertToF(30);
```
Alba
@bitavee
Apr 18 2016 01:24 UTC

Heres my code so far: function nextInLine(arr, item) {
testArr.push(item);
var item = testArr.shift();

return testArr, item; // Change this line
}

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

Coy Sanders
@coymeetsworld
Apr 18 2016 01:25 UTC
just return item, not testArr
also, instead of using testArr in your function use arr
Amande
@wormwoods
Apr 18 2016 01:26 UTC
function convertToF(celsius) {
  // Only change code below this line


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

// Change the inputs below to test your code
convertToF(30);
PK
@arcticfries
Apr 18 2016 01:26 UTC
Hi.. I am really confused on the Understanding Uninitialized Variables challenge. I am not able to get the errors to change
I think I can't figure out even the instructions:(
any one can help on it?
Coy Sanders
@coymeetsworld
Apr 18 2016 01:28 UTC
you need to give the variables a value @arcticfries, using the equals operator
a = some number
b = some other number
PK
@arcticfries
Apr 18 2016 01:28 UTC
hmm. I did that @coymeetsworld but didn't seem to work.. let me try one more thing
Coy Sanders
@coymeetsworld
Apr 18 2016 01:28 UTC
ok, if you're still having trouble try posting your code so we can see it
PK
@arcticfries
Apr 18 2016 01:29 UTC
it's wierd.. it worked a few minutes ago for two of the errors but now it's gone.. I am not sure what I did or didn't do!
a = a + 1;
b = b + 5;
c = c + " I am a String!";
oops.. this is the code:
a = a + 1;
b = b + 5;
c = c + " I am a String!";
Coy Sanders
@coymeetsworld
Apr 18 2016 01:30 UTC
thats whats given for you but you need to define and declare a b and c
you use the keyword var to declare a variable, so var a; creates a
PK
@arcticfries
Apr 18 2016 01:31 UTC
darn.. it didn't copy correctly..
a = 5 + 1;
b = 10 + 5;
c = c + " I am a String!";
this is what I have rigt now.
Coy Sanders
@coymeetsworld
Apr 18 2016 01:31 UTC
no you need to put it back the way it was
it says not to change that code
also that still won't work because you didn't declare a b or c yet either
PK
@arcticfries
Apr 18 2016 01:32 UTC
@coymeetsworld so where am I declaring it? I did it above the line but that didn't work either..
Coy Sanders
@coymeetsworld
Apr 18 2016 01:32 UTC
or my mistake, it already comes declared for you
you need to work on this section only:
var a;
var b;
var c;
everything else has to remain untouched
PK
@arcticfries
Apr 18 2016 01:33 UTC
it tells me I have define a and b correctly but that c is not and last is not either.
Coy Sanders
@coymeetsworld
Apr 18 2016 01:33 UTC
you need to initialize each of those 3 values, with the equals sign.
PK
@arcticfries
Apr 18 2016 01:33 UTC
:( I did that and didn't work... but let me try again..
Coy Sanders
@coymeetsworld
Apr 18 2016 01:33 UTC
what did you put?
PK
@arcticfries
Apr 18 2016 01:34 UTC
give me little x on the left column
and still gives me two errors..

// Initialize these three variables
var a = 5
var b = 10
var c = "I am a String!"

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + "String!";

Coy Sanders
@coymeetsworld
Apr 18 2016 01:35 UTC
good, you just need to put semicolons at the end of those 3 statements
and c needs to be corrected a bit
PK
@arcticfries
Apr 18 2016 01:35 UTC
@coymeetsworld Doh!
Coy Sanders
@coymeetsworld
Apr 18 2016 01:35 UTC
shouldn't have String! in there
PK
@arcticfries
Apr 18 2016 01:36 UTC
yes, took that off.. duhh.. realized that just now.. but still giving me two errors:
c should not contain undefined and should have a value of "I am a String!"
Do not change code below the line
Coy Sanders
@coymeetsworld
Apr 18 2016 01:37 UTC
you need to fix c
PK
@arcticfries
Apr 18 2016 01:37 UTC
I did.. var a = 5;
var b = 10;
var c = "I am a";
let me reset and clear the code and try again.. sometimes, it works..
Coy Sanders
@coymeetsworld
Apr 18 2016 01:37 UTC
c = c + "String!"; c would be "I am aString!"
rkDeason
@rkDeason
Apr 18 2016 01:37 UTC
prbly just need a space between a & "
Coy Sanders
@coymeetsworld
Apr 18 2016 01:37 UTC
you need a space
PK
@arcticfries
Apr 18 2016 01:38 UTC
@rkDeason @coymeetsworld yup.. that was the problem.. Thanks!
CamperBot
@camperbot
Apr 18 2016 01:38 UTC
arcticfries sends brownie points to @rkdeason and @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 584 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
:star: 282 | @rkdeason | http://www.freecodecamp.com/rkdeason
PK
@arcticfries
Apr 18 2016 01:38 UTC
it worked!
Coy Sanders
@coymeetsworld
Apr 18 2016 01:38 UTC
np @arcticfries
PK
@arcticfries
Apr 18 2016 01:38 UTC
Thank you thank you thank you!
Moisés Man
@moigithub
Apr 18 2016 01:38 UTC
spaces are overrated
PK
@arcticfries
Apr 18 2016 01:38 UTC
lol tell me about it @moigithub :+1:
Moisés Man
@moigithub
Apr 18 2016 01:38 UTC
;)
PK
@arcticfries
Apr 18 2016 01:38 UTC
This is starting to get tough though:) lol
rkDeason
@rkDeason
Apr 18 2016 01:38 UTC
ur welcome! thanks @arcticfries for hanging in there!
CamperBot
@camperbot
Apr 18 2016 01:38 UTC
rkdeason sends brownie points to @arcticfries :sparkles: :thumbsup: :sparkles:
:star: 149 | @arcticfries | http://www.freecodecamp.com/arcticfries
PK
@arcticfries
Apr 18 2016 01:39 UTC
:)
yeah.. trying to.. I know I need to..
I know JavaScript is super important .. ok back to coding attempt I go:)
rkDeason
@rkDeason
Apr 18 2016 01:40 UTC
you can do it! :smile:
Joseph Stivala
@joestivala
Apr 18 2016 01:55 UTC
Evening all
heymark
@heymark
Apr 18 2016 02:06 UTC
Has anyone here done the Steamroller algorithm challenge?
Ken Haduch
@khaduch
Apr 18 2016 02:06 UTC
@waasiwaasi - looks like no one has responded to your post... are you still around and trying this temperature conversion?
heymark
@heymark
Apr 18 2016 02:12 UTC
Different question: is someString.split('').[some array operation].join('') an okay thing to do? I find myself using it a lot on these challenges.
Samuel Cupidon
@Zerazera
Apr 18 2016 02:13 UTC
@heymark Not only is it OK, it's quite common
Ken Haduch
@khaduch
Apr 18 2016 02:13 UTC

@heymark

Different question: is someString.split('').[some array operation].join('') an okay thing to do? I find myself using it a lot on these challenges.

That's probably fine- the one thing that you should watch out for is if you have to do multiple such operations in a piece of code - although you would have to really profile the code to see what the performance impact is, and probably not worthwhile for most of these challenges?

heymark
@heymark
Apr 18 2016 02:14 UTC
Thanks @Zerazera and @khaduch
CamperBot
@camperbot
Apr 18 2016 02:14 UTC
heymark sends brownie points to @zerazera and @khaduch :sparkles: :thumbsup: :sparkles:
:star: 954 | @khaduch | http://www.freecodecamp.com/khaduch
:star: 374 | @zerazera | http://www.freecodecamp.com/zerazera
PK
@arcticfries
Apr 18 2016 02:20 UTC
ok i am stuck.. getting following error.. You should use the += operator for each variable
when I try to use it, it gives me different error.. so, what am I doing wrong?

here is the code: var a = 3;
var b = 17;
var c = 12;

// Only modify code below this line

a = a + 12;
b = 9 + b;
c = c + 7;

Adrian Jones
@pacmanla
Apr 18 2016 02:21 UTC
Need help, what can I divide by 2.0 & get 2.2?
PK
@arcticfries
Apr 18 2016 02:21 UTC
if I put += parameters at a, b, and c, it fixes that error but then gives me 3 other errors that the calculations are not correct.
heymark
@heymark
Apr 18 2016 02:22 UTC
@pacmanla whatever 2.2 * 2.0 is, presumably :)
PK
@arcticfries
Apr 18 2016 02:22 UTC
@pacmanla are you trying to get 2.0 or get 2.2 as your final answer?
Adrian Jones
@pacmanla
Apr 18 2016 02:22 UTC
2.2
heymark
@heymark
Apr 18 2016 02:22 UTC
@arcticfries can you paste the code that's throwing the error?
PK
@arcticfries
Apr 18 2016 02:23 UTC
@heymark

var a = 3;
var b = 17;
var c = 12;

// Only modify code below this line

a = a + 12;
b = 9 + b;
c = c + 7;

@pacmanla 4.4/2.0 = 2.2
Adrian Jones
@pacmanla
Apr 18 2016 02:23 UTC
@PK got it now, & thanks for the help guys
CamperBot
@camperbot
Apr 18 2016 02:23 UTC
pacmanla sends brownie points to @pk :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for pk
heymark
@heymark
Apr 18 2016 02:23 UTC
@arcticfries sorry, the part where you've inserted the +=
PK
@arcticfries
Apr 18 2016 02:24 UTC
I originally had it like this:
Tyler
@tylergross
Apr 18 2016 02:24 UTC
function isNumeric(value) {
    return /^\d+$/.test(value);
}
function addTogether() {
  for(i = 0; i < arguments.length; i++){
      var matcher = arguments[i];
      if(!isNumeric(arguments[i])){
        return undefined;
      }
    }
  if(arguments.length > 1){
    var value = 0;
    for(i = 0; i < arguments.length; i++){
      value += arguments[i];
    }
    return value;
  }else{
    var b = arguments[0];
    return function(a){ 
             for(i = 0; i < arguments.length; i++){
              var matcher = arguments[i];
              if(!isNumeric(arguments[i])){
                return undefined;
              }
              }
              return a + b; };
  }
}

addTogether(2, "3");
not sure what im doing wrong here, I get all the correct answers when dealing with real numbers, however when they put in "3" or [3] im not returning undefined like im suppposed to
any ideas?
PK
@arcticfries
Apr 18 2016 02:24 UTC
a += a + 12;
b += 9 + b;
c += c + 7;
but doing so gives me errors on a, b, and c
heymark
@heymark
Apr 18 2016 02:24 UTC
@arcticfries gotcha. Syntax is a += 12, etc.
PK
@arcticfries
Apr 18 2016 02:25 UTC
yes but I am confused about the code .. not the math
lol
@heymark its in the Compound Assignment With Augmented Addition challenge
Taur'e Anthony
@k0decraft
Apr 18 2016 02:26 UTC
I hate to ask because this seems so simple. I'm not passing my console checks in the Accessing Objects Properties with Variables challenge.
Help?
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas",
};

// Only change code below this line;

var playerNumber = 16[testObj]; // Change this Line
var player = 'Montana'; // Change this Line
PK
@arcticfries
Apr 18 2016 02:27 UTC
@k0decraft way over my head:) lol.
Tyler
@tylergross
Apr 18 2016 02:27 UTC
[testObj]["16"] @k0decraft
what is the objective here?
Taur'e Anthony
@k0decraft
Apr 18 2016 02:27 UTC
@arcticfries Really? What challenges are you on? I figured you guys were way ahead of me. I suck lol
heymark
@heymark
Apr 18 2016 02:27 UTC
@arcticfries Your syntax is incorrect; you need to have a line that says "a += 12;" rather than "a += a + 12;"
Randall Fine
@randallfine
Apr 18 2016 02:28 UTC
thanks @Rafase282 for your help with Checkpoint: Word Blanks
CamperBot
@camperbot
Apr 18 2016 02:28 UTC
randallfine sends brownie points to @rafase282 :sparkles: :thumbsup: :sparkles:
:star: 1160 | @rafase282 | http://www.freecodecamp.com/rafase282
heymark
@heymark
Apr 18 2016 02:28 UTC
Likewise for the other values.
PK
@arcticfries
Apr 18 2016 02:28 UTC
@k0decraft lol neeh.. everyone at different places.. lots of great people who know way more here:).
@heymark ohhh.. hmmmm.. let me check.. Thx.
CamperBot
@camperbot
Apr 18 2016 02:28 UTC
arcticfries sends brownie points to @heymark :sparkles: :thumbsup: :sparkles:
Taur'e Anthony
@k0decraft
Apr 18 2016 02:28 UTC
@tylergross
Use the playerNumber variable to lookup player 16 in testObj using bracket notation.
CamperBot
@camperbot
Apr 18 2016 02:28 UTC
:star: 184 | @heymark | http://www.freecodecamp.com/heymark
Tyler
@tylergross
Apr 18 2016 02:29 UTC
okay so bracket notation is testObj["16"]
heymark
@heymark
Apr 18 2016 02:29 UTC
@k0decraft extra comma in your object
Tyler
@tylergross
Apr 18 2016 02:29 UTC
would then return "Namath"
PK
@arcticfries
Apr 18 2016 02:29 UTC
@heymark dohh!.. holly crap.. I think I been doing this too long today.. I can't beileve I couldn't do that one rgiht!
Ken Haduch
@khaduch
Apr 18 2016 02:29 UTC
@tylergross - one thing that you could simplify is that in your function that is being returned, you are only going to get one argument, so you can really just access it with arguments[0] instead of a for loop. And I don't think that your isNumeric function is really doing what you want. For example, the "3" is a string, and the regular expression is perfectly happy to match that as a numeric value, but you don't know that it is really a string - got that? So you really want to try some other testing method. Like typeof, perhaps, or maybe one of the Number methods?
Taur'e Anthony
@k0decraft
Apr 18 2016 02:30 UTC
@heymark Yea but that's safe right? I always add an extra comma in my ARRAYs
PK
@arcticfries
Apr 18 2016 02:30 UTC
@heymark thx.. I am still learning the lingo and stuff.. don't have much experience on coding .. so very green.. thx for your patience!
CamperBot
@camperbot
Apr 18 2016 02:30 UTC
arcticfries sends brownie points to @heymark :sparkles: :thumbsup: :sparkles:
:warning: arcticfries already gave heymark points
Tyler
@tylergross
Apr 18 2016 02:30 UTC
@khaduch thanks thats a new function to me i'll check it out
CamperBot
@camperbot
Apr 18 2016 02:30 UTC
:star: 955 | @khaduch | http://www.freecodecamp.com/khaduch
tylergross sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
heymark
@heymark
Apr 18 2016 02:30 UTC
@arcticfries no worries, have fun!
Tyler
@tylergross
Apr 18 2016 02:31 UTC
@k0decraft okay so bracket notation is testObj["16"] and if you returned playerNumber it should output "Namath"
Cleofe
@cleofebelina
Apr 18 2016 02:32 UTC
can someone help me on the stand in line part on javascript? I just started learning the language a day ago and I have no idea what to do now
Taur'e Anthony
@k0decraft
Apr 18 2016 02:32 UTC
@tylergross I don't know if that's the objective here. I've tried that, it didn't work. Maybe I'm not following what you are trying to say...
Julian Krispel-Samsel
@juliankrispel
Apr 18 2016 02:36 UTC
@69grams would be happy to help
heymark
@heymark
Apr 18 2016 02:37 UTC
@69grams what have you tried so far?
Ken Haduch
@khaduch
Apr 18 2016 02:38 UTC
@k0decraft - hey there, I'll try to help.
the object is to access one of the values from the object. The values are keyed by various numeric values, so they want you to store a numeric value in the variable that they say to use, then use that with bracket notation (if you look back at the differences between "dot" notation and "bracket" notation, you'll see that there are times when you must use bracket notation. One of those times is when you have the property name stored in a variable. So you just need to set that variable with the number that they tell you to use, then write testObj[ THE_VARIABLE_NAME ] as the method to get the player's name from the object... It's really a stepping stone to get you accustomed to how to access an object's properties using a variable and bracket notation.
Cleofe
@cleofebelina
Apr 18 2016 02:39 UTC
@juliankrispel how do I add the number to the end of the array?
Ken Haduch
@khaduch
Apr 18 2016 02:40 UTC
@k0decraft - it might be best to reset your code to the initial state, in case you made any edits that would cause problems with the testing.
Taur'e Anthony
@k0decraft
Apr 18 2016 02:40 UTC
@khaduch Thanks, but I can't seem to get the challenge to work. I've tried several different set-ups.
CamperBot
@camperbot
Apr 18 2016 02:40 UTC
k0decraft sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 956 | @khaduch | http://www.freecodecamp.com/khaduch
Taur'e Anthony
@k0decraft
Apr 18 2016 02:41 UTC
@khaduch Yea I usually always reset when trying out new code.
But this still doesn't work
Ken Haduch
@khaduch
Apr 18 2016 02:41 UTC
@k0decraft - if you reset the code, I forget what it starts you with? Please post, and I'll go look at my solution to make sure I'm not missing anything...
Taur'e Anthony
@k0decraft
Apr 18 2016 02:42 UTC
@khaduch Ok, cool...
heymark
@heymark
Apr 18 2016 02:42 UTC
@khaduch starts without any assignment on those last two lines.
sekoku
@sekoku
Apr 18 2016 02:43 UTC
Is there anyone I can pester in a PM about Factorizing a Number? I don't want to post my code publically since I don't know FCC's ethic code on that.
Taur'e Anthony
@k0decraft
Apr 18 2016 02:43 UTC
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber; // Change this Line
var player; // Change this Line
Tyler
@tylergross
Apr 18 2016 02:43 UTC
@k0decraft haven't been able to figure it out myself, I've got half of it completed with the var player = testObj[16];
heymark
@heymark
Apr 18 2016 02:43 UTC
There you go. The first assignment is exactly what the variable name implies: a number.
Ken Haduch
@khaduch
Apr 18 2016 02:45 UTC

@k0decraft - you can get hints from looking at the test code - for example:

* playerNumber should be a number
* The variable player should be a string
* The value of player should be "Montana"
* You should use bracket notation to access testObj

so, playerNumber should be set to a number.
and after the test code is run, player should have the value "Montana"...
you should use bracket notation to access testObj. (And you have to access testObj with bracket notation and the playerNumber variable that is set to the appropriate value to return the variable "Montana"...)

Cleofe
@cleofebelina
Apr 18 2016 02:45 UTC
arr.push(item);
arr.pop(item);
Taur'e Anthony
@k0decraft
Apr 18 2016 02:45 UTC
@tylergross Yea, I got 3 out of the 4 checks correct. The testObj is still incorrect for me.
Cleofe
@cleofebelina
Apr 18 2016 02:45 UTC
that's what I did
heymark
@heymark
Apr 18 2016 02:46 UTC
@sekoku sure, PM me (though I think it's okay to post in here as well)
Ken Haduch
@khaduch
Apr 18 2016 02:46 UTC
@k0decraft - show your current code, please.
heymark
@heymark
Apr 18 2016 02:46 UTC
@69grams can you post the code that's not working?
Taur'e Anthony
@k0decraft
Apr 18 2016 02:46 UTC
@khaduch Thanks again Ken, but I've seen that already and tried following that. I've got 3 out of 4 checks correct right now.
CamperBot
@camperbot
Apr 18 2016 02:46 UTC
k0decraft sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: k0decraft already gave khaduch points
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 02:46 UTC
@69grams array.push() adds item to the end of the array. array.pop() removes the last thing in an array and can't actually take any arguments.
Cleofe
@cleofebelina
Apr 18 2016 02:46 UTC

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

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

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

Taur'e Anthony
@k0decraft
Apr 18 2016 02:47 UTC
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16; // Change this Line
var player = 'Montana'; // Change this Line
This gives me 3 out of 4 checks correct.
Ken Haduch
@khaduch
Apr 18 2016 02:47 UTC
@69grams - your arr.pop(item); is where you have the problem.
heymark
@heymark
Apr 18 2016 02:47 UTC
@69grams if you're trying to remove an item from the beginning of the array, you want shift rather than pop: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift
@k0decraft half way there!
Cleofe
@cleofebelina
Apr 18 2016 02:48 UTC

Write a function nextInLine 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 nextInLine function should then return the element that was removed.

I changed it to shift

Taur'e Anthony
@k0decraft
Apr 18 2016 02:49 UTC
@heymark lol, halfway? I have a sad :-(
Ken Haduch
@khaduch
Apr 18 2016 02:49 UTC
@k0decraft - okay, you are directly setting the player to "Montana", but you see that that is one of the values in the object. At property "16", and you have a variable playerNumber set to the value 16... so this test You should use bracket notation to access testObj - means that you should be setting the value of player by accessing testObj using the variable playerNumber, and using bracket notation... almost there! .....
heymark
@heymark
Apr 18 2016 02:49 UTC
@k0decraft seriously though, you're very close.
Alba
@bitavee
Apr 18 2016 02:50 UTC
@coymeetsworld Thank you sooo much!!!! I just noticed how silly my mistake was. Thanks again :)
CamperBot
@camperbot
Apr 18 2016 02:50 UTC
bitavee sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 585 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 02:50 UTC
@69grams array.shift() does not take in any arguments either.
Cleofe
@cleofebelina
Apr 18 2016 02:50 UTC
yes, I didn't put any
Coy Sanders
@coymeetsworld
Apr 18 2016 02:50 UTC
np @bitavee :thumbsup:
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 02:50 UTC
post your code @69grams
heymark
@heymark
Apr 18 2016 02:50 UTC
@69grams take a look at what you're returning
if you're changing arr, do you want to be returning item?
Taur'e Anthony
@k0decraft
Apr 18 2016 02:51 UTC
@heymark @khaduch thanks
CamperBot
@camperbot
Apr 18 2016 02:51 UTC
k0decraft sends brownie points to @heymark and @khaduch :sparkles: :thumbsup: :sparkles:
:warning: k0decraft already gave khaduch points
:star: 186 | @heymark | http://www.freecodecamp.com/heymark
Taur'e Anthony
@k0decraft
Apr 18 2016 02:51 UTC

Heres my code now, still no luck..

// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

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

This gives me 3 out of 4 checks too, but it's still not allowing the testObj to pass.

Cleofe
@cleofebelina
Apr 18 2016 02:51 UTC
I am returning item
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 02:51 UTC
you want to return the array and not the item
heymark
@heymark
Apr 18 2016 02:52 UTC
@69grams exactly, and you should be returning the array that you just changed instead.
Cleofe
@cleofebelina
Apr 18 2016 02:52 UTC
tried that, didn't work
that was what I did first
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 02:52 UTC
post your code with the change
Cleofe
@cleofebelina
Apr 18 2016 02:52 UTC

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

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

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

Ken Haduch
@khaduch
Apr 18 2016 02:52 UTC
@k0decraft - final hint - instead of using the 16 in the brackets, you should be using the variable that contains the number "16"... replace the [16] with [ some_variable_name ]
using the appropriate variable that you have defined and set to the value "16" just above that last line...
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 02:54 UTC
what's the challenge name? The nextInLine function should then return the element that was removed. @69grams
Taur'e Anthony
@k0decraft
Apr 18 2016 02:54 UTC
@khaduch thanks man. Yea that final hint basically gave me the answer. I can code like hell so long as my hand is held....when the training wheels are off though....oh shi#
CamperBot
@camperbot
Apr 18 2016 02:54 UTC
k0decraft sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: k0decraft already gave khaduch points
heymark
@heymark
Apr 18 2016 02:57 UTC
@69grams sorry, @Jlipschitz is right. I should've read the challenge more closely. Your push line is fine, but the value returned from arr.shift currently isn't going anywhere.
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 02:58 UTC
@69grams you want your return to be basically what you're taking out from shift. try looking to do something like return what\i'm\taking\out
Ken Haduch
@khaduch
Apr 18 2016 02:58 UTC
@k0decraft - if you're just starting out, there is plenty of confusing material! They try to word this in a way that should be fairly straightforward, but it does require putting together concepts that are sometimes easily forgotten. If you go back and re-read that lesson and the examples that they give you, it is a good learning experience to see what they ARE telling you, especially now that you know the final outcome and solution. The test and examples, especially in these early lessons, give some really good hints about what you need to do. Take your time to get more comfortable with them, and really pay attention as you learn. It does get a lot trickier, so the good foundation from the early lessons is very valuable! Good luck!
Luis
@zdrifted
Apr 18 2016 02:58 UTC
I'm having trouble with the Profile Lookup challenge. Any hints?
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Taur'e Anthony
@k0decraft
Apr 18 2016 03:01 UTC
@khaduch Thanks man, problem is I'm not just starting out. Granted I'm not employed to do this either, but I'm no beginner either. I seriously think with all this code there should be LOGIC challenges first before Programming. Hell I can't understand this stuff to save my life.
CamperBot
@camperbot
Apr 18 2016 03:01 UTC
k0decraft sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: k0decraft already gave khaduch points
Ken Haduch
@khaduch
Apr 18 2016 03:01 UTC
@Rushh - you are off to a pretty good start.
Michael Aubrey
@mca62511
Apr 18 2016 03:03 UTC
is it acceptable to omit brackets on if statements if they only need one line? like
$("#blue-button").click(function(){
    simon.input.blue();
    if (simon.isOn) lightUp($(this));
});
Luis
@zdrifted
Apr 18 2016 03:03 UTC
Thanks. Something is off though, I can't figure it out
Ken Haduch
@khaduch
Apr 18 2016 03:04 UTC
@k0decraft - well, I've been programming for years, and I'm amazed at the things that get me stumped now and then... going through these is good, and there is a mix of logic and programming basics here. For some folks there are parts that come more naturally than for others - some of us struggle with everything, but perseverance is essential. I would even say go back and review a section of these lessons, they start to make more sense as you get more exposure to their methodology for trying to teach. As I said - good luck - don't be afraid to ask for help here!
Luis
@zdrifted
Apr 18 2016 03:05 UTC
@mca62511 I would guess that you always need the bracket regardless of how long the code is. The javascript interpreter won't read it correctly, otherwise
heymark
@heymark
Apr 18 2016 03:05 UTC
@Rushh where is it going wrong?
Ken Haduch
@khaduch
Apr 18 2016 03:05 UTC
@Rushh - yes, something is off... you are doing some things incorrectly.
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:05 UTC
// 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 updateRecords(id, prop, value) {
if (value !== "", prop !== "tracks") value = prop;
if (prop == "tracks", value !=="") collection.tracks.push(value);
  if (value ==="") delete value.prop;

  return collection;
}

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

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.

I'm supposed to follow the instructions. Can anybody help see what I've done wrong?
Michael Aubrey
@mca62511
Apr 18 2016 03:06 UTC
@Luis No, the JavaScript interpreter reads it fine. brackets are for blocks of code. Any time you use a bracket and you have one line of code, you can just omit the brackets.... BUT I don't know if that's best practices, you know?
Taur'e Anthony
@k0decraft
Apr 18 2016 03:06 UTC
@khaduch Thanks.
CamperBot
@camperbot
Apr 18 2016 03:06 UTC
k0decraft sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: k0decraft already gave khaduch points
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 03:06 UTC
if (value !== "", prop !== "tracks") can this be done instead of using &&?
Ken Haduch
@khaduch
Apr 18 2016 03:07 UTC
@mca62511 - you can omit brackets if there is only one line of code that is to be executed for the condition. A lot of people recommend putting them in anyway, for consistency and to avoid making a mistake in adding another line of code that you think is going to be executed, but then you need the brackets.
@k0decraft - you're welcome. Any time I can help, I'll give it a shot!
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:07 UTC
@Jlipschitz duno :)
can help?
Michael Aubrey
@mca62511
Apr 18 2016 03:07 UTC
@khaduch alright, thanks, and thanks to @Luis for responding too
CamperBot
@camperbot
Apr 18 2016 03:07 UTC
mca62511 sends brownie points to @khaduch and @luis :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for luis
:star: 957 | @khaduch | http://www.freecodecamp.com/khaduch
Luis
@zdrifted
Apr 18 2016 03:07 UTC
@Kelvin-penang You need to use the && operator in your if statements
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:08 UTC
@Rushh ok, Jamie said so too
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 03:08 UTC
try formulating your if's like this if(something > 0 && 5 > 2) { //my code here } you want to enclose what you want to do inside curly braces { }
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:08 UTC
Tried, still got it wrong
ok jamie
I'll try that
Luis
@zdrifted
Apr 18 2016 03:09 UTC
Well you don't have brackets in your if statements but I guess you don't need it if it's only one line of code. I never knew that lol.
@kelvin-penang Also, you want to set the value for the prop. Not set prop to the value
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:10 UTC
Tried all that, still got all x's
After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA"
After updateRecords(2548, "artist", ""), artist should not be set
After updateRecords(1245, "tracks", "Addicted to Love"), tracks should have "Addicted to Love" as the last element.
After updateRecords(2548, "tracks", ""), tracks should not be set
// 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 updateRecords(id, prop, value) {
if (value !== ""&& prop !== "tracks") {
  prop = value;
}
if (prop == "tracks"&& value !=="") {
  collection.tracks.push(value);
}
  if (value ==="") {
    delete value.prop;
  }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 03:11 UTC
if (prop == "tracks", value !=="") collection.tracks.push(value);you want to use bracket notation here and also include your ID. It doesn't know where to go when you are pushing.
Luis
@zdrifted
Apr 18 2016 03:13 UTC
@heymark All my tests are failing except one: "Bob", "number" should return "No such contact"
Ken Haduch
@khaduch
Apr 18 2016 03:13 UTC

@Rushh - okay, there are a couple thing wrong with your code:

  if( contacts[i][firstName] === firstName && contacts[i][prop] !== undefined ) {  // point #1
    return contacts[i][prop];
  } 
  if ( contacts[i].hasOwnProperty(firstName) === false) { // point #2
    return "No such contact";
  }
  if( contacts[i].hasOwnProperty(prop) === false ) {  // point #3
    return "No such property";
  }

Let's see - you basically have the correct idea with a for loop, since contacts is an array. But your tests are structured incorrectly. For example, where I inserted comments in the code snippet:

  • point #1 - your test for a match on firstName is correct, but for the second part, you should use the Object method .hasOwnProperty() to check for the existence of the property
  • point #2 - that test does not really make sense. In fact, the only way that you know that you have "No such contact" is to check for a match of the firstName against all of the contacts - that should be moved outside of the for loop, so that after all possible contacts are exhausted, then you can make that return.
  • point #3 - you cannot make the return of "No such property" unless you know that there is a match on the firstName, and you don't know that with this condition. It might randomly pass a test, depending on the order that they pass the arguments or test values in.

So - there should be some changes. But I'll let you see what you think about those comments first and ask more questions...

Jamie Lipschitz
@Jlipschitz
Apr 18 2016 03:13 UTC
same thing for js if (value ==="") { delete value.prop; }
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:14 UTC
@Jlipschitz what do you mean? I thought thats the exact code i typed?
Ken Haduch
@khaduch
Apr 18 2016 03:16 UTC
@Kelvin-penang - one thing that I don't see you doing in your code is using the value that is stored in the function arg parameter id to access the collection object. There should be some code references that have collection[id] in them. That's for starters...
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 03:16 UTC
i'm not giving you the code but i'm quoting your code in order to point out what needs fixing. you just need to tell it exactly where to change inside the object by using collections[id] @Kelvin-penang
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:17 UTC
@khaduch thanks
CamperBot
@camperbot
Apr 18 2016 03:17 UTC
kelvin-penang sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:17 UTC
@Jlipschitz thanks
CamperBot
@camperbot
Apr 18 2016 03:17 UTC
:star: 958 | @khaduch | http://www.freecodecamp.com/khaduch
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:17 UTC
@Rushh thanks
CamperBot
@camperbot
Apr 18 2016 03:17 UTC
kelvin-penang sends brownie points to @rushh :sparkles: :thumbsup: :sparkles:
:star: 207 | @rushh | http://www.freecodecamp.com/rushh
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:17 UTC
// 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 updateRecords(id, prop, value) {
if (value !== ""&& prop !== "tracks") {
  prop = value;
}
if (prop == "tracks"&& value !=="") {
  collection[2548].tracks.push(value);
}
  if (value ==="") {
    delete value.prop;
  }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Michael Aubrey
@mca62511
Apr 18 2016 03:18 UTC

Using this to toggle whether a checkbox is enabled or not

$("#strict-mode").prop("disabled", !$("#strict-mode").prop("disabled"));

And it works, but when I toggle it to enabled, the styling still remains like its disabled until I click it.

What gives?

Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:18 UTC
is 2548 the thing you are refering to as ID?
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 03:19 UTC
function updateRecords(id, prop, value) you are passing the ID inside this function. So actually use the variable as opposed to the actual number ... so collections[id]
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:19 UTC
// 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 updateRecords(id, prop, value) {
if (value !== ""&& prop !== "tracks") {
  prop = value;
}
if (prop == "tracks"&& value !=="") {
  collection[id].tracks.push(value);
}
  if (value ==="") {
    delete value.prop;
  }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 03:19 UTC
it gets passed in when you actually call the function updateRecords(5439, "artist", "ABBA"); @Kelvin-penang
Ken Haduch
@khaduch
Apr 18 2016 03:20 UTC
@Kelvin-penang - yes, check the test records and you can see that they will pass one of those numeric values that are the properties for each item in the collection and that is what you use to access individual entries in the collection.
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:20 UTC
still got 3 of the 4 objectives wrong :P
Michael Aubrey
@mca62511
Apr 18 2016 03:20 UTC
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 03:20 UTC
you never changed your if statement as @khaduch suggested. if (value !== ""&& prop !== "tracks") { prop = value; } you have to again be specific and tell exactly where you want it changed inside the object
Ken Haduch
@khaduch
Apr 18 2016 03:21 UTC
@Kelvin-penang - your first check where you are testing if (value !== ""&& prop !== "tracks") { - you need to be setting a property on one of the collection[id] objects, and you'll need to use bracket notation for everything there....
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 03:21 UTC
you are very close! @Kelvin-penang
Michael Aubrey
@mca62511
Apr 18 2016 03:21 UTC
after turning it on, you can click on the strict mode input, but it still looks disabled until you click on it
Ken Haduch
@khaduch
Apr 18 2016 03:23 UTC
@mca62511 - your UI design looks really slick!
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:23 UTC
@khaduch
Michael Aubrey
@mca62511
Apr 18 2016 03:23 UTC
@khaduch Thanks, much appreciated :D
CamperBot
@camperbot
Apr 18 2016 03:23 UTC
mca62511 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: mca62511 already gave khaduch points
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:23 UTC
// 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 updateRecords(id, prop, value) {
if (value !== ""&& prop !== "tracks") {
  collection[id].prop = value;
}
if (prop == "tracks"&& value !=="") {
  collection[id].tracks.push(value);
}
  if (value ==="") {
    delete value.prop;
  }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
I still don't quite get it sorry
Norvin Burrus
@ndburrus
Apr 18 2016 03:25 UTC
are there any questions i might be able to assist with?
Ken Haduch
@khaduch
Apr 18 2016 03:26 UTC

@Kelvin-penang - that's ok. When you have a property name in a variable, you must use bracket notation to reference the property in the object. So your line of code:

collection[id].prop = value;

needs to have the .prop replaced with [prop]. That might fix something.

Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:27 UTC
@khaduch yes it fixed one more objective :) now there are 2 out of 4 that are still wrong
Ken Haduch
@khaduch
Apr 18 2016 03:29 UTC

@Kelvin-penang - if you still have this:

  if (value ==="") {
    delete value.prop;
  }

in your code, that also needs to have collection[id] as part of the reference. And you are deleting a property, so value is only used to test for an empty value.

Luis
@zdrifted
Apr 18 2016 03:29 UTC
@khaduch
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++) {
  if( contacts[i][firstName] === firstName && contacts[i].hasOwnProperty(prop) !== undefined ) {
    return contacts[i][prop];
  } 
  if( contacts[i][firstName] === firstName && contacts[i].hasOwnProperty(prop) === false ) {
    return "No such property";
  }
 }

return "No such contact";
// Only change code above this line
}
Ken Haduch
@khaduch
Apr 18 2016 03:30 UTC
@Rushh - .hasOwnProperty() returns true or false. So checking it for !== undefined is probably always going to be true.
Luis
@zdrifted
Apr 18 2016 03:30 UTC
Oh oops
Ken Haduch
@khaduch
Apr 18 2016 03:30 UTC
because it will never be undefined.
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 03:31 UTC
This message was deleted
no nvm
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:31 UTC
// 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 updateRecords(id, prop, value) {
if (value !== ""&& prop !== "tracks") {
  collection[id][prop] = value;
}
if (prop == "tracks"&& value !=="") {
  collection[id].tracks.push(value);
}
  if (value ==="") {
    delete collection[id][value].prop;
  }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
@khaduch still doesn't help much
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 03:32 UTC
if (value ==="") { delete collection[id][value].prop; } you cannot get to the value without specifying the property first
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:33 UTC
ok. tyring now
Ken Haduch
@khaduch
Apr 18 2016 03:33 UTC

@Kelvin-penang - this code:

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

is almost correct. But as I said - you are trying to delete a property, so the [value] should not be there - it is incorrect. You only need [prop] to delete the property...

Luis
@zdrifted
Apr 18 2016 03:33 UTC
Hmm, I already went through all the basics on teamtreehouse. Is there another code school subscription for javascript that would really help me with freecodecamp?
Ken Haduch
@khaduch
Apr 18 2016 03:34 UTC
I'm tiring too... going to be shutting down here soon...
Rada
@Radascript
Apr 18 2016 03:34 UTC
you guys I finished that date algorythm bonfire how should I celebrate
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 03:34 UTC
think he meant trying lol
Luis
@zdrifted
Apr 18 2016 03:35 UTC
@Kelvin-penang I'll help you, I need to review the problem first though and I'll be back in a minute
Richard Joe
@rjoe19
Apr 18 2016 03:35 UTC
hi
Ken Haduch
@khaduch
Apr 18 2016 03:35 UTC
@Radascript - I don't know how you can celebrate - maybe take an hour off from coding? :) Congratulations!!!
Richard Joe
@rjoe19
Apr 18 2016 03:35 UTC

var Bike = function() {

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

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

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

};

var myCar = new Car();

var myBike = new Bike();

myBike.setGear(4);

Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:36 UTC
// 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 updateRecords(id, prop, value) {
if (value !== ""&& prop !== "tracks") {
  collection[id][prop] = value;
}
if (prop == "tracks"&& value !=="") {
  collection[id].tracks.push(value);
}
  if (value ==="") {
    delete collection[id]["artist"].prop;
    delete collection[id]["tracks"].prop;
    delete collection[id]["album"].prop;
  }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Ken Haduch
@khaduch
Apr 18 2016 03:36 UTC
@Jlipschitz - yup... but I'm tiring... long day and it's late for me.
Richard Joe
@rjoe19
Apr 18 2016 03:36 UTC
get error message "myBike.getGear() should return 4 after calling myBike.setGear(4)."
any help here please
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:36 UTC
I think I'm making a bigger mess :P
Rada
@Radascript
Apr 18 2016 03:36 UTC
@khaduch thanks Ken! Actually finishing a challenge usually instantly gives me motivation to start the next one
CamperBot
@camperbot
Apr 18 2016 03:36 UTC
radascript sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 959 | @khaduch | http://www.freecodecamp.com/khaduch
PK
@arcticfries
Apr 18 2016 03:37 UTC
hi..
Ken Haduch
@khaduch
Apr 18 2016 03:37 UTC
@Kelvin-penang - yes, you have the property to delete in the variable prop. Just use that in place of the contents of that final bracket, and delete two of those three, as well as the .prop...
PK
@arcticfries
Apr 18 2016 03:37 UTC
ok I am running into an issue with the following code..
var myStr = "\\ \t \r \n";
Luis
@zdrifted
Apr 18 2016 03:37 UTC
@Radascript Pour yourself 2oz of some ice cold soda
PK
@arcticfries
Apr 18 2016 03:38 UTC
This is the error it's giving me: myStr should have the escape sequences for backslash tab tab carriage-return new-line separated by spaces
any suggestions?
not sure what I am doing wrong
Ken Haduch
@khaduch
Apr 18 2016 03:38 UTC
@arcticfries - I think that you are just missing one of the items in your string? Lke your thing says "tab tab", and you only have one tab...
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:38 UTC
@khaduch omg....that worked
haha
THANKS TO ALL WHO HELPED!
Ken Haduch
@khaduch
Apr 18 2016 03:39 UTC
@Kelvin-penang :cake:
also @Radascript :cake: :balloon:
Kelvin-penang
@Kelvin-penang
Apr 18 2016 03:40 UTC
yes. cake is right
PK
@arcticfries
Apr 18 2016 03:41 UTC
@khaduch ohh.. hmmm. let me see.. too many tabs .. lol
@khaduch hmm.. that doesn't seem to work
Ken Haduch
@khaduch
Apr 18 2016 03:43 UTC
@arcticfries - no, you need backslash tab tab carriage-return new-line separated by spaces, so you need exactly that sequence and that many of the items they list. So I think you needed two tabs, and it looked like you only had one? Please post your code again if that isn't true...
PK
@arcticfries
Apr 18 2016 03:43 UTC
@khaduch var myStr = "\\ \t \t \r \n";
I updated to this and still giving me the same error
Ken Haduch
@khaduch
Apr 18 2016 03:43 UTC
@arcticfries - let me look at the lesson...
PK
@arcticfries
Apr 18 2016 03:43 UTC
var myStr = "\\ \t \t \r \n";
ok thx
Michael Aubrey
@mca62511
Apr 18 2016 03:44 UTC

ugh, this feels terribly hacky, but it works

$("#strict-mode").prop("disabled", !$("#strict-mode").prop("disabled"));
$('#strict-mode').click().click();

basically just have jQuery quickly click it twice to have the styles set properly >.<

Luis
@zdrifted
Apr 18 2016 03:44 UTC
Man I wish I knew someone I could pair program with
PK
@arcticfries
Apr 18 2016 03:46 UTC
@khaduch thx.. appreciate it
CamperBot
@camperbot
Apr 18 2016 03:46 UTC
arcticfries sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 960 | @khaduch | http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Apr 18 2016 03:46 UTC
@arcticfries - I pasted that line into my editor window and it passed the tests... actually the test. So - is it still failing for you?
Michael Aubrey
@mca62511
Apr 18 2016 03:46 UTC
...actually no that doesn't fix things, because when I disable the button it doesn't update the styles either.
PK
@arcticfries
Apr 18 2016 03:47 UTC
hmm yup.. it does.. let me try clearing the code and trying again.
Ken Haduch
@khaduch
Apr 18 2016 03:47 UTC
@mca62511 - I'm having trouble looking at your code.
Cameron Swift
@Chromps
Apr 18 2016 03:48 UTC
var fact = 1;
function factorialize(num) {
    for(i=1; i<=num; i++){
    fact= fact*i;

  }
  return fact;
}
factorialize(5);
hey guys, I am stuck on this challenge. It is asking me to factorialize various numbers and return the result. I am getting the correct results but FCC is not registering that I am. Do you guys see anything wrong with this code?
PK
@arcticfries
Apr 18 2016 03:48 UTC
@khaduch just reset the code and put it on there again by pasting it and still does same problem:(
you think it's a bug perhaps?
pasting here again, just in case.. var myStr = "\\ \t \t \r \n";
Ken Haduch
@khaduch
Apr 18 2016 03:49 UTC
@arcticfries - do you know how to clear your browser cache (temporary files) - there are times when that is necessary to make things work...
not sure if that is the case here, but your code looks like it should work!
PK
@arcticfries
Apr 18 2016 03:49 UTC
@khaduch yes.. let me try clearing the cache..
be right back
Ken Haduch
@khaduch
Apr 18 2016 03:50 UTC
@mca62511 - I can see that, but putting the pieces together isn't that easy when you're not familiar with the code...
PK
@arcticfries
Apr 18 2016 03:51 UTC
@khaduch ok I cleared.. still same problem:(
Ken Haduch
@khaduch
Apr 18 2016 03:51 UTC
@mca62511 - I'm kind of wondering, if the checkbox is disabled, how can you click on it? Not sure if that is really an issue?
PK
@arcticfries
Apr 18 2016 03:51 UTC
so now what do I do?
Michael Aubrey
@mca62511
Apr 18 2016 03:52 UTC

@khaduch Ah, right. Sorry. Well, I have all of the non-ui stuff in an object called "simon". I have all the sounds in an object called "soundBank". Everything related to the UI is in seperate functions or in $(document).ready

I'm using Google's Material Design Lite framework. Those are all the mdl-element--effect classes.

Ken Haduch
@khaduch
Apr 18 2016 03:52 UTC
@arcticfries - try reloading the page again, and if the code is still there, try it, otherwise just enter it in again? I'm not sure how this problem (if it's the browser cache) will manifest itself...
PK
@arcticfries
Apr 18 2016 03:53 UTC
@khaduch ok let me try ..
Michael Aubrey
@mca62511
Apr 18 2016 03:53 UTC
@khaduch The problem is that if I do $("#strict-mode").disabled = true, or $("#strict-mode").attr("disabled", "disabled"), or $("#strict-mode").prop("disabled", true), it will disable the checkbox, but it won't change the style to make it look disabled.
PK
@arcticfries
Apr 18 2016 03:55 UTC
@khaduch ok back.. still same problem:(.
Michael Aubrey
@mca62511
Apr 18 2016 03:55 UTC
@khaduch The same is true for setting it to enabled. The hacky way I tried to get around that was to have jQuery click on the checkbox (since that updates the styles). However, that hack won't work for disabling the button, since you can't click a disabled button
Luis
@zdrifted
Apr 18 2016 03:55 UTC
thanks @khaduch
CamperBot
@camperbot
Apr 18 2016 03:55 UTC
rushh sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Luis
@zdrifted
Apr 18 2016 03:55 UTC
I finally solved it
John Prada
@jhonsnake
Apr 18 2016 03:55 UTC
// 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 updateRecords(id, prop, value) {
 if(value !== "" && prop !== "tracks"){
  id[prop] = value;
 }else if(prop === "tracks" && value !== ""){
   id.tracks.push(value);
 }else if(value === ""){
   delete id[prop];
 }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Hi please help, what am i not seen in my code?
CamperBot
@camperbot
Apr 18 2016 03:55 UTC
:star: 961 | @khaduch | http://www.freecodecamp.com/khaduch
Michael Aubrey
@mca62511
Apr 18 2016 03:55 UTC
@khaduch I'm guessing it has something to do with MDL and the way that it updates it styles? Maybe?
Ken Haduch
@khaduch
Apr 18 2016 03:56 UTC
@mca62511 - I'm not familiar with MDL... I'm going to try a test on jsfiddle... I'm curious about whether or not you can get a click on a disabled checkbox?
Michael Aubrey
@mca62511
Apr 18 2016 03:56 UTC
@khaduch I cannot get a click on a disabled checkbox
Ghost
@ghost~56bd2077e610378809c105cd
Apr 18 2016 03:57 UTC
anyone around can help me?
Aiden
@AidenKerr
Apr 18 2016 03:57 UTC
How is it? It tests for palindromes.
function palindrome(str) {
  var frontStr = str.toLowerCase().replace(/[^A-Za-z0-9]/gi, "");
  var backStr = frontStr.split("").reverse().join("");
  return frontStr === backStr;
}



palindrome("A man, a plan, a canal. Panama");
PK
@arcticfries
Apr 18 2016 03:59 UTC
I am going to call it a night.. let's see if it helps in the morning!:)
Thanks
Luis
@zdrifted
Apr 18 2016 03:59 UTC
What are some of the other resources you guys use to solve these challenges? I'm on teamtreehouse also but I'm looking for another site to use
Michael Aubrey
@mca62511
Apr 18 2016 03:59 UTC
@khaduch GOT IT! Okay. I was right. MDL adds a "is-disabled" class to the label automatically. If I simply "enable" the button programatically, it still looks disabled because the look of the checkbox is dictated by the label's class, where the function of the checbox is dictacted by the checkbox's disabled prop
@khaduch Thanks for trying to help out again though
CamperBot
@camperbot
Apr 18 2016 03:59 UTC
mca62511 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: mca62511 already gave khaduch points
Ken Haduch
@khaduch
Apr 18 2016 04:00 UTC
@arcticfries - ok - sorry we didn't get that squared away...
Alexander Berezkin
@Leidone
Apr 18 2016 04:00 UTC

The firstLetterOfLastName variable should have the value of L.
// Example
var firstLetterOfFirstName = "";
var firstName = "Ada";

firstLetterOfFirstName = firstName0;

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

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

Kevin
@KevinBruland
Apr 18 2016 04:00 UTC
im stuck on the record collection, and I can't figure out why its not working
i've looked at solutions after trying it, and I have basically the same thing, but it's giving me an error
Ken Haduch
@khaduch
Apr 18 2016 04:01 UTC
@Benalron - please post your code, I'll take a look...
John Prada
@jhonsnake
Apr 18 2016 04:02 UTC
i did it
Kevin
@KevinBruland
Apr 18 2016 04:02 UTC
sure, how exactly do people post it in the boxes?
Ken Haduch
@khaduch
Apr 18 2016 04:02 UTC
help format
CamperBot
@camperbot
Apr 18 2016 04:02 UTC

: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

Ken Haduch
@khaduch
Apr 18 2016 04:02 UTC
@Benalron ^^^ posting code.
Kevin
@KevinBruland
Apr 18 2016 04:03 UTC
function updateRecords(id, prop, value) {
  if(value !== "" && prop === "tracks"){
    collection.id.tracks.push(value);
  }
  else if (value !==""){
    collection.id.prop = value;
  }
  else {
    delete collection.id.prop;
  }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
CamperBot
@camperbot
Apr 18 2016 04:03 UTC
:bulb: to format code use backticks! ``` more info
Kevin
@KevinBruland
Apr 18 2016 04:03 UTC
ok, I think I have it for the future
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 04:04 UTC
you can still edit it @Benalron
John Prada
@jhonsnake
Apr 18 2016 04:04 UTC
@Benalron im just did the same questions and just pass the same level as you we can help each other futher now
Doug
@Spazcool
Apr 18 2016 04:04 UTC
Any good online editors to run my JS code in for testing?
Doug
@Spazcool
Apr 18 2016 04:05 UTC
@Jlipschitz Oh yeah, codepen. Forgot about that one. Thanks mate.
CamperBot
@camperbot
Apr 18 2016 04:05 UTC
spazcool sends brownie points to @jlipschitz :sparkles: :thumbsup: :sparkles:
Kevin
@KevinBruland
Apr 18 2016 04:05 UTC
tada
CamperBot
@camperbot
Apr 18 2016 04:05 UTC
:star: 124 | @jlipschitz | http://www.freecodecamp.com/jlipschitz
Kevin
@KevinBruland
Apr 18 2016 04:05 UTC
only took 4 tries
Ghost
@ghost~56bd2077e610378809c105cd
Apr 18 2016 04:05 UTC
a little help please
$(document).ready(function()  {
  function getFortune() {


    var fortune = ["A friend asks only for your time not your money.", "If you refuse to accept anything but the best, you very often get it.", "A smile is your passport into the hearts of others."];

    var number = ["Lucky Number 1","Lucky NUmber 2", "Lucky NUmber 3",  "Lucky NUmber 4", "Lucky Number 5", "Lucky Number 6"];


    var newNum = Math.floor((Math.random()*fortune.length));

    var newFortune= fortune[newNum];
    var newNumber= number[newNum];

    $(".fortune").text(newFortune);
    $(".number").text(newNumber);
  }   
  $(".btn").on("click", function(){
    getFortune();

  });
});
Ken Haduch
@khaduch
Apr 18 2016 04:06 UTC
@Benalron - you have multiple problems, but I think they are related. collection is a set of objects, so they are keyed by these id values, which are the numbers that you see. You are being passed the id, and prop in variables, and as the previous lessons taught, in order to reference object properties when they are stored in variables, you must use bracket notation. So any place you have collection.id is incorrect - it has to be using bracket notation, or collection[id]. The same thing is true for the prop variable - any time you have a property name in a variable, you have to use bracket notation to access the object properties.
Ghost
@ghost~56bd2077e610378809c105cd
Apr 18 2016 04:06 UTC
im having some t rouble making this work
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 04:06 UTC
@Benalron look into using bracket notation when traversing through an object ```collections[id][prop]```` for example
Kevin
@KevinBruland
Apr 18 2016 04:06 UTC
oooh OK, thanks @khaduch
CamperBot
@camperbot
Apr 18 2016 04:06 UTC
benalron sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 962 | @khaduch | http://www.freecodecamp.com/khaduch
Kevin
@KevinBruland
Apr 18 2016 04:06 UTC
I must have misread something... I thought you only had to use brackets for things with spaces in it?
Ken Haduch
@khaduch
Apr 18 2016 04:07 UTC
@Benalron - that is one of the situations, but if you look back at the lesson that mentions variables and object properties, you'll see that it is also required there.
Kevin
@KevinBruland
Apr 18 2016 04:08 UTC
thanks, I appreciate your help
John Prada
@jhonsnake
Apr 18 2016 04:08 UTC
i got it now thank you all for your help!
Ken Haduch
@khaduch
Apr 18 2016 04:09 UTC
@Rogue00 - where do you have this code - in a CodePen project? It would be easier to look there.
Ghost
@ghost~56bd2077e610378809c105cd
Apr 18 2016 04:09 UTC
Kevin
@KevinBruland
Apr 18 2016 04:10 UTC
@khaduch solved it, and found my other errors in the process
I will go back and ready up on accessing values
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 04:11 UTC
@Rogue00 your button class has a comma in it and is not referring properly in the javascript..btn should be changed to .btn,
Ken Haduch
@khaduch
Apr 18 2016 04:11 UTC
@Rogue00 - I think that the main problem is that you have a comma separating your "btn, btn-default", and that's causing the issue.
@Rogue00 - the comma is incorrect - the classes should be space-separated...
Ghost
@ghost~56bd2077e610378809c105cd
Apr 18 2016 04:13 UTC
thanks @khaduch @Jlipschitz :+1:
CamperBot
@camperbot
Apr 18 2016 04:13 UTC
rogue00 sends brownie points to @khaduch and @jlipschitz :sparkles: :thumbsup: :sparkles:
:star: 125 | @jlipschitz | http://www.freecodecamp.com/jlipschitz
:star: 963 | @khaduch | http://www.freecodecamp.com/khaduch
Ghost
@ghost~56bd2077e610378809c105cd
Apr 18 2016 04:13 UTC
i knew it would be something small
Ken Haduch
@khaduch
Apr 18 2016 04:13 UTC
@Benalron - great!! Good luck...
and you're welcome
and @Rogue00 - you're welcome, too...
khaduch @khaduch - checking out for the night... happy coding everyone!
Jamie Lipschitz
@Jlipschitz
Apr 18 2016 04:13 UTC
@khaduch goodnight man!
Ghost
@ghost~56bd2077e610378809c105cd
Apr 18 2016 04:14 UTC
see you @khaduch :wave:
khaduch @khaduch - thanks all - good night to everyone, or good day, if you're on the other side of the world...
CamperBot
@camperbot
Apr 18 2016 04:14 UTC
sorry khaduch, you can't send brownie points to yourself! :sparkles: :sparkles:
Ken Haduch
@khaduch
Apr 18 2016 04:14 UTC
@camperbot - you're a hoot...
Kelvin-penang
@Kelvin-penang
Apr 18 2016 04:28 UTC

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
var array = [ []]
// Only change code above this line
return product;
}

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

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  var array = [ []]
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
can anybody give a hint on what do i write in the var array?
Justin
@daemedeor
Apr 18 2016 04:29 UTC
@Kelvin-penang you don't write anything, you want to go through the arr variable and with each element multiply whats there
Kelvin-penang
@Kelvin-penang
Apr 18 2016 04:32 UTC
@daemedeor thanks :) but I literally have no idea how to go about it
CamperBot
@camperbot
Apr 18 2016 04:32 UTC
kelvin-penang sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 514 | @daemedeor | http://www.freecodecamp.com/daemedeor
Kelvin-penang
@Kelvin-penang
Apr 18 2016 04:33 UTC
as arr is not yet defined?
Justin
@daemedeor
Apr 18 2016 04:33 UTC
@Kelvin-penang it is, you're passing it in as a parameter
Ankit Padia
@InsaneSkull
Apr 18 2016 04:33 UTC
help Nesting For Loops
CamperBot
@camperbot
Apr 18 2016 04:33 UTC

:point_right: challenge nesting for loops [wiki]

Challenge: Nesting For Loops

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

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

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

Elijah
@Elijahhh
Apr 18 2016 04:37 UTC
@Kelvin-penang multiplyAll([[1,2],[3,4],[5,6,7]]); your parameters .. Your (arr)
@Kelvin-penang Don't give up. I spent maybe 1 hour or more for that.
Kelvin-penang
@Kelvin-penang
Apr 18 2016 04:40 UTC
@Elijahhh thanks. this is hard...
CamperBot
@camperbot
Apr 18 2016 04:40 UTC
kelvin-penang sends brownie points to @elijahhh :sparkles: :thumbsup: :sparkles:
:star: 237 | @elijahhh | http://www.freecodecamp.com/elijahhh
Elijah
@Elijahhh
Apr 18 2016 04:45 UTC
@Kelvin-penang Please don’t skip that part. If you get what I told you, you will understand coding in a whole new way
Kelvin-penang
@Kelvin-penang
Apr 18 2016 04:50 UTC
@Elijahhh , too bad I have been staring at your comment now for some time, still no answer. But I'll give it a try. gtg now, will come back to this problem later
Erin Heard
@ufi16
Apr 18 2016 04:50 UTC
am i supposed to use an if/else or a lookup in the the 'Profile Lookup' challenge?
Luis
@zdrifted
Apr 18 2016 04:53 UTC
@ufi16 Yes, you can do that. I only used two if statements and the && operator as well
But remember that you'll want to iterate through each item/object in the array (to search the properties and values for a match). You'll need to use a loop for that
Erin Heard
@ufi16
Apr 18 2016 05:02 UTC
This message was deleted
This message was deleted
This message was deleted
This message was deleted
E. Badu
@E-Badu
Apr 18 2016 05:26 UTC
@E-Badu
Hello, I am trying to finish the stand in line javascript problem and am running into some issues.
I'm dealing with arrays and .push() and .shift()
could anyone help?
Luis
@zdrifted
Apr 18 2016 05:27 UTC
SUre
E. Badu
@E-Badu
Apr 18 2016 05:28 UTC
@Rushh Thanks! ok. let me send you the problem
CamperBot
@camperbot
Apr 18 2016 05:28 UTC
e-badu sends brownie points to @rushh :sparkles: :thumbsup: :sparkles:
:star: 212 | @rushh | http://www.freecodecamp.com/rushh
alive-jekyll
@alive-jekyll
Apr 18 2016 05:29 UTC

hi everyone, could use few pointer on solving "Understand String Immutability" -tia
// Setup
var myStr = "Jello World";

// Only change code below this line

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

I've tried to assign new string to myStr

myStr = "Hello World";

but keep getting error

Have to search for the answer but the solution I've read is assigning new array which I think that's in the next challenge...

CamperBot
@camperbot
Apr 18 2016 05:29 UTC

welcome to FreeCodeCamp @alive-jekyll!

V Arun Kumar
@arunvkumr
Apr 18 2016 05:33 UTC
@alive-jekyll try removing the line myStr[0] = "H"
Juwdohr
@Juwdohr
Apr 18 2016 05:37 UTC
So I created a website on code pen with a dropdown menu. Dropdown works on codepen.io, and on local machine then uploaded onto a server for school and the dropdown does not work. Any ideas?
V Arun Kumar
@arunvkumr
Apr 18 2016 05:38 UTC
@Juwdohr can you share links for your pen and site?
@arunkumrv The pen works fine and when I export it and open it works fine. The only difference I did was edited it so the menu takes you to their corresponding pages and uploaded it to the school site.
alive-jekyll
@alive-jekyll
Apr 18 2016 05:42 UTC

@alive-jekyll try removing the line myStr[0] = "H"

Commenting that line make the assigning new value acceptable but still why bother to put bracket notation to find first character if only to disable it?

V Arun Kumar
@arunvkumr
Apr 18 2016 05:44 UTC
@alive-jekyll that's the challenge, strings are immutable. You can't change a specific character in the string, but you can manipulate the string to get a new string and store it in new variable. However, you can change the same string by reassigning the entire string to new string value.
V Arun Kumar
@arunvkumr
Apr 18 2016 05:52 UTC
@Juwdohr the site is blocking the jquery and bootstrap js file.. try removing http: in both the links.
Zach
@Moose1551
Apr 18 2016 05:55 UTC
Can someone hold my hand with "Title case a sentence", and give me a small hint? FFS
function titleCase(str) {
  var allLower = str.toLowerCase();
  return allLower; //turns string to Lower case. 
} if (allLower) {
  var camelCase = 0;
  for (var i = 0; i >= camelCase + 1; i++)
    allLower.push(i);
  //some kind of a for loop, who knows. 
}


titleCase("I'm a little tea pot");
kirbyedy
@kirbyedy
Apr 18 2016 05:56 UTC
@Moose1551 well this line does not seem right to me
if (allLower) {
if has to have some condition
V Arun Kumar
@arunvkumr
Apr 18 2016 05:56 UTC
@Moose1551 why return allLower after converting string to lowercase?
V Arun Kumar
@arunvkumr
Apr 18 2016 05:58 UTC
and } before if terminates your function.
@Moose1551
Paul Manning
@paulmanning
Apr 18 2016 05:58 UTC
@Moose1551 perhaps break the string into an array using str.split(“ “) and then for each word, take the first letter and make it uppecase
Eldar Tinjić
@EldarT90
Apr 18 2016 06:01 UTC
@kirbyedy isnt this TRUE OR statement ? which means it should be correct if first part is correct, regardless of second part ?
(newArr.length !== 10 || (newArr.length !== 12 && newArr[0] !== 1)
 ((newArr.length !== 10) || (newArr.length !== 11 && newArr[0] !== 1))
Rada
@Radascript
Apr 18 2016 06:03 UTC
hey do you guys know of a good resource for understanding Closure functions? I understand what it means but I'm not quite feeling them if that makes sense.
Eldar Tinjić
@EldarT90
Apr 18 2016 06:05 UTC
@Radascript it makes sense, actually couple of people were explaining them to me yday, so i think its one of those common things that is hard to get the grasp quickly
Markus Kiili
@Masd925
Apr 18 2016 06:06 UTC
@Radascript Have you read the MDN page https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures ?
Rada
@Radascript
Apr 18 2016 06:07 UTC
@Masd925 yes, I did, in my head I see them as a bit of a "function factory" but would like a little more focused practice
Eldar Tinjić
@EldarT90
Apr 18 2016 06:07 UTC
@Masd925 could you take a look at my statement from couple of minutes ago? i dont get why second part is turning statement in FALSE when we have OR
it shouldnt influence anything if first part is true, correct?
Rada
@Radascript
Apr 18 2016 06:09 UTC
@EldarT90 yeah I just watched a Youtube tutorial and they guy spent the first 3 out of 12 minutes talking about how they are actually really simple but it was pretty unhelpful after all lol
Eldar Tinjić
@EldarT90
Apr 18 2016 06:09 UTC
@Radascript well , for now i think of them as a sub-function which can take result of "bigger function" as a variable
@Radascript so its function inside a function
Markus Kiili
@Masd925
Apr 18 2016 06:10 UTC
@Radascript Simply put, when you return a function in JS, you actually return a closure. The function and the variable environment (scope chain).
JGeis13
@JGeis13
Apr 18 2016 06:12 UTC
Can anyone tell me why this won't work? If I manually reference the arguments it works fine, but I can't seem to get it to work when iterating...
function destroyer(arr) {
  // Remove all the values
  var first = arguments[0];
  var args = [];
  for(i=1;i<arguments.length; i++){
    args.push(arguments[i]);
  }

  var result = [];

  function check(val){
    for(i=0; i<args.length; i++){
      if(val !== args[i]){
        return val;
      }
    }    
  }
  return first.filter(check);
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
oops - don't mind the 'result' array
Luis
@zdrifted
Apr 18 2016 06:14 UTC
This message was deleted
This message was deleted
Markus Kiili
@Masd925
Apr 18 2016 06:15 UTC
@Radascript And closure is important because the outer function that returned the closure might finish its execution, and normally the variables would cease to exist. But because the returned function remembers those variables it had access to, the variables don't vanish.
@JGeis13 You should return false if you find a match and return true after the loop.
Marc Schöni
@marcschoeni
Apr 18 2016 06:16 UTC
Good morning Campers
JGeis13
@JGeis13
Apr 18 2016 06:18 UTC
Ahhh ... so simple! Thanks @Masd925
CamperBot
@camperbot
Apr 18 2016 06:18 UTC
jgeis13 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1370 | @masd925 | http://www.freecodecamp.com/masd925
Paul Manning
@paulmanning
Apr 18 2016 06:19 UTC
@JGeis13 I think the return of the check function needs to be boolean. If true, then you keep the item in the filter, false, remove it. so your return statement in the check function return false if any of the items in args == val otherwise return false.
or what @Masd925 said already :smile:
JGeis13
@JGeis13
Apr 18 2016 06:20 UTC
:)
Zach
@Moose1551
Apr 18 2016 06:21 UTC
Gang,
Are we really expected to know how to do this by the time we get to "Title Case a Sentence?"
String.prototype.replaceAt = function(index, character) {
    return this.substr(0, index) + character + this.substr(index+character.length);
};


function titleCase(str) {
    var newTitle = str.split(' ');
    var updatedTitle = [];
    for (var st in newTitle) {
        updatedTitle[st] = newTitle[st].toLowerCase().replaceAt(0, newTitle[st].charAt(0).toUpperCase());
    }
    return updatedTitle.join(' ');
}
Eldar Tinjić
@EldarT90
Apr 18 2016 06:22 UTC
can some1 tell me why is this statement wrong
 if ((newArr.length !== 10) || (newArr.length !== 11 && newArr[0] !== 1))
it should be TRUE or something, it should always be true if first prat is true
and first part solo is true, but if i add second, it turns to false
which is ilogical
scottmike0
@scottmike0
Apr 18 2016 06:24 UTC
i dont get it, why are you checking for a length of 10 and then 11
Eldar Tinjić
@EldarT90
Apr 18 2016 06:24 UTC
because it can have both 10 and 11 - phone number
if it has 10, its ok; but if it has 11 - first one must be 1
because its country code for usa
so botha re fine
but with OR
but if it has 9 or 12 ,13 ,etc
it should be false immediately
scottmike0
@scottmike0
Apr 18 2016 06:25 UTC
its easier to make it has two seperate conditionals to debug it
Eldar Tinjić
@EldarT90
Apr 18 2016 06:25 UTC
but thats not the whole part, i have additional things to add, but this time
scottmike0
@scottmike0
Apr 18 2016 06:25 UTC
because there is a chance that the first index can be 0
Eldar Tinjić
@EldarT90
Apr 18 2016 06:26 UTC
i want some1 to tell me why
why true OR is turning false
scottmike0
@scottmike0
Apr 18 2016 06:28 UTC
the main reason fr what you are checking is if an arrray
's length
is not 10
then you check or is not 11 and the first is not 1 at the length, then do this, which is a conditional, but necessarily what you want
not necessarily what you want*
Eldar Tinjić
@EldarT90
Apr 18 2016 06:29 UTC
yes, but why
why the second part matter if i have OR
its not AND
why would it even care abot second part if first is true
thats what i want to know
scottmike0
@scottmike0
Apr 18 2016 06:31 UTC
possibly because one of your inputs has a 1 in front of it and it is length 11
Eldar Tinjić
@EldarT90
Apr 18 2016 06:32 UTC
im talking about something that has length of 10
aha, i thinki might see the mistake
scottmike0
@scottmike0
Apr 18 2016 06:33 UTC
exactly, the conditional will not run if there is an array of length 11 and has a 1 as the index 0
mnashrullah07
@mnashrullah07
Apr 18 2016 06:52 UTC
hello everybody
I got stuck on javascript "Returning Boolean Values from Functions"
is there anybody can help me?
Ankit Padia
@InsaneSkull
Apr 18 2016 06:54 UTC
@mnashrullah07 if (a < b) { return true; } else { return false; } inside function
mnashrullah07
@mnashrullah07
Apr 18 2016 06:56 UTC
@InsaneSkull Sorry, but the instruction told me that I'm not allowed using if/else statement
Ankit Padia
@InsaneSkull
Apr 18 2016 06:59 UTC
@mnashrullah07 return a < b;
mnashrullah07
@mnashrullah07
Apr 18 2016 07:01 UTC
Yeah it's working, thank's very much smile: ) @InsaneSkull
CamperBot
@camperbot
Apr 18 2016 07:01 UTC
mnashrullah07 sends brownie points to @insaneskull :sparkles: :thumbsup: :sparkles:
:star: 308 | @insaneskull | http://www.freecodecamp.com/insaneskull
dennis-noah
@dennis-noah
Apr 18 2016 07:18 UTC
Hey
Can anyone help me? I am stuck with switch statements
Instructions
Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta" this is the task

function caseInSwitch(val) {
var answer = "";
// Only change code below this line

case val1 == 1;
answer="alpha";
break;

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

// Change this value to test
caseInSwitch(1);
what I have so far but it already tells me error for the first case statement

mnashrullah07
@mnashrullah07
Apr 18 2016 07:20 UTC
try this bro
case(1):
answer = "alpha";
break;
just repeat it @dennis-noah
Ian Montero
@ianmontero92
Apr 18 2016 07:22 UTC
hi everyone
im a bit stuck in this challenge

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

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("cat", "little", "meow", "cute");

dennis-noah
@dennis-noah
Apr 18 2016 07:23 UTC
@mnashrullah07 Thanks a lot for helping me. It tells me that it is expecting } because of line 1.. that is so weird because I close this later
CamperBot
@camperbot
Apr 18 2016 07:23 UTC
dennis-noah sends brownie points to @mnashrullah07 :sparkles: :thumbsup: :sparkles:
:star: 211 | @mnashrullah07 | http://www.freecodecamp.com/mnashrullah07
Ian Montero
@ianmontero92
Apr 18 2016 07:23 UTC
it says wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
mnashrullah07
@mnashrullah07
Apr 18 2016 07:24 UTC
you're wellcome @dennis-noah
dennis-noah
@dennis-noah
Apr 18 2016 07:24 UTC
@mnashrullah07 Any idea what could be wrong"
Ian Montero
@ianmontero92
Apr 18 2016 07:24 UTC
how can i makke this one work
dennis-noah
@dennis-noah
Apr 18 2016 07:24 UTC
@mnashrullah07 "Expected '}' to match '{' from line 1 and instead saw 'case'
"
@mnashrullah07 "Expected an assignment or function call and instead saw an expression" wtf
mnashrullah07
@mnashrullah07
Apr 18 2016 07:25 UTC
maybe want to see my whole sollution @dennis-noah

switch (val){
case(1):
answer = "alpha";
break;
case(2):
answer = "beta";
break;
case(3):
answer = "gamma";
break;
case(4):
answer = "delta";
break;

}

maybe you forgot to write "{" in the begining @dennis-noah
Dominic Barretto
@Dominicbarretto
Apr 18 2016 07:28 UTC
@mnashrullah07 are u sure u need to put brackets after case? ie case(1):
is this not right ... case 1: ?
dennis-noah
@dennis-noah
Apr 18 2016 07:29 UTC
something is really wrong.. Why is it telling me "Expected an assignment or function call and instead saw an expression" all the time
Dominic Barretto
@Dominicbarretto
Apr 18 2016 07:29 UTC
@dennis-noah try this
switch(val)
mnashrullah07
@mnashrullah07
Apr 18 2016 07:29 UTC
@Dominicbarretto it's the same bro, it works
dennis-noah
@dennis-noah
Apr 18 2016 07:30 UTC
@Dominicbarretto I am trying it like that it still doesnt work :/
Dominic Barretto
@Dominicbarretto
Apr 18 2016 07:30 UTC
@dennis-noah ignore my comment!
mnashrullah07
@mnashrullah07
Apr 18 2016 07:31 UTC
@ianmontero92 what is the name of challange? I forgot
Dominic Barretto
@Dominicbarretto
Apr 18 2016 07:32 UTC
@dennis-noah can u post ur code here
dennis-noah
@dennis-noah
Apr 18 2016 07:32 UTC
Hey guys
I just realized what is wrong

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch(val) {
case(1):
answer = "alpha";
break;

}

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

// Change this value to test
caseInSwitch(1);

I included a switch in the function which is called caseInSwitch but which is not a switch function
not my first value just worked and I will try the other ones
mnashrullah07
@mnashrullah07
Apr 18 2016 07:34 UTC
@dennis-noah Alright, good luck then :)
dennis-noah
@dennis-noah
Apr 18 2016 07:34 UTC
It worked :D

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch(val) {
case(1):
answer = "alpha";
break;
case(2):
answer = "beta";
break;
case(3):
answer = "gamma";
break;

     case(4):

answer = "delta";
break;
}

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

// Change this value to test
caseInSwitch(1);

mnashrullah07
@mnashrullah07
Apr 18 2016 07:35 UTC
:+1: @dennis-noah
EricOber
@EricOber
Apr 18 2016 07:36 UTC
hi everybody
can someone help me with "Access MultiDimensional Arrays With Indexes" challenge?
kirbyedy
@kirbyedy
Apr 18 2016 07:38 UTC
@Am3ricanPaladin what is the problem?
EricOber
@EricOber
Apr 18 2016 07:39 UTC
hey @kirbyedy thanks... I dont really understand the instructions here, or what it wants me to do.
CamperBot
@camperbot
Apr 18 2016 07:39 UTC
am3ricanpaladin sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 878 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
EricOber
@EricOber
Apr 18 2016 07:39 UTC

One way to think of a multi-dimensional array, is as an array of arrays. When you use brackets to access your array, the first set of bracket refers to the entries in the outer-most array, and each subsequent level of brackets refers to the next level of entries inside.

Example

var arr = [
[1,2,3],
[4,5,6],
[7,8,9],
[[10,11,12], 13, 14]
];
arr0; // equals [1,2,3]
arr1; // equals 6
arr31; // equals 11
Instructions
Read from myArray using bracket notation so that myData is equal to 8

Dominic Barretto
@Dominicbarretto
Apr 18 2016 07:39 UTC

Hey Guys
i am doing the "Record Collection" challenge

i need to do the following

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.

how to set the value for prop?

EricOber
@EricOber
Apr 18 2016 07:40 UTC

^those are the instructions.. this is the code that I havent touched. // Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

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

kirbyedy
@kirbyedy
Apr 18 2016 07:40 UTC
@Am3ricanPaladin arrays are 0 based, which means your counting starts at 0
EricOber
@EricOber
Apr 18 2016 07:40 UTC
yes
kirbyedy
@kirbyedy
Apr 18 2016 07:40 UTC
so the first bracket with numbers 1,2,3 is number 0
ok so wht is the number of the array where 8 is ?
EricOber
@EricOber
Apr 18 2016 07:40 UTC
that entire bracket is 0?
3
CamperBot
@camperbot
Apr 18 2016 07:40 UTC

:point_right: challenge get json with the jquery getjson method [wiki]

Get JSON with the jQuery getJSON Method

Application Programming Interfaces - are tools that computers use to communicate with one another.

Most web APIs transfer data in a format called JSON. JSON stands for JavaScript Object Notation. JSON is nothing more than object properties and their current values, sandwiched between a { and a }.

These properties and their values are often referred to as "key-value pairs".

Here is a sample of what it looks like.

$.getJSON("/json/cats.json", function(json) {

   $(".message").html(JSON.stringify(json));

 });

:pencil: read more about challenge get json with the jquery getjson method on the FCC Wiki

kirbyedy
@kirbyedy
Apr 18 2016 07:41 UTC
mmm not really
if first array is 0...
then the next one is...
EricOber
@EricOber
Apr 18 2016 07:41 UTC
1
so the answer is 7?
kirbyedy
@kirbyedy
Apr 18 2016 07:41 UTC
ok, and the next one
hang on :)
EricOber
@EricOber
Apr 18 2016 07:41 UTC
k thx
kirbyedy
@kirbyedy
Apr 18 2016 07:41 UTC
1,2,3 = 0
4,5,6 = 1
the next one ?
EricOber
@EricOber
Apr 18 2016 07:42 UTC
[7,8,9] = 2
kirbyedy
@kirbyedy
Apr 18 2016 07:42 UTC
yes
so my data has to access the second array (2), and the number 8 in it
EricOber
@EricOber
Apr 18 2016 07:43 UTC
ooooooooh right i think i see how its done now. let me plug in these numebrs , 2,1 - lets see
kirbyedy
@kirbyedy
Apr 18 2016 07:43 UTC
and again if you now watch only that array... 7,8,9
and start from 0
EricOber
@EricOber
Apr 18 2016 07:44 UTC
it worked! its like of like a coordinate system
thanks @kirbyedy
CamperBot
@camperbot
Apr 18 2016 07:44 UTC
am3ricanpaladin sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:warning: am3ricanpaladin already gave kirbyedy points
kirbyedy
@kirbyedy
Apr 18 2016 07:44 UTC
yes sort of
:thumbsup:
Vincent Matinde
@matinde
Apr 18 2016 08:45 UTC
Hello all, I am bit stuck on this Profile lookup. Can someone help out?
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var x=0; x < contacts.length; x++){
if (contacts[x].firstName === firstName){
return contacts[x][prop];
}
I seem to interfere every time I add an "else if" statement on this.
LostInTransistors
@marcosignorello
Apr 18 2016 08:49 UTC
is contacts initialized?
Markus Kiili
@Masd925
Apr 18 2016 08:57 UTC
@matinde You should make two nested if clauses inside the contact loop. First if for firstname check and the second for property existence. No elses needed, just the returns.
Vincent Matinde
@matinde
Apr 18 2016 09:05 UTC
Thanks for that @Masd925 this has worked for me.
CamperBot
@camperbot
Apr 18 2016 09:05 UTC
matinde sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1371 | @masd925 | http://www.freecodecamp.com/masd925
Adam Nemeth
@adam-nmth
Apr 18 2016 09:10 UTC
hi! I want to remove duplicates from more arrays, using .filter function with index,self, and element, but if I put it in a for loop, it says don't use functions in a loop. Does anyone have a workaround for this ?
Mooli
@Mooli88
Apr 18 2016 09:13 UTC
hi , need help with Pig Latin please.
English is not my first language so i think im stuck because english grammar more than anything else
function translatePigLatin(str) {

  var vowels = ['a', 'e', 'i', 'o', 'u'];

  var noVowel = true;

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

    var strVowel = str.charAt(0).indexOf(vowels[i]);

    if(strVowel > -1){

      noVowel = false;

      str=str+ 'way';

    }

  }

 if(noVowel){
      str=str.slice(1) + str.charAt(0) + 'ay';
    }




  return str;
}

translatePigLatin("consonant");
Markus Kiili
@Masd925
Apr 18 2016 09:17 UTC
@mrnemeth Filter method does the looping through the elements automatically.
Adam Nemeth
@adam-nmth
Apr 18 2016 09:18 UTC
yes but I mean I have like 3 or N arrays, and I want to use this function in all of them
so I want to loop in each array and remove their duplicates
Markus Kiili
@Masd925
Apr 18 2016 09:19 UTC
@mrnemeth You can declare the callback function separately, and just pass the function name to filter, or you can use .reduce() to loop through the arrays.
Adam Nemeth
@adam-nmth
Apr 18 2016 09:21 UTC
@Masd925 what do you mean by declare the callback function separately? can you explain with a bit more details?
'''
var unique = array.filter(function(elem, index, self) {
return index == self.indexOf(elem);
} );
'''
CamperBot
@camperbot
Apr 18 2016 09:21 UTC
:bulb: to format code use backticks! ``` more info
LostInTransistors
@marcosignorello
Apr 18 2016 09:22 UTC

callback = function (parameter 1, parameter2) {
do stuff
}

functionThatCallsCallback(parameter , parameter, callback(parameter1, parameter2));

Markus Kiili
@Masd925
Apr 18 2016 09:23 UTC
@mrnemeth I mean this:
function callback (elem) {
    return elem%2===0;
}

[1,2,3,4].filter(callback); // [ 2, 4 ]
Then there is no function declaration inside filter.
Mahmoud Abdulazim
@aze3ma
Apr 18 2016 09:25 UTC
hey there
I got stuck at the first
Bharat
@BharatKalluri
Apr 18 2016 09:28 UTC
Hello Guys! Can anybody help me out by telling how to implement the search dropdown functionality in wikipedia viewer
Link to code is here
Islam Ibakaev
@dagman
Apr 18 2016 09:29 UTC
@Bharat-Kalluri jquery ui autocomplete plugin
Adam Nemeth
@adam-nmth
Apr 18 2016 09:29 UTC
@masd thanks! ahh, got it now! perfect :)
CamperBot
@camperbot
Apr 18 2016 09:29 UTC
mrnemeth sends brownie points to @masd :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for masd
Bharat
@BharatKalluri
Apr 18 2016 09:29 UTC
@dagman How do I pre populate the array?
Adam Nemeth
@adam-nmth
Apr 18 2016 09:29 UTC
@Masd925 @masd thanks! ahh, got it now! works perfectly :)
CamperBot
@camperbot
Apr 18 2016 09:29 UTC
mrnemeth sends brownie points to @masd925 and @masd :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for masd
:star: 1372 | @masd925 | http://www.freecodecamp.com/masd925
Islam Ibakaev
@dagman
Apr 18 2016 09:30 UTC
@Bharat-Kalluri you dont need
Bharat
@BharatKalluri
Apr 18 2016 09:31 UTC
@dagman Will try it out
Mahmoud Abdulazim
@aze3ma
Apr 18 2016 09:31 UTC
anyone here
Ashok Bakthavathsalam
@kgashok
Apr 18 2016 09:32 UTC
@aze3ma go ahead
Mahmoud Abdulazim
@aze3ma
Apr 18 2016 09:32 UTC
a shoughl be assigned to b with = does not recognize is this a glitch or I make something wrong ???\
Ashok Bakthavathsalam
@kgashok
Apr 18 2016 09:33 UTC
COde please
Islam Ibakaev
@dagman
Apr 18 2016 09:33 UTC
@Bharat-Kalluri add this in top of your js
// Autocomplete is a jquery ui plugin
$("#input").autocomplete({
    source: function(request, response) {
        $.ajax({
            url: "http://en.wikipedia.org/w/api.php",
            dataType: "jsonp",
            data: {
                'action': "opensearch",
                'format': "json",
                'search': request.term
            },
            success: function(data) {
                response(data[1]);
            }
        });
    }
});
@Bharat-Kalluri quick-add jquery-ui in your js to let it work
Mahmoud Abdulazim
@aze3ma
Apr 18 2016 09:34 UTC
// Setup
2
var a;
3
var b = 2;
4

5
// Only change code below this line
6
var a = 7;
7
var b = 7;
8
a = b;
and another Q how can I copy my code like editor !
Ashok Bakthavathsalam
@kgashok
Apr 18 2016 09:35 UTC
Use ``` to start with
and then end with ```
In-between place your code
which challenge number are you referring to?
Mahmoud Abdulazim
@aze3ma
Apr 18 2016 09:36 UTC

''' // Setup
var a;
var b = 2;

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

CamperBot
@camperbot
Apr 18 2016 09:36 UTC
:bulb: to format code use backticks! ``` more info
Mahmoud Abdulazim
@aze3ma
Apr 18 2016 09:36 UTC

``` // Setup
var a;
var b = 2;

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

```// Setup
var a;
var b = 2;

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

Ashok Bakthavathsalam
@kgashok
Apr 18 2016 09:37 UTC
``` - should be separate on a newline
which FCC challenge number are you on?
Mahmoud Abdulazim
@aze3ma
Apr 18 2016 09:38 UTC
// Setup
var a;
var b = 2;

// Only change code below this line
var a = 7;
var b = 7;
a = b;
Ashok Bakthavathsalam
@kgashok
Apr 18 2016 09:38 UTC
there you go!
Mahmoud Abdulazim
@aze3ma
Apr 18 2016 09:39 UTC
he told me to make a = 7 and b and then a should be assigned to b with =
Ashok Bakthavathsalam
@kgashok
Apr 18 2016 09:39 UTC
Remove the var keyword as a and b already defined.
Mahmoud Abdulazim
@aze3ma
Apr 18 2016 09:40 UTC
// Setup
var a;
var b = 2;

// Only change code below this line
 a = 7;
 b = 7;
 a = b;
still not working
I thought it a glitch !!!
Ashok Bakthavathsalam
@kgashok
Apr 18 2016 09:40 UTC
which challenge number?
Mahmoud Abdulazim
@aze3ma
Apr 18 2016 09:40 UTC
141
Islam Ibakaev
@dagman
Apr 18 2016 09:41 UTC
@aze3ma u should apply b to a after a = 7
Ashok Bakthavathsalam
@kgashok
Apr 18 2016 09:42 UTC
yes... I see it
Islam Ibakaev
@dagman
Apr 18 2016 09:43 UTC
@kgashok
a = 7;
 // one line here
Mahmoud Abdulazim
@aze3ma
Apr 18 2016 09:44 UTC
// Setup
var a;
var b = 2;

// Only change code below this line
 a = 7;
 a = b;
Ashok Bakthavathsalam
@kgashok
Apr 18 2016 09:44 UTC
If you want to assign bigValue to smallValue, the smallValue has to be on the left side of the =
Send me the link of the Challenge...
Mahmoud Abdulazim
@aze3ma
Apr 18 2016 09:45 UTC
@kgashok thank you :)
CamperBot
@camperbot
Apr 18 2016 09:45 UTC
aze3ma sends brownie points to @kgashok :sparkles: :thumbsup: :sparkles:
:star: 155 | @kgashok | http://www.freecodecamp.com/kgashok
Mahmoud Abdulazim
@aze3ma
Apr 18 2016 09:45 UTC
@dagman thank you buddy! (Y)
Ashok Bakthavathsalam
@kgashok
Apr 18 2016 09:45 UTC
@aze3ma I got it..don't bother
CamperBot
@camperbot
Apr 18 2016 09:45 UTC
aze3ma sends brownie points to @dagman :sparkles: :thumbsup: :sparkles:
:star: 423 | @dagman | http://www.freecodecamp.com/dagman
Islam Ibakaev
@dagman
Apr 18 2016 09:46 UTC
@aze3ma yw
Ultras05
@Ultras05
Apr 18 2016 09:51 UTC

function chainToSwitch(val) {
var answer = "";
// Only change code below this line

switch(val){
case 1 :
answer = "Marley";
break;
case 2 :
answer = "The Answer";
break;
case 3:
answer = "There is no #1";
break;
case 4 :
answer = "Missed me by this much!";
break;
case 5 :
answer = "Ate Nine";
break;

}

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

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

Ashok Bakthavathsalam
@kgashok
Apr 18 2016 09:58 UTC
function chainToSwitch(val) {
var answer = "";
// Only change code below this line
switch(val){
  case 1 :
    answer = "Marley";
    break;
  case 2 :
    answer = "The Answer";  
   break;
  case 3:
    answer = "There is no #1";
    break;
  case 4 :
    answer = "Missed me by this much!";
    break;
  case 5 :
    answer = "Ate Nine";
    break;
  }
  // Only change code above this line
  return answer;
}
// Change this value to test
chainToSwitch("");
Stephen James
@sjames1958gm
Apr 18 2016 09:58 UTC
@Ultras05 Reset the code. The case values are not 1,2,3,4,5. Use the values from the original if/else
Dardan Demiri
@dardandemiri
Apr 18 2016 10:00 UTC
Why is this not working

function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line

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

      if(collection[j].hasOwnProperty("first") && source[i].hasOwnProperty("last")){

        if(collection[j].first == source[i].first){
          arr += source[i];
        }

      }else if(collection[j].hasOwnProperty("last") && source[i].hasOwnProperty("last")){

        if(collection[j].last == source[i].last){
          arr += source[i];
        }
      }

    }
  }

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

whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Alex
@alexstelmakh
Apr 18 2016 10:02 UTC
please somebody tell me what I'm doing wrong. This is what I should get You should use two double quotes (") and four escaped double quotes (\")
Variable myStr should equal to ("I am a "double quoted" string inside "double quotes""). THIS is what I'm typed in-var myStr = "I am a \"double quoted\" string inside \"double quotes\"\""; // Change this line
Dardan Demiri
@dardandemiri
Apr 18 2016 10:03 UTC
@alexstelmakh
Markus Kiili
@Masd925
Apr 18 2016 10:03 UTC
@dardandemiri You cannot add to an array with +=.
Dardan Demiri
@dardandemiri
Apr 18 2016 10:03 UTC
ahhh
.push
kirbyedy
@kirbyedy
Apr 18 2016 10:03 UTC
@alexstelmakh this does not look right to me \"\"";
Dardan Demiri
@dardandemiri
Apr 18 2016 10:04 UTC
@Masd925 it's still not working
Ankit Padia
@InsaneSkull
Apr 18 2016 10:04 UTC
@alexstelmakh myStr = "I am a \"double quoted\" string inside \"double quotes\"";
Markus Kiili
@Masd925
Apr 18 2016 10:05 UTC
@dardandemiri You have hardcoded the source keys. You should loop through the source keys.
Alex
@alexstelmakh
Apr 18 2016 10:05 UTC
So give me advice @kirbyedy
Markus Kiili
@Masd925
Apr 18 2016 10:05 UTC
@dardandemiri Outer loop should be through the collection and inner through source keys. Only push if values are the same for all the source keys.
kirbyedy
@kirbyedy
Apr 18 2016 10:06 UTC
@alexstelmakh there it is... @InsaneSkull wrote it for you
mnashrullah07
@mnashrullah07
Apr 18 2016 10:06 UTC
Is anybody can help me? I got stuck with "Convert Celsius to Fahrenheit"
Alex
@alexstelmakh
Apr 18 2016 10:07 UTC
@InsaneSkull I did it the same way but I thought that in the end should be two "" , because of instruction was :Variable myStr should equal to ("I am a "double quoted" string inside "double quotes"").
Dardan Demiri
@dardandemiri
Apr 18 2016 10:07 UTC
@Masd925 can you please explain it more
I don't understand
Alex
@alexstelmakh
Apr 18 2016 10:08 UTC
Thanks for comments
Stephen James
@sjames1958gm
Apr 18 2016 10:08 UTC
@dardandemiri Your solution is if it works only solves the first test. You have to read the keys from source to know what to check. You can use "for in" type for loop to loop over the keys in source to check if they exist in collection. I would put the collection loop on the outside.
for(var j = 0; j < collection.length; j++){
  for (var prop in source) {
  // check if prop is in collection[j]
  }
}
Ankit Padia
@InsaneSkull
Apr 18 2016 10:09 UTC
@alexstelmakh you can count no. of quotes started and ended.
mnashrullah07
@mnashrullah07
Apr 18 2016 10:09 UTC
i wrote celsius = (celsius * 9/5) + 32; inside the convertToF function
Markus Kiili
@Masd925
Apr 18 2016 10:10 UTC
@dardandemiri Another way is to use methods .filter() and .every().
mnashrullah07
@mnashrullah07
Apr 18 2016 10:10 UTC
there is no error message so I get confused
cannelflow
@cannelflow
Apr 18 2016 10:13 UTC
var fahrenheit = celsius*(9/5)+32; @mnashrullah07
Kevin
@KevinBruland
Apr 18 2016 10:14 UTC
im stuck on the factorialize a number problem... and it seemed really simple, but I can't figure out why my solution isnt working
cannelflow
@cannelflow
Apr 18 2016 10:15 UTC
@Benalron can you show your code
Kevin
@KevinBruland
Apr 18 2016 10:16 UTC
yeah
function factorialize(num) {
  var y = 1;
  for (var x=num; x === 0; x--){
    y *= x;
  }
  return y;
}
factorialize(5);
priyanka
@priyankasawant12345
Apr 18 2016 10:17 UTC
fahrenheit = celsius * 9 / 5 + 32; for fahrenheit problem
Kevin
@KevinBruland
Apr 18 2016 10:18 UTC
if it was more complex, I would spend longer trying to figure it out... but it seemed so easy to me
obviously it wasnt lol, I just dont know what else to consider
Ivan Temchur
@ttemcha
Apr 18 2016 10:18 UTC
hey folks i need help!
function destroyer(arr) {
  // Remove all elements from the initial array that are of the same value as these arguments.
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Markus Kiili
@Masd925
Apr 18 2016 10:19 UTC
@Benalron For loop condition is wrong.
Kevin
@KevinBruland
Apr 18 2016 10:19 UTC
thanks, ill look into that
Ivan Temchur
@ttemcha
Apr 18 2016 10:19 UTC
where should i start from ?
Markus Kiili
@Masd925
Apr 18 2016 10:19 UTC
@ttemcha The arguments object and perhaps .filter().
Kate Fedorenko
@katie-codes
Apr 18 2016 10:19 UTC
@Benalron I was stuck on this one for a while using for loops. Look into recursion!
I had no idea what it was before the factorial challenge, but you will need it
cannelflow
@cannelflow
Apr 18 2016 10:20 UTC
as @katie-codes said try recursion @Benalron
Kevin
@KevinBruland
Apr 18 2016 10:20 UTC
thanks for the tips, I will pursue that
priyanka
@priyankasawant12345
Apr 18 2016 10:20 UTC
anybody solved world-blanks problem. i stuck there
Kevin
@KevinBruland
Apr 18 2016 10:21 UTC
thanks @katie-codes
CamperBot
@camperbot
Apr 18 2016 10:21 UTC
benalron sends brownie points to @katie-codes :sparkles: :thumbsup: :sparkles:
:star: 262 | @katie-codes | http://www.freecodecamp.com/katie-codes
Stephen James
@sjames1958gm
Apr 18 2016 10:22 UTC
@priyankasawant12345 Do you have any code so far?
Kevin
@KevinBruland
Apr 18 2016 10:22 UTC
I beat it, thanks guys
but im definitely going to read up more on recursion
Kate Fedorenko
@katie-codes
Apr 18 2016 10:23 UTC
well done!!!
@Benalron now you've done the challenge, read this (helped me understand the code I actually wrote!): http://www.programmerinterview.com/index.php/recursion/explanation-of-recursion/
priyanka
@priyankasawant12345
Apr 18 2016 10:24 UTC

@sjames1958gm function wordBlanks(myNoun, myAdjective, myVerb,myAdverb) {
var result = "";
// Your code below this line
result = "cat,little,hit,slowly";
// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog" , "big" , "ran" , "quickly");
here is my code but not working

Kevin
@KevinBruland
Apr 18 2016 10:24 UTC
ah awesome, thanks @katie-codes
CamperBot
@camperbot
Apr 18 2016 10:24 UTC
benalron sends brownie points to @katie-codes :sparkles: :thumbsup: :sparkles:
:warning: benalron already gave katie-codes points
Stephen James
@sjames1958gm
Apr 18 2016 10:25 UTC
@priyankasawant12345 You will need to use string operators to build a new string,
priyanka
@priyankasawant12345
Apr 18 2016 10:25 UTC
is it for result variable?
Stephen James
@sjames1958gm
Apr 18 2016 10:26 UTC
@priyankasawant12345 The string operator it is looking for is how to put to strings together to make one.
@priyankasawant12345 yes for the result variable - Use your input parameters myNoun, etc.
mnashrullah07
@mnashrullah07
Apr 18 2016 10:27 UTC
@cannelflow thanks buddy, very helfull
CamperBot
@camperbot
Apr 18 2016 10:27 UTC
mnashrullah07 sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
:star: 1082 | @cannelflow | http://www.freecodecamp.com/cannelflow
cannelflow
@cannelflow
Apr 18 2016 10:28 UTC
@mnashrullah07 :+1:
Deepak Yadav
@ydeepk
Apr 18 2016 10:30 UTC

help guy's

// title case achallange
function titleCase(str) {
  var strtolower = str.toLowerCase();
  var strSplit = strtolower.split(/\s/);

  for(var a = 0; a < strSplit.length; a++) {
    var upperFirst = strSplit[a][0].toUpperCase();
    }

  }

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

note:- only thing remains my array is I , A, L ,P. Only want to make my first letter of word capital.

CamperBot
@camperbot
Apr 18 2016 10:30 UTC
no wiki entry for: guys title case achallange function titlecasestr var strtolower strtolowercase var strsplit strtolowersplits forvar a 0 a strsplitlength a var upperfirst strsplita0touppercase titlecaseim a little potnote- only thing remains my array is i a l p only want to make my first letter of word capital
priyanka
@priyankasawant12345
Apr 18 2016 10:30 UTC
@sjames1958gm not working
cannelflow
@cannelflow
Apr 18 2016 10:31 UTC
@priyankasawant12345 can you paste your code
Deepak Yadav
@ydeepk
Apr 18 2016 10:31 UTC
@camperbot wiki?
Stephen James
@sjames1958gm
Apr 18 2016 10:31 UTC
@priyankasawant12345 what did you do
Deepak Yadav
@ydeepk
Apr 18 2016 10:31 UTC
@priyankasawant12345 hey !
priyanka
@priyankasawant12345
Apr 18 2016 10:32 UTC

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

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

Stephen James
@sjames1958gm
Apr 18 2016 10:32 UTC
@priyankasawant12345 "," is not how you combine strings, also you are supposed to put a " " inbetween words
@sjames1958gm Not sure if they have shown this "this" + " " + "that => "this that"
cannelflow
@cannelflow
Apr 18 2016 10:34 UTC
function(A,B,C,D){
so if you want to make a sentence using A,B,C,C then do like
result = A+" "+B+" "+C" "+D
}
@priyankasawant12345
Stephen James
@sjames1958gm
Apr 18 2016 10:34 UTC
@ydeepk strSplita.toUpperCase(); this returns the first word upper case, now you combine it with the rest of strSplit[a] using a string function that returns only part of a string.
Deepak Yadav
@ydeepk
Apr 18 2016 10:35 UTC
@priyankasawant12345 you have to make a fill in the blanks sentence, in result variable
Alex
@alexstelmakh
Apr 18 2016 10:35 UTC
Please help. What should I do with this: myStr should have the escape sequences for backslash tab tab carriage-return new-line separated by spaces var myStr = 'backslash tab tab carriage-return new-line'; // Change this line
Deepak Yadav
@ydeepk
Apr 18 2016 10:36 UTC
@priyankasawant12345 you have to make a fill in the blanks sentence , in result variable, remember about strings and variables ?
Stephen James
@sjames1958gm
Apr 18 2016 10:37 UTC
@alexstelmakh Use the table on the left to replace the words in the string with the escape sequences
Deepak Yadav
@ydeepk
Apr 18 2016 10:37 UTC
@sjames1958gm let me try it.
Stephen James
@sjames1958gm
Apr 18 2016 10:38 UTC
Deepak Yadav
@ydeepk
Apr 18 2016 10:38 UTC
@priyankasawant12345 are you there?
priyanka
@priyankasawant12345
Apr 18 2016 10:38 UTC
yes

function wordBlanks(myNoun, myAdjective, myVerb,myAdverb) {
var result = "";
// Your code below this line
result = "cat"+" "+"little"+" "+"hit"+" "+"slowly";
// Your code above this line
return result;
}

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

still not working
cannelflow
@cannelflow
Apr 18 2016 10:39 UTC
@alexstelmakh you can see the instruction like tab is \t something
Alex
@alexstelmakh
Apr 18 2016 10:39 UTC

Please help. What should I do with this:

myStr should have the escape sequences for backslash tab tab carriage-return new-line separated by spaces

var myStr = 'backslash tab tab carriage-return new-line'; // Change this line

Stephen James
@sjames1958gm
Apr 18 2016 10:39 UTC
@priyankasawant12345 You didn't use the variables
cannelflow
@cannelflow
Apr 18 2016 10:39 UTC
@priyankasawant12345 you are passing myNoun, myAdjective, myVerb,myAdverb to function so use these variable
Deepak Yadav
@ydeepk
Apr 18 2016 10:40 UTC
@priyankasawant12345 do want ans directly??
Stephen James
@sjames1958gm
Apr 18 2016 10:40 UTC
@alexstelmakh See the table on the left
priyanka
@priyankasawant12345
Apr 18 2016 10:40 UTC
yes
cannelflow
@cannelflow
Apr 18 2016 10:40 UTC
@alexstelmakh as @sjames1958gm said see the table
Stephen James
@sjames1958gm
Apr 18 2016 10:40 UTC
@alexstelmakh Use output column to replace the words in string with code column
Deepak Yadav
@ydeepk
Apr 18 2016 10:40 UTC

@priyankasawant12345
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result= "I'm a "+myNoun+",I'm very "+myAdjective+" like to "+myVerb+" my "+myAdverb+" everyday.";
// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("cat", "little", "hit", "slowly");

Stephen James
@sjames1958gm
Apr 18 2016 10:41 UTC
@sjames1958gm For example replace tab with \t
cannelflow
@cannelflow
Apr 18 2016 10:42 UTC
pls pasting answer won't help anyone here
@alexstelmakh for newline \n
everything is there at left @alexstelmakh
priyanka
@priyankasawant12345
Apr 18 2016 10:43 UTC
@ydeepk Thanks deepak !!!
CamperBot
@camperbot
Apr 18 2016 10:43 UTC
priyankasawant12345 sends brownie points to @ydeepk :sparkles: :thumbsup: :sparkles:
:star: 264 | @ydeepk | http://www.freecodecamp.com/ydeepk
Alex
@alexstelmakh
Apr 18 2016 10:44 UTC
This message was deleted
Deepak Yadav
@ydeepk
Apr 18 2016 10:44 UTC
@priyankasawant12345 you R Welcome.
Alex
@alexstelmakh
Apr 18 2016 10:46 UTC
I don't understand what is wrong
I typed this : var myStr = 'backslash \t tab \t tab \t carriage-return \t new-line';
and nothing((
Deepak Yadav
@ydeepk
Apr 18 2016 10:46 UTC
@alexstelmakh try putting it between double quotes. ""
cannelflow
@cannelflow
Apr 18 2016 10:47 UTC
suppose it is newline newline tab tab
then you do like
var myStr = '\n \n \t \t'
@alexstelmakh
Brendan Kinahan
@BKinahan
Apr 18 2016 10:48 UTC
@cannelflow that ain't no string :P
cannelflow
@cannelflow
Apr 18 2016 10:49 UTC
@BKinahan oops :p
Deepak Yadav
@ydeepk
Apr 18 2016 10:49 UTC
@BKinahan agreed.
@cannelflow a string is something between "".
Son Dang
@viiiprock
Apr 18 2016 10:50 UTC
@alexstelmakh remove all text with escape sign
Deepak Yadav
@ydeepk
Apr 18 2016 10:50 UTC
@cannelflow good you realised your mistake.
cannelflow
@cannelflow
Apr 18 2016 10:50 UTC
@ydeepk tax @BKinahan
CamperBot
@camperbot
Apr 18 2016 10:50 UTC
cannelflow sends brownie points to @ydeepk and @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1327 | @bkinahan | http://www.freecodecamp.com/bkinahan
:star: 265 | @ydeepk | http://www.freecodecamp.com/ydeepk
cannelflow
@cannelflow
Apr 18 2016 10:50 UTC
@ydeepk after all we are here to learn
Stephen James
@sjames1958gm
Apr 18 2016 10:52 UTC
@alexstelmakh Remove the words
Alex
@alexstelmakh
Apr 18 2016 10:55 UTC
@sjames1958gm What the words?
Stephen James
@sjames1958gm
Apr 18 2016 10:55 UTC
@alexstelmakh backspace tab new-line carriage-return
Uğur
@UgurKurt
Apr 18 2016 10:56 UTC
Hi guys ,i looked everywhere but couldnt find a solution ,in find palindromes challenge ,my code doesnt work and i have no idea why .
How can i post my code here ?
cannelflow
@cannelflow
Apr 18 2016 10:56 UTC
wiki format
CamperBot
@camperbot
Apr 18 2016 10:56 UTC

: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

cannelflow
@cannelflow
Apr 18 2016 10:56 UTC
:point_up: April 18, 2016 4:26 PM @UgurKurt
Alex
@alexstelmakh
Apr 18 2016 10:57 UTC
@sjames1958gm f*k/. my english is bad, I understand nothing((
Stephen James
@sjames1958gm
Apr 18 2016 10:57 UTC
@alexstelmakh "tab" ==> "\t"
Abdoulaye Niang
@abesn
Apr 18 2016 11:01 UTC
Hi All...
Today's my second day - Need Help with this:
function convertToF(celsius) { // Only change code below this line var celcius; var fahrenheit = celcius*(9/5)+32; // Only change code above this line return fahrenheit; } // Change the inputs below to test your code convertToF(0); convertToF(-30); convertToF(-10); convertToF(-0); convertToF(20); convertToF(30);
Stephen James
@sjames1958gm
Apr 18 2016 11:01 UTC
@abesn why define celcius with var celcius when it is a parameter
Uğur
@UgurKurt
Apr 18 2016 11:02 UTC
function palindrome(str) {

  var clean = str.replace(/\s+|\\/g,"");
  var lowerCase = clean.toLowerCase();
  var reversed = lowerCase.split("").reverse().join("");

  if(reversed==str)
    return true;
  else
    return false;

}
why this doesnt work ?
i did other regex things too
greg
@wearenotgroot
Apr 18 2016 11:03 UTC
@UgurKurt compare the clean and the reversed, also try other regex
Uğur
@UgurKurt
Apr 18 2016 11:03 UTC
Ill try that
now everything returns true
Abdoulaye Niang
@abesn
Apr 18 2016 11:05 UTC
Thanks @sjames1958gm
I sthere anything else I need to change? Still not working...
CamperBot
@camperbot
Apr 18 2016 11:05 UTC
abesn sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 689 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
greg
@wearenotgroot
Apr 18 2016 11:05 UTC
@UgurKurt yeah you need to redo the regex
Uğur
@UgurKurt
Apr 18 2016 11:05 UTC
how ?
V Arun Kumar
@arunvkumr
Apr 18 2016 11:05 UTC
@UgurKurt you are just removing spaces and \, you need to remove all special chars.. including _.
greg
@wearenotgroot
Apr 18 2016 11:05 UTC
@UgurKurt you can replace special characters and only let alphanummeric characters remain
Rustem Garaev
@fuko4
Apr 18 2016 11:06 UTC
Hello! how to insert the code here ?
V Arun Kumar
@arunvkumr
Apr 18 2016 11:06 UTC
wiki format
CamperBot
@camperbot
Apr 18 2016 11:06 UTC

: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

Uğur
@UgurKurt
Apr 18 2016 11:06 UTC
function palindrome(str) {

  var clean = str.replace(/\s+|,|.|(|)|:|_|-|\/|\\/g,"");
  var lowerCase = clean.toLowerCase();
  var reversed = lowerCase.split("").reverse().join("");

  if(reversed==clean)
    return true;
  else
    return false;

}


palindrome("eye");
did it
still not working
Rustem Garaev
@fuko4
Apr 18 2016 11:06 UTC
Thank you!
greg
@wearenotgroot
Apr 18 2016 11:07 UTC
@UgurKurt try https://regex101.com/ and check out \W. remember _(underscore) is an alphanummeric character so you need to filter it out as well
Stephen James
@sjames1958gm
Apr 18 2016 11:07 UTC
@UgurKurt Try /\W|_/g
Uğur
@UgurKurt
Apr 18 2016 11:07 UTC
thanks man
Stephen James
@sjames1958gm
Apr 18 2016 11:07 UTC
@UgurKurt Also you should compare reversed to lowerCase not clean
Albin Karlsson
@AlbinKarlsson99
Apr 18 2016 11:07 UTC

// Setup
var a;
var b = 2;

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

Uğur
@UgurKurt
Apr 18 2016 11:07 UTC
/\W|_/g worked
Thank you a lot
Albin Karlsson
@AlbinKarlsson99
Apr 18 2016 11:08 UTC
What am doing wrong?
Alex
@alexstelmakh
Apr 18 2016 11:08 UTC
@sjames1958gm it's not a programming it's hell knows what. Can somebody give me a prepared string of code? I need to solve this : ```
myStr should have the escape sequences for backslash tab tab carriage-return new-line separated by spaces
Albin Karlsson
@AlbinKarlsson99
Apr 18 2016 11:08 UTC
What am I doing wrong?

// Setup
var a;
var b = 2;

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

Uğur
@UgurKurt
Apr 18 2016 11:08 UTC
does that mean replace all the non-alphanumerics ?
Stephen James
@sjames1958gm
Apr 18 2016 11:08 UTC
@UgurKurt Yes
Albin Karlsson
@AlbinKarlsson99
Apr 18 2016 11:08 UTC
The "level" is called Storing Values with the Assignment Operator
Rustem Garaev
@fuko4
Apr 18 2016 11:08 UTC
console.log("hello world");
V Arun Kumar
@arunvkumr
Apr 18 2016 11:09 UTC
@AlbinKarlsson99 don't declare a and b again.. you don't need var asecond time just aawould do.
greg
@wearenotgroot
Apr 18 2016 11:09 UTC
@AlbinKarlsson99 propbably need to assign a to b
Albin Karlsson
@AlbinKarlsson99
Apr 18 2016 11:09 UTC
How do i do that @wearenotgroot ?
greg
@wearenotgroot
Apr 18 2016 11:09 UTC
@AlbinKarlsson99 right now you are assigning b to a
Albin Karlsson
@AlbinKarlsson99
Apr 18 2016 11:10 UTC
Yea
greg
@wearenotgroot
Apr 18 2016 11:10 UTC
@AlbinKarlsson99 do the opposite then?
Albin Karlsson
@AlbinKarlsson99
Apr 18 2016 11:10 UTC
Do not change code above the line
a should have a value of 7
b should have a value of 7
a should be assigned to b with =
What do you mean, I dont understand ;D
greg
@wearenotgroot
Apr 18 2016 11:10 UTC
@AlbinKarlsson99 b = a not a = b
:smile:
Albin Karlsson
@AlbinKarlsson99
Apr 18 2016 11:10 UTC
Oh
Haha thanks bro
greg
@wearenotgroot
Apr 18 2016 11:11 UTC
@AlbinKarlsson99 np
Stephen James
@sjames1958gm
Apr 18 2016 11:11 UTC
@AlbinKarlsson99 b is 7 because of b = a
Alex
@alexstelmakh
Apr 18 2016 11:11 UTC
it's not a programming it's hell knows what. Can somebody give me a prepared string of code? I need to solve this : ```
myStr should have the escape sequences for backslash tab tab carriage-return new-line separated by spaces
Stephen James
@sjames1958gm
Apr 18 2016 11:12 UTC
var myStr = "\\ \t \t \r \n";
Rustem Garaev
@fuko4
Apr 18 2016 11:13 UTC
Help! Checks only the first object in the array . Then he writes that the contact can not be found .
```
CamperBot
@camperbot
Apr 18 2016 11:13 UTC
no wiki entry for: checks only the first object in the array then he writes that the contact can not be found
Stephen James
@sjames1958gm
Apr 18 2016 11:13 UTC
@alexstelmakh It is programming, it is understanding how javascript works
Rustem Garaev
@fuko4
Apr 18 2016 11:13 UTC
Help! Checks only the first object in the array . Then he writes that the contact can not be found .
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line

 for(var i = 0; i < contacts.length; i++){
    if(contacts[i].firstName === firstName){

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


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

// Change these values to test your function
lookUpProfile("Harry", "lastName");
CamperBot
@camperbot
Apr 18 2016 11:13 UTC
no wiki entry for: checks only the first object in the array then he writes that the contact can not be found setupvar contacts firstname akira lastname laine number 0543236543 likes pizza coding brownie points firstname harry lastname potter number 0994372684 likes hogwarts magic hagrid firstname sherlock lastname holmes number 0487345643 likes intriguing cases violin firstname kristian lastname vos number unknown likes javascript gaming foxes function lookupprofilefirstname prop only change code below this line forvar i 0 i contactslength i ifcontactsifirstname firstname ifcontactsiprop undefined return no such property else return contactsiprop else return no such contact only change code above this line change these values to test your functionlookupprofileharry lastname
greg
@wearenotgroot
Apr 18 2016 11:14 UTC
@fuko4 re-check your if statements
Abdoulaye Niang
@abesn
Apr 18 2016 11:15 UTC
function convertToF(celsius) {
  // Only change code below this line
var fahrenheit = celcius*(9/5)+32;
  // Only change code above this line
return fahrenheit;
}
// Change the inputs below to test your code
convertToF(0);
convertToF(-30);
convertToF(-10);
convertToF(-0);
convertToF(20);
convertToF(30);
Any help..?
Rustem Garaev
@fuko4
Apr 18 2016 11:15 UTC
@wearenotgroot 1st or 2nd?
greg
@wearenotgroot
Apr 18 2016 11:15 UTC
@fuko4 remember you have .hasOwnProperty(arg) available to check if a property exist in an object
@fuko4 second one
Alex
@alexstelmakh
Apr 18 2016 11:15 UTC
@sjames1958gm I copied and pasted this : ```
var myStr = "\ \t \t \r \n" and it doesnt work
V Arun Kumar
@arunvkumr
Apr 18 2016 11:15 UTC
@fuko4 just remove the else part of no such contact and return no such contact out of loop. that should do it.
greg
@wearenotgroot
Apr 18 2016 11:16 UTC
@fuko4 also consider what happens to the else on the other if statement
Stephen James
@sjames1958gm
Apr 18 2016 11:16 UTC
@alexstelmakh var myStr = "\\ \t \t \r \n";
Albin Karlsson
@AlbinKarlsson99
Apr 18 2016 11:16 UTC

Need some help again :D What am i doing wrong now? :( // Declarations
var StUdLyCapVaR;
var properCamelCase;
var TitleCaseOver;

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

Understanding Case Sensitivity in Variables
Stephen James
@sjames1958gm
Apr 18 2016 11:16 UTC
@abesn Make sure your variables are all the same spelling
Alex
@alexstelmakh
Apr 18 2016 11:17 UTC
@sjames1958gm it doesn't work
Abdoulaye Niang
@abesn
Apr 18 2016 11:17 UTC
@sjames1958gm
Thanks again, Man!!
Only took me 1/2 hour ..
CamperBot
@camperbot
Apr 18 2016 11:17 UTC
abesn sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: abesn already gave sjames1958gm points
greg
@wearenotgroot
Apr 18 2016 11:17 UTC
@alexstelmakh post your code
Alex
@alexstelmakh
Apr 18 2016 11:18 UTC
@sjames1958gm sorry it works
greg
@wearenotgroot
Apr 18 2016 11:18 UTC
@AlbinKarlsson99 were you supposed to do camelcase on everything?
Albin Karlsson
@AlbinKarlsson99
Apr 18 2016 11:19 UTC
I think so
greg
@wearenotgroot
Apr 18 2016 11:19 UTC
@AlbinKarlsson99 do you know how to do it?
Albin Karlsson
@AlbinKarlsson99
Apr 18 2016 11:19 UTC
I dont
Stephen James
@sjames1958gm
Apr 18 2016 11:19 UTC
@AlbinKarlsson99 Where you supposed to make the assignment names match the ones above?
cannelflow
@cannelflow
Apr 18 2016 11:19 UTC
@AlbinKarlsson99 you need to make camelCase in both Declarations and Assignments
greg
@wearenotgroot
Apr 18 2016 11:19 UTC
@AlbinKarlsson99 so you have a string which is composite of different word
@AlbinKarlsson99 the first letter of each word should be capitalized except for the very first letter of the entire string
@AlbinKarlsson99 like this one
var properCamelCase;
Albin Karlsson
@AlbinKarlsson99
Apr 18 2016 11:20 UTC
Oh
Stephen James
@sjames1958gm
Apr 18 2016 11:20 UTC
@abesn Pro-tip - open your devtools (F12 on chrome) - sometimes it will show an error that will help.
Ultras05
@Ultras05
Apr 18 2016 11:21 UTC

function abTest(a, b) {
// Only change code below this line

// Only change code above this line

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b),2));

}

// Change values below to test your code
abTest(2,-16);

help plz
CamperBot
@camperbot
Apr 18 2016 11:21 UTC
no wiki entry for: plz
cannelflow
@cannelflow
Apr 18 2016 11:21 UTC
@Ultras05 which exercise
Rustem Garaev
@fuko4
Apr 18 2016 11:21 UTC

Here error . Checks only the first element . Why?
```function lookUpProfile(firstName, prop){
// Only change code below this line

for(var i = 0; i < contacts.length; i++){
if(contacts[i].firstName === firstName){
...
}

Albin Karlsson
@AlbinKarlsson99
Apr 18 2016 11:21 UTC
Nothing changes @wearenotgroot , still the same
Rustem Garaev
@fuko4
Apr 18 2016 11:21 UTC

Here error . Checks only the first element . Why?
```function lookUpProfile(firstName, prop){
// Only change code below this line

for(var i = 0; i < contacts.length; i++){
if(contacts[i].firstName === firstName){
...
}
```

greg
@wearenotgroot
Apr 18 2016 11:22 UTC
@AlbinKarlsson99 post updated code
Albin Karlsson
@AlbinKarlsson99
Apr 18 2016 11:22 UTC

// Declarations
var studlyCapVar;
var properCamelCase;
var titleCaseOver;

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

Ultras05
@Ultras05
Apr 18 2016 11:22 UTC
@cannelflow Return Early Pattern for Functions
Stephen James
@sjames1958gm
Apr 18 2016 11:22 UTC
@fuko4 Press shift-return after ``` to get code formatting
Matthew Brener
@akkatracker
Apr 18 2016 11:22 UTC
Hey guys, how come my palindrome function is always returning true?
function palindrome(str) {
  // Good luck!
  var nowhitespace = str.replace(/\s+/g,"");
  nowhitespace = nowhitespace.toLowerCase();
  var splitString = nowhitespace.split();
  var reversed = splitString;
  reversed.reverse();
  if(splitString == reversed){
    return true;
  }else{
    return false;
  }
}
Stephen James
@sjames1958gm
Apr 18 2016 11:22 UTC
@AlbinKarlsson99 Make the assignments match
V Arun Kumar
@arunvkumr
Apr 18 2016 11:22 UTC
@fuko4 your code was fine.. only thing you had to do was to move the no such contact outside the loop.
Stephen James
@sjames1958gm
Apr 18 2016 11:23 UTC
@akkatracker reverse doesn't modify the array it returns a reversed array
cannelflow
@cannelflow
Apr 18 2016 11:23 UTC
@Ultras05 if(a is less then 0 or b is less then 0) return undefined
Stephen James
@sjames1958gm
Apr 18 2016 11:24 UTC
@akkatracker But you can call it on splitString to return the reversed array
Matthew Brener
@akkatracker
Apr 18 2016 11:24 UTC
@sjames1958gm thanks but it still doesn't work:
function palindrome(str) {
  // Good luck!
  var nowhitespace = str.replace(/\s+/g,"");
  nowhitespace = nowhitespace.toLowerCase();
  var splitString = nowhitespace.split();
  var reversed = splitString.reverse();
  if(splitString == reversed){
    return true;
  }else{
    return false;
  }
}



palindrome("eye");
CamperBot
@camperbot
Apr 18 2016 11:24 UTC
akkatracker sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 690 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Albin Karlsson
@AlbinKarlsson99
Apr 18 2016 11:24 UTC
Oh thanks @sjames1958gm and @wearenotgroot
CamperBot
@camperbot
Apr 18 2016 11:24 UTC
albinkarlsson99 sends brownie points to @sjames1958gm and @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 1021 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
:star: 691 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
V Arun Kumar
@arunvkumr
Apr 18 2016 11:24 UTC
@fuko4 paste your code again.. with formating
Stephen James
@sjames1958gm
Apr 18 2016 11:25 UTC
@akkatracker Where is it not working - use console.log and devtools console to see the various values
Ultras05
@Ultras05
Apr 18 2016 11:25 UTC
@cannelflow it doesnt work
Rustem Garaev
@fuko4
Apr 18 2016 11:25 UTC
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line

 for(var i = 0; i < contacts.length; i++){
    if(contacts[i].firstName === firstName){

      if(contacts[i].hasOwnProperty(prop)){
        return contacts[i][prop];
      }
      else{

        return "No such property";
      }


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

// Change these values to test your function
lookUpProfile("Harry", "lastName");