These are chat archives for FreeCodeCamp/HelpJavaScript

10th
Jun 2017
andrewmparker
@andrewmparker
Jun 10 2017 00:14

function findLongestWord(str) {
var splitWord = str.split('');
var longest = 0;
var word = null;
for ( var i = 0; i <splitWord.length - 1; i++){
if (longest < splitWord[i].length){
longest = splitWord[i].length;
word = splitWord[i];
}
}

return word;
}

findLongestWord("The quick brown fox jumped over the lazy dog"); Does someone see something wrong in this?????

Agata
@agatakj
Jun 10 2017 00:14
You should use two double quotes (") and four escaped double quotes (\").
Variable myStr should contain the string: I am a "double quoted" string inside "double quotes".
var myStr = "I am a \"double quoted\" string inside \"double quotes\"";
What is wrong ?
my error Variable myStr should contain the string: I am a "double quoted" string inside "double quotes".
omarraza
@omarraza
Jun 10 2017 00:17
can anyone explain what is happening in the return portion here? Specifically the offset ? we haven't encountered anything like this
function upperToHyphenLower(match, offset, string) {
    return (offset ? '-' : '') + match.toLowerCase();
  }
Agata
@agatakj
Jun 10 2017 00:18
Anyone there?
andrewmparker
@andrewmparker
Jun 10 2017 00:18
hello
Moisés Man
@moigithub
Jun 10 2017 00:18
missing dot at the end @agatakj
Agata
@agatakj
Jun 10 2017 00:19
@moigithub THANK YOU
CamperBot
@camperbot
Jun 10 2017 00:19
agatakj sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3347 | @moigithub |http://www.freecodecamp.com/moigithub
omarraza
@omarraza
Jun 10 2017 00:22
@sjames1958gm Gotham needs you
Veronica Eulenberg
@HappyViki
Jun 10 2017 00:25
Why isn’t this returning if contacts contains the property?
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i=0; i > contacts.length; i++){
  if (contacts[i].hasOwnProperty(firstName)){
    return "lol";
  } else {
    return "nope";
  }
}
Stephen James
@sjames1958gm
Jun 10 2017 00:25
@omarraza It is basically saying if offset (or index) is greater that 0 put in a "-" else empty string.
@omarraza It is using the fact that index / offset === 0 is falsy
@HappyViki i > contacts.length ??
Veronica Eulenberg
@HappyViki
Jun 10 2017 00:27
I donno it’s confusing. I’ll start from scratch and just keep returning things.
that returns {
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
}
omarraza
@omarraza
Jun 10 2017 00:28
@sjames1958gm Thank you, you are the best. Much obliged
CamperBot
@camperbot
Jun 10 2017 00:28
omarraza sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7697 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 10 2017 00:28
@omarraza You are welcome
Veronica Eulenberg
@HappyViki
Jun 10 2017 00:29
@sjames1958gm I’ll get back to you later. I’ll try to figure it out a bit by myself.
omarraza
@omarraza
Jun 10 2017 00:29
@HappyViki He's implying that the i > contacts.length portion of your code is strange
Veronica Eulenberg
@HappyViki
Jun 10 2017 00:30
@omarraza why is it strange?
omarraza
@omarraza
Jun 10 2017 00:30
Take a look at it again and think about how a for loop works
Veronica Eulenberg
@HappyViki
Jun 10 2017 00:31
@omarraza it’s supposed to be i<something.length?
omarraza
@omarraza
Jun 10 2017 00:31
bingo
Veronica Eulenberg
@HappyViki
Jun 10 2017 00:31
oh lol
omarraza
@omarraza
Jun 10 2017 00:32
remember that a for loop has 3 parts. The 2nd part tells the loop "run until...." or "run while..."
Veronica Eulenberg
@HappyViki
Jun 10 2017 00:33
yeah…I’m just bad with my less-than more-than signs.
Darius
@smileyjuice
Jun 10 2017 00:40
Why doesn't this work

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

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

Veronica Eulenberg
@HappyViki
Jun 10 2017 00:40
@omarraza What about this? What’s wrong with it?
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i=0; i < contacts.length; i++){
    if (contacts[i].hasOwnProperty(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
}
Darius
@smileyjuice
Jun 10 2017 00:41
This message was deleted
This message was deleted
Veronica Eulenberg
@HappyViki
Jun 10 2017 00:42
@omarraza Like…how do I check if the section with a certain property contains another certain property?
omarraza
@omarraza
Jun 10 2017 00:42
@smileyjuice do the ``` above and below all of your code
Darius
@smileyjuice
Jun 10 2017 00:43
function titleCase(str) {
  str = str.toLowerCase().split(" ");
  for (i = 0; i < str.length; i++) {
    str[i][0].toUpperCase();
  }
  return str.join(' ');
}


titleCase("I'm a little tea pot");
omarraza
@omarraza
Jun 10 2017 00:43
@HappyViki can you show me an example
Darius
@smileyjuice
Jun 10 2017 00:44
@HappyViki
It shouldn't be checking if it has a firstname property, but instead if the first name property matches with the argument.
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";
      }
    }
  }
  return "No such contact";
// Only change code above this line
}
like that i believe
Veronica Eulenberg
@HappyViki
Jun 10 2017 00:45
@omarraza Wait…what do you mean?
@smileyjuice I’ll check
@smileyjuice Thanks for the answer. My brain is still pretty boggled as to how it works.
CamperBot
@camperbot
Jun 10 2017 00:47
happyviki sends brownie points to @smileyjuice :sparkles: :thumbsup: :sparkles:
:warning: @smileyjuice's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Darius
@smileyjuice
Jun 10 2017 00:49
In your first if statement, Javascript is checking whether there is a firstName property, not whether they match with the argument.
So by changing it to
(contacts[i].firstName === firstName)
it's checking whether the argument that you entered matches what's in the list.
omarraza
@omarraza
Jun 10 2017 00:50
@smileyjuice your loop is overwriting str every time
Veronica Eulenberg
@HappyViki
Jun 10 2017 00:50
@smileyjuice I’m sort of getting it. I think I’ll get it after tonight. I usually get it when I sleep on it lol
Darius
@smileyjuice
Jun 10 2017 00:50
good luck
Veronica Eulenberg
@HappyViki
Jun 10 2017 00:50
:P
Darius
@smileyjuice
Jun 10 2017 00:50
@omarraza I kind of guessed that, but I don't know what to do about it.
omarraza
@omarraza
Jun 10 2017 00:52
So what type of object is str inside of your loop?
Darius
@smileyjuice
Jun 10 2017 00:53
An array?
because i used the .split() method.
omarraza
@omarraza
Jun 10 2017 00:53
Yes! So how do you add values to an array without constantly overwriting everything?
Darius
@smileyjuice
Jun 10 2017 00:55
Unshift maybe?
I'm not sure...
or .concat()?
andrewmparker
@andrewmparker
Jun 10 2017 00:56

function titleCase(str) {
var newStr = str.split(' ').toLowerCase();
for (var i = 0; i < newStr.length; i++){
newStr[i] = Str[i].charAt(0).toUpperCase() + newStr[i].slice(1);
}
return newStr.join(' ');
}

titleCase("I'm a little tea pot"); It says TypeError: str.split(' ').toLowerCase is not a function What do I need to change???

omarraza
@omarraza
Jun 10 2017 00:56
unshift() is close. It adds on to the array but returns the length
push() is what you want
Darius
@smileyjuice
Jun 10 2017 00:57
oh
How would that work? I thought push adds a value to the end?
And I want to change the first value to make it capitalized.
andrewmparker
@andrewmparker
Jun 10 2017 01:00
anybody know what i need to change???
Moisés Man
@moigithub
Jun 10 2017 01:05
@andrewmparker what split does ?
what result u get after applying split( ' ' ) with a space on str
andrewmparker
@andrewmparker
Jun 10 2017 01:05
i am using it to split up the sentence
Zotha
@Zotha
Jun 10 2017 01:07
Hello everyone
andrewmparker
@andrewmparker
Jun 10 2017 01:08
@moigithub what do you mean by space on str???
Moisés Man
@moigithub
Jun 10 2017 01:08
@andrewmparker u can test here.. if u dont know
https://repl.it/languages/javascript
or on ur browser devtools console
example:
"hello world".split(' ') what result u get ?
"I'm a little tea pot".split(' ')
andrewmparker
@andrewmparker
Jun 10 2017 01:10
undefined
Darius
@smileyjuice
Jun 10 2017 01:10
no
you would get
["hello", "world"] and
["I'm", "a", "little", "tea", "pot"]
it separates each word in reference to the space
andrewmparker
@andrewmparker
Jun 10 2017 01:11
yeah lol i made a mistake
Moisés Man
@moigithub
Jun 10 2017 01:11
soo.. u get an ARRAY of words
andrewmparker
@andrewmparker
Jun 10 2017 01:11
yes
Moisés Man
@moigithub
Jun 10 2017 01:11
.toUpperCase() method works ONLY on strings.. not on arrays
andrewmparker
@andrewmparker
Jun 10 2017 01:12
oh
so what would i use @moigithub
Moisés Man
@moigithub
Jun 10 2017 01:12
soo u cant do str.split(' ').toUpperCase()
apply toUpperCase to the string first...then u can split
str.toUpperCase().split(' ')
MJ
@mjcello
Jun 10 2017 01:13

Not sure what I"m doing wrong; here's what I have so far for the switch statement exercise:

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

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

it isn't returning anything :/
Moisés Man
@moigithub
Jun 10 2017 01:13
u need to evaluate val variable on ur switch function caseInSwitch(val) {
and assign "alpha" to answer variable
MJ
@mjcello
Jun 10 2017 01:15
ohhhhh
andrewmparker
@andrewmparker
Jun 10 2017 01:15

function titleCase(str) {
var newStr = str.toLowerCase().split(' ');
for (var i = 0; i < newStr.length; i++){
newStr[i] = Str[i].charAt(0).toUpperCase() + newStr[i].slice(1);
}
return newStr.join(' ');
}

titleCase("I'm a little tea pot"); @moigithub why is it saying str is undefined????

MJ
@mjcello
Jun 10 2017 01:15
thank you! I got it now.
Moisés Man
@moigithub
Jun 10 2017 01:15
when u CALL the function ie: caseInSwitch(1) <--u pass a value there
that value will be assigned to val
Darius
@smileyjuice
Jun 10 2017 01:16
function titleCase(str) {
  str = str.toLowerCase().split(' ');
  for (var i = 0; i < str.length; i++) {
    str[i] = str[i].charAt(0).toUpperCase() + str[i].slice(1); 
  }
  return str.join(' ');
}
titleCase("I'm a little tea pot");
Moisés Man
@moigithub
Jun 10 2017 01:17
newStr[i] = Str[i].cha...
whats Str ?? @andrewmparker
FrostDrive
@FrostDrive
Jun 10 2017 01:17
Am I using dot and brakcet notation correctly to access myStorage?

var myStorage = {
"car": {
"inside": {
"glovebox": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line

var gloveBoxContents = myStorage.car.inside.glovebox;

Moisés Man
@moigithub
Jun 10 2017 01:17

@FrostDrive

// Only change code below this line

make sure u dont change anything else when u write ur code.. reset n redo again

andrewmparker
@andrewmparker
Jun 10 2017 01:17
just saw that thx @moigithub @smileyjuice
CamperBot
@camperbot
Jun 10 2017 01:17
andrewmparker sends brownie points to @moigithub and @smileyjuice :sparkles: :thumbsup: :sparkles:
:cookie: 140 | @smileyjuice |http://www.freecodecamp.com/smileyjuice
:star2: 3348 | @moigithub |http://www.freecodecamp.com/moigithub
Darius
@smileyjuice
Jun 10 2017 01:19
@FrostDrive Just to make things easier, when you're writing the name of the property, not the value, you don't need to use quotation marks.
FrostDrive
@FrostDrive
Jun 10 2017 01:20
@smileyjuice Thanks for your help! That worked (:
CamperBot
@camperbot
Jun 10 2017 01:20
:cookie: 141 | @smileyjuice |http://www.freecodecamp.com/smileyjuice
frostdrive sends brownie points to @smileyjuice :sparkles: :thumbsup: :sparkles:
Joseph
@revisualize
Jun 10 2017 01:25
@FrostDrive Isn't it supposed to be "glove box" with a space?
Lance Ward
@Lanceward410
Jun 10 2017 01:29
@camperbot thanks
CamperBot
@camperbot
Jun 10 2017 01:29
lanceward410 sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 3309 | @camperbot |http://www.freecodecamp.com/camperbot
James R. Roberts
@jamesraymondroberts
Jun 10 2017 01:30
Concatenating Strings with the Plus Equals Operator with this one I tried creating the variable myStr then after the fact using =+ to concanate two strings but its a no go
Manish Giri
@Manish-Giri
Jun 10 2017 01:31
@jamesraymondroberts code?
James R. Roberts
@jamesraymondroberts
Jun 10 2017 01:32
var myStr = "This is the first sentence.";
myStr += " This is the second sentence.";
I declare the variable then say it is that variable and in addition add string "This is the second sentence/"
no backslash that was a typo
Manish Giri
@Manish-Giri
Jun 10 2017 01:33
@jamesraymondroberts need a space
between the sentences.
Lance Ward
@Lanceward410
Jun 10 2017 01:34
@jamesraymondroberts You are correct in that you have a space already, but the directions require that space to be placed somewhere else. Very picky.
codeloopy
@codeloopy
Jun 10 2017 01:34
Hey guys
good evening
James R. Roberts
@jamesraymondroberts
Jun 10 2017 01:34
Dang. It is picky then. The error it was throwing didn't make it sound like that's what it was looking for:Use the += operator to build myStr
Lance Ward
@Lanceward410
Jun 10 2017 01:35
I still can't get over how long I was staring at my 'incorrect' JS code yesterday not able to figure out that "No such Contact" was supposed to be "No such contact"
James R. Roberts
@jamesraymondroberts
Jun 10 2017 01:35
@Lanceward410 thanks @Manish-Giri thanks
CamperBot
@camperbot
Jun 10 2017 01:35
jamesraymondroberts sends brownie points to @lanceward410 and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 230 | @lanceward410 |http://www.freecodecamp.com/lanceward410
:star2: 5919 | @manish-giri |http://www.freecodecamp.com/manish-giri
codeloopy
@codeloopy
Jun 10 2017 01:35
quick question I'm on exercise Testing Objects for Properties (JS) and kinda confused about something
this is my code

// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here

if(myObj.hasOwnProperty(checkProp)){
return myObj[checkProp];
} else {
return "Not Found";
}
}

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

Manish Giri
@Manish-Giri
Jun 10 2017 01:35
question?
codeloopy
@codeloopy
Jun 10 2017 01:36
how come when I can access the myObj prperty with the brackets notation
but when I try myObj.checkProp it doesn't work
isn't it either or?
brackets or dot notation
Manish Giri
@Manish-Giri
Jun 10 2017 01:36
because myObj.checkProp looks for a property called checkProp, literally.
when it's in a variable, you gotta use [ ] notation.
codeloopy
@codeloopy
Jun 10 2017 01:37
uh? I'm soooo sorry
ooooooh
ok
but doesn't JS know the value stored in it already?
oh nm nm nm
I got it ...
so if I'm passing the actual value I can use either, but when it's a var I have to use brackets?
right?
@Manish-Giri ... yo'da man! really appreciate it.
tnx guys
good night
Manish Giri
@Manish-Giri
Jun 10 2017 01:39
:+1:
Lance Ward
@Lanceward410
Jun 10 2017 01:39
The show goes on all night
Or whatever that lyric is to that song I like
James R. Roberts
@jamesraymondroberts
Jun 10 2017 01:45
@Manish-Giri still can't get it to work even after messing with where my space is. var myStr = "This is the first sentence. ";
myStr += "This is the second sentence.";
Manish Giri
@Manish-Giri
Jun 10 2017 01:46
@jamesraymondroberts post your challenge url, click "run tests" first.
James R. Roberts
@jamesraymondroberts
Jun 10 2017 01:46
It's like the += is not being recognized

my error:

myStr = "This is the first sentence. This is the second sentence."

myStr should have a value of This is the first sentence. This is the second sentence.
Use the += operator to build myStr

Manish Giri
@Manish-Giri
Jun 10 2017 01:47
post the URL
I didn't ask for the instructions
Manish Giri
@Manish-Giri
Jun 10 2017 01:48
this is all your code?
// Example
var ourStr = "I come first. ";
ourStr += "I come second.";

// Only change code below this line

var myStr;
James R. Roberts
@jamesraymondroberts
Jun 10 2017 01:48
I cleared it out and reset
Manish Giri
@Manish-Giri
Jun 10 2017 01:48
sigh
James R. Roberts
@jamesraymondroberts
Jun 10 2017 01:49
I got it!
FreeCodeCamp is just too buggy sometimes. Same code after numerous refreshes and cleared caches workds all the sudden. Weak,
thansk for the help though I didn't know about those spaces
Joseph
@revisualize
Jun 10 2017 01:50
@jamesraymondroberts Bugs? I have completed all of the beginner challenges multiple times. I haven't experience too many bugs.
James R. Roberts
@jamesraymondroberts
Jun 10 2017 01:51
@revisualize really? no cursor placement issues (not lag) or anything like that?
Joseph
@revisualize
Jun 10 2017 01:52
@jamesraymondroberts Lag isn't a bug.
@jamesraymondroberts I don't know what you mean by cursor placement issues. If I place the cursor somewhere. That's where it goes.
@jamesraymondroberts I've completed freeCodeCamp issues on my Ubuntu computer in Chrome. I've also completed them on my Windows 10 Enterprise Surface Pro 4 and my personal Windows 10 Home computer.
intervolver
@intervolver
Jun 10 2017 02:02
hey, I'm having problems with this basic javascript lesson: https://www.freecodecamp.com/challenges/profile-lookup
the following code can access the first position in the array object without issue and check its properties, but it doesn't seem to be able to iterate through the array to check other entries:
  var i = 0;
  while (i < contacts.length) {
    if (contacts[i].firstName == firstName) {
      if (contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
      }
      else {
        return "No such property";
      }
    }
    else {
      return "No such contact";

    }

    i++;
  }
Ellyria
@Ellyria
Jun 10 2017 02:14
This message was deleted
intervolver
@intervolver
Jun 10 2017 02:16
is i++; not changing i properly?
Ellyria
@Ellyria
Jun 10 2017 02:17
Well, you do have i++ in there, which is why I deleted what I wrote, but if you look at it, if it fulfills the first test, it won't increment there because the return will take it completely out of the loop.
So by the time it gets to the i++, it's not in a loop any more. I must be tired. It's not in a conditional any more.
intervolver
@intervolver
Jun 10 2017 02:17
oh, and then it reinstantiates i to 0?
Coy Sanders
@coymeetsworld
Jun 10 2017 02:17
that i++ will never get executed
Ellyria
@Ellyria
Jun 10 2017 02:18
No, I would think it increases it by 1, but it doesn't send it back through the if conditional.
Coy Sanders
@coymeetsworld
Jun 10 2017 02:18
theres no situations where that will run
the logic inside the loop is not correct
Ellyria
@Ellyria
Jun 10 2017 02:19
The way I would do it is to increment i before the return on any success, wherever that may be.
Coy Sanders
@coymeetsworld
Jun 10 2017 02:20
if you're going to return something it doesn't matter if you increment i or not, when you return you're done
Ellyria
@Ellyria
Jun 10 2017 02:21
Well, you're done with whatever you were in, but the incremented i may still have some power outside of that.
Coy Sanders
@coymeetsworld
Jun 10 2017 02:21
having said that, im not sure why a for loop isn't being used here. no reason to use a while loop
intervolver
@intervolver
Jun 10 2017 02:22
the lesson right before it (iterate with javascript while loops) introduced the while loop, perhaps that was a red herring
Coy Sanders
@coymeetsworld
Jun 10 2017 02:22
no you could use while loops
but a for loop would be better
Ellyria
@Ellyria
Jun 10 2017 02:23
You can actually use either. It's just that you have to do more work if you use a while loop because you've got to manually increment i inside of each loop, whereas you just have to do it once with the for loop.
Coy Sanders
@coymeetsworld
Jun 10 2017 02:23
i++ still needs to be written, just that you can define and increment all in one place
Ellyria
@Ellyria
Jun 10 2017 02:23
Yep, making it less "busy".
Coy Sanders
@coymeetsworld
Jun 10 2017 02:23
the code is more succinct that way
intervolver
@intervolver
Jun 10 2017 02:24
I'll reread the for section, I assumed I was supposed to use a why
Joseph
@revisualize
Jun 10 2017 02:24
YO!
Coy Sanders
@coymeetsworld
Jun 10 2017 02:24

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

looks better than

var i = 0;
while (i < contacts.length) {
...
...
i++
}
Joseph
@revisualize
Jun 10 2017 02:24
@coymeetsworld Do you POSH?
Ellyria
@Ellyria
Jun 10 2017 02:24
Heh, I often find that my first round of code, whenever I start something new, is bulky, to say the least. Then, as I look it over, I whittle away at it until it becomes a sleek, streamlined piece of art. Wait, I might be dreaming here.
Coy Sanders
@coymeetsworld
Jun 10 2017 02:25
@revisualize yes
Ellyria
@Ellyria
Jun 10 2017 02:25
Yes, agreed.
Coy Sanders
@coymeetsworld
Jun 10 2017 02:25
@Ellyria thats normal
Joseph
@revisualize
Jun 10 2017 02:25
@coymeetsworld Do you have on-prem exch and o365? I'm wondering how if you create your user mailboxes via posh.
Coy Sanders
@coymeetsworld
Jun 10 2017 02:25
refactoring comes later
Ellyria
@Ellyria
Jun 10 2017 02:26
Good, because I tend to do it rather often.
Coy Sanders
@coymeetsworld
Jun 10 2017 02:26
wait thought you meant something else @revisualize
i don't deal w/ exchange no
Ellyria
@Ellyria
Jun 10 2017 02:26
My current project has bulky (but working!) code and needs some love and attention.
Joseph
@revisualize
Jun 10 2017 02:26
POSH is short for PowerShell
Ayush Kumar
@Gr8ayu
Jun 10 2017 02:26
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> is this link for bootstrap 3 ??????
Coy Sanders
@coymeetsworld
Jun 10 2017 02:27
ah no I just use bash
don't do much with windows
Joseph
@revisualize
Jun 10 2017 02:27
@coymeetsworld Ahh.
Ellyria
@Ellyria
Jun 10 2017 02:27
3.3.7, specifically, yep.
Joseph
@revisualize
Jun 10 2017 02:27
@coymeetsworld Wait... w.t.f. did you think POSH meant?
Coy Sanders
@coymeetsworld
Jun 10 2017 02:27
thought you were making a joke, i was talking about elegant code
Joseph
@revisualize
Jun 10 2017 02:28
I'm trying to create a script for automating user account creation.
Lance Ward
@Lanceward410
Jun 10 2017 02:28
I was just in the chinese chat room... Cool people over there, they like the Cavs
Coy Sanders
@coymeetsworld
Jun 10 2017 02:28
cavs suck
Lance Ward
@Lanceward410
Jun 10 2017 02:28
I'm a Washington Wizards guy
Coy Sanders
@coymeetsworld
Jun 10 2017 02:28
this game is a joke right now
Kyle Holm
@thekholm80
Jun 10 2017 02:29
I also enjoy sports teams
go sports go
Coy Sanders
@coymeetsworld
Jun 10 2017 02:29
go sports
Kyle Holm
@thekholm80
Jun 10 2017 02:29
hi coy
Lance Ward
@Lanceward410
Jun 10 2017 02:29
I don't watch sports at all really lol, but I know this is a big one
Coy Sanders
@coymeetsworld
Jun 10 2017 02:29
:wave:
yeah its the finals, warriors are 15-0 in postseason which is already a record. one more win they get championship
refs are making alot of questionable calls, possibly for money
NBA stands to lose millions if the rest of the games aren't played out
intervolver
@intervolver
Jun 10 2017 02:31
I changed that to a for loop, and now it doesn't even run the code inside it, however, the same code in the while loop at least checked the first entry in the array
as suggested: for (var i = 0; i < contacts.length, i++;)
err for (var i = 0; i < contacts.length; i++)
now it's returning the "likes" property of the second array entry as well
Coy Sanders
@coymeetsworld
Jun 10 2017 02:33
thats fine @intervolver but there was something wrong with your if/else statements
the way the code was written it only would loop once, no matter what
need to fix that
intervolver
@intervolver
Jun 10 2017 02:33
alright, I'll reassess them
is it return that's stopping the loop?
Kyle Holm
@thekholm80
Jun 10 2017 02:35
loops stop at return
Lance Ward
@Lanceward410
Jun 10 2017 02:35
That may be very likely^
Coy Sanders
@coymeetsworld
Jun 10 2017 02:36
return exits out of the context you're in, in this case a function
Greg Lawrence
@Chewieez
Jun 10 2017 02:36
Can someone tell me why I'm getting a lot of errors that say "array.toUpperCase" is not a function? I don't have a solid amount of code to share, but I'm currently working on 'Title Case a Sentence' js algorithm challenge. I had this error on my last exercise as well and ended up defining a function outside of my normal code, then referencing it. But once I got that code to work, I re-wrote it without the reference and it worked so I'm not sure why I was getting the error.
I imagine I'm not giving enough back story yet.
Basically it seems like I'm inputing something that should be a function and it's giving me an error stating it's not a function
Kyle Holm
@thekholm80
Jun 10 2017 02:37
.toUpperCase() is a string function
Coy Sanders
@coymeetsworld
Jun 10 2017 02:37
Array doesn't have a toUpperCase function
:point_up:
Greg Lawrence
@Chewieez
Jun 10 2017 02:38
ok, I've used other names. Array just happens to be what I'm naming it now, probably poorly
ok maybe that's it for this example. I took a string and split it into an array of strings.
Then I was trying to access the characters in each string, inside the array, and .toUpperCase just the first character.
Kyle Holm
@thekholm80
Jun 10 2017 02:40
makes sense
Greg Lawrence
@Chewieez
Jun 10 2017 02:40
I thought substring(0, 1) would help but I couldnt' get that to work.
May just need more study
Kyle Holm
@thekholm80
Jun 10 2017 02:40
anyone who says they don't need more study is lying lol
Greg Lawrence
@Chewieez
Jun 10 2017 02:41
Well I guess I'm trying to decide if I'm doing the wrong thing, or just doing the right thing incorrectly. :)
FlashHero
@FlashHero
Jun 10 2017 02:43
what is a header in jquery ajax
Toby J. Henderson
@Mr-Henderson
Jun 10 2017 02:45
hmm please help with challenge 137 not sure how to incorporate the % operator??
Kyle Holm
@thekholm80
Jun 10 2017 02:45
when you make any kind of get / put / post etc request your browser sends a header filled with information about who/what is making the request, and the response comes with a header telling your browser what to expect in the response
Lance Ward
@Lanceward410
Jun 10 2017 02:45
5 % 2 = 1
Because 2 goes into 5 twice (4), and ONE is left over
one is the remainder
Kyle Holm
@thekholm80
Jun 10 2017 02:46
<3 modulo
FlashHero
@FlashHero
Jun 10 2017 02:47
@thekholm80 ok thanks
CamperBot
@camperbot
Jun 10 2017 02:47
flashhero sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1006 | @thekholm80 |http://www.freecodecamp.com/thekholm80
Greg Lawrence
@Chewieez
Jun 10 2017 02:47
AHHH! I got it!
function titleCase(str) {
  str = str.toLowerCase().split(" ");

  for (i = 0; i <= str.length - 1; i++) {
    str[i] = str[i].charAt(0).toUpperCase() + str[i].substring(1);
  }

  str = str.join(" ");

  return str;
}

titleCase("I'm a little tea pot");
Lance Ward
@Lanceward410
Jun 10 2017 02:48
@Chewieez Nice
Kyle Holm
@thekholm80
Jun 10 2017 02:49
@Chewieez you can also use bracket notation on a string to get just a letter
var string = "hello";
console.log(string[0]);  // logs "h"
Coy Sanders
@coymeetsworld
Jun 10 2017 02:49
str should be renamed to arr, since thats an array
Greg Lawrence
@Chewieez
Jun 10 2017 02:49

I was getting the error again because I forgot to put the array bracket after str.substring. Since my var was an array not a string, it was erroring out. (as I understand it)

Thanks for the help @thekholm80 @coymeetsworld

CamperBot
@camperbot
Jun 10 2017 02:49
chewieez sends brownie points to @thekholm80 and @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1007 | @thekholm80 |http://www.freecodecamp.com/thekholm80
:star2: 2765 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 10 2017 02:49
split() returns an array
np
Kyle Holm
@thekholm80
Jun 10 2017 02:49
@Chewieez good job!
Manish Giri
@Manish-Giri
Jun 10 2017 02:49
someone switched rooms
:smirk:
Greg Lawrence
@Chewieez
Jun 10 2017 02:50
Ok, thanks. I get that would make it more understandable
I haven't gotten the swing of commenting code or best practice of naming var yet. :)
Kyle Holm
@thekholm80
Jun 10 2017 02:50
I needed to see something besides "my h2 isn't blue" for a while @Manish-Giri
Manish Giri
@Manish-Giri
Jun 10 2017 02:50
lol
my h2 isn't orange help
@thekholm80
Coy Sanders
@coymeetsworld
Jun 10 2017 02:50
get good enough you wont even use vars
Kyle Holm
@thekholm80
Jun 10 2017 02:51
@Manish-Giri finished my tutorial, part 2 will publish next Friday.
turned out pretty good
intervolver
@intervolver
Jun 10 2017 02:51
I finally got it, thanks @coymeetsworld
CamperBot
@camperbot
Jun 10 2017 02:51
intervolver sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2766 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
intervolver
@intervolver
Jun 10 2017 02:51
thanks @Ellyria
CamperBot
@camperbot
Jun 10 2017 02:51
intervolver sends brownie points to @ellyria :sparkles: :thumbsup: :sparkles:
:cookie: 427 | @ellyria |http://www.freecodecamp.com/ellyria
Coy Sanders
@coymeetsworld
Jun 10 2017 02:51
np
Manish Giri
@Manish-Giri
Jun 10 2017 02:51
@thekholm80 I'd do a video tutorial if I were you..
more effective than posts.
intervolver
@intervolver
Jun 10 2017 02:52
I didn't understand that return would always break a loop
Manish Giri
@Manish-Giri
Jun 10 2017 02:52
but I hate my voice, so
Alexander Køpke
@alexanderkopke
Jun 10 2017 02:52
@coymeetsworld you mean let and const?
Coy Sanders
@coymeetsworld
Jun 10 2017 02:52
no not even those
Lance Ward
@Lanceward410
Jun 10 2017 02:52
return breaks solid concrete
Kyle Holm
@thekholm80
Jun 10 2017 02:52
yeah, I know. Reading is hard. I just don't have the setup for video right now
Greg Lawrence
@Chewieez
Jun 10 2017 02:52
@coymeetsworld Does this look better?
function titleCase(str) {
  var arr = str.toLowerCase().split(" ");

  for (i = 0; i <= arr.length - 1; i++) {
    arr[i] = arr[i].charAt(0).toUpperCase() + arr[i].substring(1);
  }

  var newStr = arr.join(" ");

  return newStr;
}

titleCase("I'm a little tea pot");
Manish Giri
@Manish-Giri
Jun 10 2017 02:52
maybe chaining methods?
no need for temp vars
Coy Sanders
@coymeetsworld
Jun 10 2017 02:52
i solved title case w/o defining a variable
Kyle Holm
@thekholm80
Jun 10 2017 02:52
same!
Coy Sanders
@coymeetsworld
Jun 10 2017 02:52
:thumbsup:
Alexander Køpke
@alexanderkopke
Jun 10 2017 02:52
oh ok
Kyle Holm
@thekholm80
Jun 10 2017 02:52
can all be chained on the return
Greg Lawrence
@Chewieez
Jun 10 2017 02:53
Great thx
Manish Giri
@Manish-Giri
Jun 10 2017 02:53
code().sleep().repeat()
Lance Ward
@Lanceward410
Jun 10 2017 02:53
@Manish-Giri Hey it won't matter that you hate it later when everyone is learning coding from your videos and loving it!
Manish Giri
@Manish-Giri
Jun 10 2017 02:53
um
Lance Ward
@Lanceward410
Jun 10 2017 02:55
I made assumptions too quickly. I see now you probably aren't planning on making videos lol
Manish Giri
@Manish-Giri
Jun 10 2017 02:55
lol
I'd love to
Kyle Holm
@thekholm80
Jun 10 2017 02:55
hire a voice actor?
Manish Giri
@Manish-Giri
Jun 10 2017 02:55
but I don't have the right equipment
I'm too broke to get it
Kyle Holm
@thekholm80
Jun 10 2017 02:56
I'd just need a decent mic I think
Lance Ward
@Lanceward410
Jun 10 2017 02:56
bingo! Sony Vegas 16, a $40 Blue mic from craigslist, and a free screen recorder
Toby J. Henderson
@Mr-Henderson
Jun 10 2017 02:56
no idea how to use the % operator in this lesson hahaha ..remainder = 11 % 3; that was it???
Kyle Holm
@thekholm80
Jun 10 2017 02:57
11 % 3 = 2
Csaba Balogh
@JasonCorp84
Jun 10 2017 02:57
Good evening everyone !
I am working on my weather app. However since the api work via http the connection is refused by codepen
does anyone know solution ?
I try to use openweather map
Kyle Holm
@thekholm80
Jun 10 2017 02:57
Are you getting an error?
Csaba Balogh
@JasonCorp84
Jun 10 2017 02:58
net::ERR_CONNECTION_REFUSED
Lance Ward
@Lanceward410
Jun 10 2017 02:58
(p.s. The $400-500 video editor Sony vegas 16 is free if you search long enough)
Csaba Balogh
@JasonCorp84
Jun 10 2017 02:58
This request has been blocked; the content must be served over HTTPS.
Kyle Holm
@thekholm80
Jun 10 2017 02:58
so change your codepen url to https
Csaba Balogh
@JasonCorp84
Jun 10 2017 02:59
I did
that is when I got my second error
this: net::ERR_CONNECTION_REFUSED
Coy Sanders
@coymeetsworld
Jun 10 2017 02:59
@thekholm80 codepen only uses https now
Kyle Holm
@thekholm80
Jun 10 2017 02:59
oh, new information
Kyle Holm
@thekholm80
Jun 10 2017 02:59
@JasonCorp84 do you have a link to the pen? then we can see
@coymeetsworld I should add them on twitter
Coy Sanders
@coymeetsworld
Jun 10 2017 03:00
yeah maybe
Kyle Holm
@thekholm80
Jun 10 2017 03:03
@JasonCorp84 I think the problem is your api address. I can' t get it to load outside your pen
Csaba Balogh
@JasonCorp84
Jun 10 2017 03:04
change it to http
Kyle Holm
@thekholm80
Jun 10 2017 03:04
yeah, that worked
Toby J. Henderson
@Mr-Henderson
Jun 10 2017 03:04
'\;
ppp-;b pn,; \,m/;
Coy Sanders
@coymeetsworld
Jun 10 2017 03:06
...
Elliw Seehorn
@ellsee
Jun 10 2017 03:10
how can you accomplish the challenge "quoting strings with single quotes" without commenting out most of your line/link
Coy Sanders
@coymeetsworld
Jun 10 2017 03:12
not sure I understand @ellsee, you don't need to comment out anything
Lance Ward
@Lanceward410
Jun 10 2017 03:13
I think she meant she didn't want the answer given to her :D
Coy Sanders
@coymeetsworld
Jun 10 2017 03:13
I understand that part, just not what she meant by comment out
Lanceward410 @Lanceward410
Elliw Seehorn
@ellsee
Jun 10 2017 03:15
i mean how do you delete the backslashes without the \ following http: marking the remainder of the line as a comment, producing an "unexpected end of code error" @coymeetsworld
Coy Sanders
@coymeetsworld
Jun 10 2017 03:15
what does your code look like @ellsee ?
Elliw Seehorn
@ellsee
Jun 10 2017 03:15
var myStr = "<a href="\http://www.example.com\" target="_blank">Link</a>";
Coy Sanders
@coymeetsworld
Jun 10 2017 03:15
you're not using any single quotes
there should be no escaping of characters (i.e. backslashes)
Alexander Køpke
@alexanderkopke
Jun 10 2017 03:16
\ backslash / forward slash .. only remove the backslashes
Coy Sanders
@coymeetsworld
Jun 10 2017 03:16
no, thats not the challenge
this is mixing single and double quotes, @ellsee check the example
Elliw Seehorn
@ellsee
Jun 10 2017 03:18
I don't see how I can accomplish all 3. the first and last are mutually exclusive it seems Remove all the backslashes () You should have two single quotes ' and four double quotes "
*Only remove the backslashes \ used to escape quotes.
Coy Sanders
@coymeetsworld
Jun 10 2017 03:18
you should have 0 backslashes
Alexander Køpke
@alexanderkopke
Jun 10 2017 03:19
@ellsee after you remove the backslashes \but not the forward slashes /, replace the first and last double quote with single quotes
Lance Ward
@Lanceward410
Jun 10 2017 03:20
hint hint the entire string is surrounded by single quotes
Kyle Holm
@thekholm80
Jun 10 2017 03:20
' is a single quote and " is a double quote
Elliw Seehorn
@ellsee
Jun 10 2017 03:21
thanks all of y'all! it works! so sorry, im young and new to this
Coy Sanders
@coymeetsworld
Jun 10 2017 03:22
all good @ellsee
nice work
Lance Ward
@Lanceward410
Jun 10 2017 03:22
No apologies. no mercy. conquer the battlefield
Alexander Køpke
@alexanderkopke
Jun 10 2017 03:24
I think it's great that you kept at it until you got it. That is how it is done! :)
Kyle Holm
@thekholm80
Jun 10 2017 03:25
never give up! never surrender!
Austin Wiggins
@austinwiggins
Jun 10 2017 03:29
Hi! I am having some trouble incorporating the twitter api(https://dev.twitter.com/web/tweet-button/web-intent) into my random quote machine(https://codepen.io/bigwigaustin/pen/xrZwMG) Can anyone help explain the process and how to make the api work?
hugo
@hramos0910
Jun 10 2017 03:34
Heya. im on lesson 213 javascript: iterate through an array with a for loop... it says "Remember that Arrays have zero-based numbering, which means the last index of the array is length - 1."... im lost
for example var arr = [10,9,8,7,6] i know the first index of the array is 0
Austin Wiggins
@austinwiggins
Jun 10 2017 03:36
anyone?
hugo
@hramos0910
Jun 10 2017 03:36
how is the last index of the array -1?
Manish Giri
@Manish-Giri
Jun 10 2017 03:36
it's not - 1
read again

it says

length - 1

Kyle Holm
@thekholm80
Jun 10 2017 03:37
if you have an array [0, 1, 2] the length is 3, the last index is 2. so the last index is length - 1
Manish Giri
@Manish-Giri
Jun 10 2017 03:39
@thekholm80 x
Hernan Mendez
@hernanmendez
Jun 10 2017 03:40
@hramos0910 es6, for(let content of arr){/code here/ }
Natalia
@talomusica
Jun 10 2017 03:40
Hi can anyone please help. I am so stuck on incrementing a number on javascript\
Kyle Holm
@thekholm80
Jun 10 2017 03:40
@Manish-Giri lol
Lance Ward
@Lanceward410
Jun 10 2017 03:41
i++
Natalia
@talomusica
Jun 10 2017 03:42
thanks Lance, I get that, but I cannot complete the challenge. I don't understand what they are asking me to do
Manish Giri
@Manish-Giri
Jun 10 2017 03:43
@talomusica ++ before/after a number or variable increments the value of it.
Natalia
@talomusica
Jun 10 2017 03:45
i still can't make the code correct
Ayush Kumar
@Gr8ayu
Jun 10 2017 03:46
what is difference between container and container-fluid ???
Ayush Kumar
@Gr8ayu
Jun 10 2017 03:48
@talomusica show your code
@ravikishorethella thnx
CamperBot
@camperbot
Jun 10 2017 03:50
:cookie: 486 | @ravikishorethella |http://www.freecodecamp.com/ravikishorethella
gr8ayu sends brownie points to @ravikishorethella :sparkles: :thumbsup: :sparkles:
Ravi Kishore Thella
@ravikishorethella
Jun 10 2017 03:50
@Gr8ayu :thumbsup:
D4Mighty
@D4Mighty
Jun 10 2017 03:50
hey guys, any ideas what's wrong with this code? (Card counting challenge)

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 > 0){
return count + " Bet ";
}
else {
return count + " Hold ";
}

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);

Natalia
@talomusica
Jun 10 2017 03:52

var myVar = 87;

// Only change code below this line
var myVar = 88;
var i = 1;
i++;

Ayush Kumar
@Gr8ayu
Jun 10 2017 03:53
@D4Mighty give link, I guess you were supposed to do count++ till 10
@talomusica you were not supposed to change value of myVar using =
Natalia
@talomusica
Jun 10 2017 03:55
thanks. what am i supposed to do? i really don't understand it at all and i have been stuck on this for half an hour!
Manish Giri
@Manish-Giri
Jun 10 2017 03:55
@talomusica instead of using i
Mukul Agrawal
@mukul09
Jun 10 2017 03:55
@talomusica i++ means i=i+1; and you have to do it with myVar
Manish Giri
@Manish-Giri
Jun 10 2017 03:55
use myVar
you've got the idea right
@talomusica
Natalia
@talomusica
Jun 10 2017 03:56
thank you. thank you. i got it now.
i am literally crying with relief
Ayush Kumar
@Gr8ayu
Jun 10 2017 03:58
@Manish-Giri can a page have more than 1 container class ??
Manish Giri
@Manish-Giri
Jun 10 2017 03:58
@Gr8ayu yup
Ayush Kumar
@Gr8ayu
Jun 10 2017 03:58
@Manish-Giri thnx
CamperBot
@camperbot
Jun 10 2017 03:58
gr8ayu sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5926 | @manish-giri |http://www.freecodecamp.com/manish-giri
Aditya
@adichouhan
Jun 10 2017 03:59

var myStr="FirstLine\n \SecondLine\ \rThirdLine"; // Change this line

what is wrong with this code?

Ayush Kumar
@Gr8ayu
Jun 10 2017 04:00
@adichouhan why you are adding \ after Second line??
Aditya
@adichouhan
Jun 10 2017 04:00
@Gr8ayu slash
Joseph
@revisualize
Jun 10 2017 04:01
@adichouhan you have to remove the spaces
@Gr8ayu Because you're supposed to be escaping a backslash after SecondLine
Aditya
@adichouhan
Jun 10 2017 04:01
@revisualize u mean all the spaces
Joseph
@revisualize
Jun 10 2017 04:02
@adichouhan Read the instructions. It tells you to remove the spaces in the string.
Aditya
@adichouhan
Jun 10 2017 04:02
@revisualize thx
CamperBot
@camperbot
Jun 10 2017 04:02
adichouhan sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4134 | @revisualize |http://www.freecodecamp.com/revisualize
Ace-Monkey-Ilium
@Ace-Monkey-Ilium
Jun 10 2017 04:06
Golf Code
How do I do this?
function golfScore(par, strokes) {
  // Only change code below this line
  if (1) {
  return "Hole-in-one!";
} else if (2) {
  return "Eagle";
} else if (num < 15) {
  return "Birdie";
} else if (num < 20) {
  return "Par";
} else {
  return "Bogey";
}

  return "Change Me";
  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
Ayush Kumar
@Gr8ayu
Jun 10 2017 04:06
@revisualize that need double slash for that
@Ace-Monkey-Ilium your if conditions are wrong
Ace-Monkey-Ilium
@Ace-Monkey-Ilium
Jun 10 2017 04:07
How do I fix them?
Ayush Kumar
@Gr8ayu
Jun 10 2017 04:07
@Ace-Monkey-Ilium read question carefully and tell what is the condition for "Hole-in-one!"
Ace-Monkey-Ilium
@Ace-Monkey-Ilium
Jun 10 2017 04:08
I don't understand the question so the is why I am asking
Joseph
@revisualize
Jun 10 2017 04:08
@Gr8ayu You need to quote the line to see what they ACTUALLY typed.
Ayush Kumar
@Gr8ayu
Jun 10 2017 04:09
@Ace-Monkey-Ilium question say if stroke is 1 then "Hole-in-one!"
Ace-Monkey-Ilium
@Ace-Monkey-Ilium
Jun 10 2017 04:09
how do I do both?
I don't understand
Ayush Kumar
@Gr8ayu
Jun 10 2017 04:10
@Ace-Monkey-Ilium I can't tell you direct answer , let me explain this to you
@Ace-Monkey-Ilium if (1) { mean true
Ace-Monkey-Ilium
@Ace-Monkey-Ilium
Jun 10 2017 04:11
what means false?
I am asking for how to do this
Ayush Kumar
@Gr8ayu
Jun 10 2017 04:11
if(myAge==18) means if my age is 18
Ace-Monkey-Ilium
@Ace-Monkey-Ilium
Jun 10 2017 04:12
OK
I still don't know how to solve this problem
Ayush Kumar
@Gr8ayu
Jun 10 2017 04:12
@Ace-Monkey-Ilium undefined ,NaN ,false are all false
Ace-Monkey-Ilium
@Ace-Monkey-Ilium
Jun 10 2017 04:13
function golfScore(par, strokes) {
  // Only change code below this line
  if (par==1 && strokes==1) {
  return "Hole-in-one!";
} else if (2) {
  return "Eagle";
} else if (3) {
  return "Birdie";
} else if (4) {
  return "Par";
} else {
  return "Bogey";
}

  return "Change Me";
  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
Ayush Kumar
@Gr8ayu
Jun 10 2017 04:13
@Ace-Monkey-Ilium remove par==1 &&
Ace-Monkey-Ilium
@Ace-Monkey-Ilium
Jun 10 2017 04:13
ok
Ayush Kumar
@Gr8ayu
Jun 10 2017 04:13
thats not what question wants
change all conditions
Ace-Monkey-Ilium
@Ace-Monkey-Ilium
Jun 10 2017 04:15
function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes==1) {
  return "Hole-in-one!";
} else if (strokes==2) {
  return "Eagle";
} else if (strokes==3) {
  return "Birdie";
} else if (strokes==4 && strokes==5) {
  return "Par";
} else {
  return "Bogey";
}

  return "Change Me";
  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
Is that better?
Ayush Kumar
@Gr8ayu
Jun 10 2017 04:18
@Ace-Monkey-Ilium try running it
Ace-Monkey-Ilium
@Ace-Monkey-Ilium
Jun 10 2017 04:18
it doesn't work
Ayush Kumar
@Gr8ayu
Jun 10 2017 04:18
@Ace-Monkey-Ilium conditions are different , show me conditions
that 's mentioned on left side above run button
Ace-Monkey-Ilium
@Ace-Monkey-Ilium
Jun 10 2017 04:19
function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes==1) {
  return "Hole-in-one!";
} else if (strokes==2) {
  return "Eagle";
} else if (strokes==3) {
  return "Birdie";
} else if (strokes==4) {
  return "Par";
} else if (strokes==5) {
  return "Par";
} else if (strokes==6) {
  return "Double Bogey";
} else {
  return "Go Home!";
}

  return "Change Me";
  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
Ayush Kumar
@Gr8ayu
Jun 10 2017 04:20
give link @Ace-Monkey-Ilium
Ayush Kumar
@Gr8ayu
Jun 10 2017 04:22

Strokes Return
1 "Hole-in-one!"
<= par - 2 "Eagle"
par - 1 "Birdie"
par "Par"
par + 1 "Bogey"
par + 2 "Double Bogey"

= par + 3 "Go Home!" these are conditions you have to write your code according to this

Ken Haduch
@khaduch
Jun 10 2017 04:22
@Ace-Monkey-Ilium - you need to take the par value into account as well as the number of strokes. The only condition where the number of strokes determines the result is for a hole in one. Otherwise, you have to compare the number of strokes to the "par" value for the hole.
Ayush Kumar
@Gr8ayu
Jun 10 2017 04:25
@Ace-Monkey-Ilium https://www.w3schools.com/js/js_if_else.asp this will help you
@khaduch can I write col-xs-3 or it should always 1,4,6,12 ??
Roger Melo
@Roger-Melo
Jun 10 2017 04:29
hey guys, can you help me with the following code?
var myStr = "I am a \"double quoted\" string inside \"double quotes\"."; // Change this line
I don't know what's wrong with him
Ayush Kumar
@Gr8ayu
Jun 10 2017 04:31
@Roger-Melo what is the title of challenge?
Roger Melo
@Roger-Melo
Jun 10 2017 04:31
var myStr = "I am a \"double quoted\" string inside \"double quotes\"."; // Change this line
the title is "Basic JavaScript: Escaping Literal Quotes in Strings"
Ken Haduch
@khaduch
Jun 10 2017 04:32
@Gr8ayu - you can write col-xs-3 The only requirement is that each row can have no more than 12 of the coluns used. (Although I'm not sure of the context for your question?) You can have any combination of columns in a row, as long as you don't exceed 12, so four col-xs-3, or two col-xs-6 or two threes and one six, etc.
Ayush Kumar
@Gr8ayu
Jun 10 2017 04:34
@Roger-Melo try reloading page
Roger Melo
@Roger-Melo
Jun 10 2017 04:34
@Gr8ayu it works! Was just a bug, right?
Ayush Kumar
@Gr8ayu
Jun 10 2017 04:35
@khaduch in all grid Images in tutorials I havn't seen col-xs-3 or 5 as example , thats why I asked . Thanks
CamperBot
@camperbot
Jun 10 2017 04:35
gr8ayu sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2962 | @khaduch |http://www.freecodecamp.com/khaduch
Nita
@nita90
Jun 10 2017 04:38
Hi Guys, could somebody help me?
Alexander Køpke
@alexanderkopke
Jun 10 2017 04:38
can try
Nita
@nita90
Jun 10 2017 04:39
I am at the very beginning. The challenge called "Use Conditional Logic with If Statements".
I think I did everything right. It seems really easy (I am pretty sure it is) but I can't go through :(
Ken Haduch
@khaduch
Jun 10 2017 04:39
@Gr8ayu - not that it's the ideal reference, but https://www.w3schools.com/bootstrap/bootstrap_grid_examples.asp has some examples of various sizes. It seems the using the ones you mentioned are pretty common for the basic illustration of the grid.
@nita90 - can you share your code?
Nita
@nita90
Jun 10 2017 04:40

// Example
function ourTrueOrFalse(isItTrue) {
if (isItTrue) {
return "Yes, it's true";
}
return "No, it's false";
}

// Setup
function trueOrFalse(wasThatTrue) {

// Only change code below this line.
if (wasThatTrue) {
return "Yes, that was true.";
}
return "No, that was false.";

// Only change code above this line.

}

// Change this value to test
trueOrFalse(true);

that is the whole thing
These tests are not completed: trueOrFalse(true) should return "Yes, that was true"
trueOrFalse(false) should return "No, that was false"
Alexander Køpke
@alexanderkopke
Jun 10 2017 04:42
@nita90 your code is correct. Only thing wrong is your strings have a . at the end
@nita90 "Yes, that was true" not "Yes, that was true."
Nita
@nita90
Jun 10 2017 04:44
wow
that works
Alexander Køpke
@alexanderkopke
Jun 10 2017 04:44
good work!
Nita
@nita90
Jun 10 2017 04:44
thank you so much @alexanderkopke
CamperBot
@camperbot
Jun 10 2017 04:44
nita90 sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1466 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Khalil Majeed
@kyojoken
Jun 10 2017 04:51
Hello. Just started JavaScript and am slightly confused by the escape sequences. Would like a bit of help.
var myStr; "FirstLine\n \\SecondLine\\\nThirdLine"
César Ferreira Germano
@IndieHouseStudio
Jun 10 2017 04:52
Hey :smile: My code looks right, and for the last condition that is missing, the expected response appears on the console. However, the challenge is not yet complete.
Amit singh
@amitsin6h
Jun 10 2017 04:52
what are you trying to do @kyojoken
Ken Haduch
@khaduch
Jun 10 2017 04:52
@nita90 - spelling (including the specified case of the words) and punctuation are some important things to check. The tests are very specific in what they are looking for, so you have to follow the test outputs to see what is expected and compare it letter-for-letter to what you are getting. simple things like punctuation can cause a lot of frustration in getting the tests to pass!
Khalil Majeed
@kyojoken
Jun 10 2017 04:53
make a list of strings using escape sequences, @amitsin6h
Amit singh
@amitsin6h
Jun 10 2017 04:53
are you assigning the string val to your variable @kyojoken
Khalil Majeed
@kyojoken
Jun 10 2017 04:53
The instructions how this: FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
Ken Haduch
@khaduch
Jun 10 2017 04:53
@kyojoken - is should be var myVar = and then your string, and there should be no spaces in the string at all (per the instructions).
Roger Melo
@Roger-Melo
Jun 10 2017 04:53
@kyojoken try to rewrite the code without any spaces
Khalil Majeed
@kyojoken
Jun 10 2017 04:54
Oh! That worked, @khaduch and @Roger-Melo
Ken Haduch
@khaduch
Jun 10 2017 04:54
@IndieHouseStudio - what does your code look like?
Khalil Majeed
@kyojoken
Jun 10 2017 04:54
Thought I can't say I understand what /r actually does
Jan Shah
@JanShah
Jun 10 2017 04:54
@kyojoken
var myStr= "FirstLine\n \\SecondLine\\ \nThirdLine"
console.log(myStr)
slavastarikov
@slavastarikov
Jun 10 2017 04:54
Screen Shot 2017-06-09 at 9.52.19 PM.png
hi all, in the javascript basic, "profile lookup" exercise I'm stuck and not sure what else to do here, if someone could please take a look I would very much appreciate some help. seems like the code for the second conditional statement is not working correctly.
Khalil Majeed
@kyojoken
Jun 10 2017 04:55
Thanks, guys.
César Ferreira Germano
@IndieHouseStudio
Jun 10 2017 04:55
(Profile Lookup) Hey! My code looks right, and for the last condition that is missing, the expected response appears on the console. However, the challenge is not yet complete. Print: alt
Jan Shah
@JanShah
Jun 10 2017 04:55
@kyojoken that will show you the output in the console, then change the variable to see the new result
Khalil Majeed
@kyojoken
Jun 10 2017 04:56
Yup. Got it, man. Cheers.
Ken Haduch
@khaduch
Jun 10 2017 04:57
@kyojoken - I always think of it in terms of a physical typewriter (not that everyone is familiar with those these days). There used to be a separate "carriage return" command, which would move the paper (actually the "carriage" that held the paper) back to the beginning of the line, and a "line feed" would shift the paper up to the next line. Sometimes you would just "return" to the beginning of the line to overstrike the line with things like underscore characters to underline a part of the line, and you would not want to advance the paper to the next line.
You'll run across those characters some times in certain file formats or operating systems that use them.
Amit singh
@amitsin6h
Jun 10 2017 04:58
var mystr = "hello\n my name is amit\n am from ranchi, jharkhand, India\n thank you!!";
@kyojoken
you are not assign you var
for assing the var
u need to do something var myvar = "value";
Khalil Majeed
@kyojoken
Jun 10 2017 04:59
@khaduch Thanks for the explanation. That makes sense.
@amitsin6h yeah. I saw the mistake and fixed it. Thanks for clarifying.
CamperBot
@camperbot
Jun 10 2017 04:59
kyojoken sends brownie points to @khaduch and @amitsin6h :sparkles: :thumbsup: :sparkles:
:cookie: 119 | @amitsin6h |http://www.freecodecamp.com/amitsin6h
:star2: 2964 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Jun 10 2017 05:03
@IndieHouseStudio - you can simplify your return of "No such contact" and remove that flagExist variable and your testing and setting of it by just moving the return "No such contact"; after the end of the for loop, because if you find a contact in the loop, you'll return one of the two conditions there. After the list runs out, you can just return the final status. Other than that (although it's a little hard to read) I don't know why your code isn't working.
红色小星
@turboxing
Jun 10 2017 05:03
有说 中文的吗
slavastarikov
@slavastarikov
Jun 10 2017 05:04
@IndieHouseStudio i wonder if it would help you to wrap your return statements in the {} brackets
@khaduch could you possibly check mine out? I'm working on the same profile lookup challenge
Ken Haduch
@khaduch
Jun 10 2017 05:06
@slavastarikov - it's good practice to do that (always use curly braces for if conditional blocks), but it should still work as it is. It might be a browser caching issue, too, @IndieHouseStudio ? (And I could just be missing something, the screen shot is hard to read.)
@slavastarikov - sure, can you post your code? Easier if you use the markdown format, and you don't have to post the contacts list...
slavastarikov
@slavastarikov
Jun 10 2017 05:07
@khaduch of course
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("Akira", "likes");
hm is there a way to make the code appear different?
Ken Haduch
@khaduch
Jun 10 2017 05:08
@slavastarikov - wrap the code with a separate line of ``` at the top and bottom. You can just go back and edit your post.
slavastarikov
@slavastarikov
Jun 10 2017 05:09
oh cool
Alexander Køpke
@alexanderkopke
Jun 10 2017 05:09
@slavastarikov won't your function return on the first interation no matter what?
slavastarikov
@slavastarikov
Jun 10 2017 05:09
just did that ^^
César Ferreira Germano
@IndieHouseStudio
Jun 10 2017 05:10
@khaduch Thanks for the help!!!
CamperBot
@camperbot
Jun 10 2017 05:10
indiehousestudio sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2965 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Jun 10 2017 05:10
@slavastarikov - I think that you have the problem where you are attempting to return "No such contact" within the for loop, and you don't really know that you have found a contact until you are finished looking at the entire contact list. So your conditions for returning the property or "No such property" can be satisfied within the loop. Then after the loop, if you have not returned the first two conditions, you can just return "No such contact".
César Ferreira Germano
@IndieHouseStudio
Jun 10 2017 05:11
How do I donate brownies? How does it work?
Alexander Køpke
@alexanderkopke
Jun 10 2017 05:12
@IndieHouseStudio click a name and write thanks ty merci or similar expressions of gratitude
CamperBot
@camperbot
Jun 10 2017 05:12
alexanderkopke sends brownie points to @indiehousestudio :sparkles: :thumbsup: :sparkles:
:cookie: 218 | @indiehousestudio |http://www.freecodecamp.com/indiehousestudio
Ken Haduch
@khaduch
Jun 10 2017 05:12
@IndieHouseStudio - brownie points explained (if you didn't know?)
César Ferreira Germano
@IndieHouseStudio
Jun 10 2017 05:14
@alexanderkopke , @alexanderkopke : Thanks for explaination
CamperBot
@camperbot
Jun 10 2017 05:14
indiehousestudio sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1467 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
slavastarikov
@slavastarikov
Jun 10 2017 05:19
@khaduch I finally get what you're saying, took some thinking there, sorry for the delay, I'm just not sure about to how return "No such contact" if neither conditions are met in the for loop.
@alexanderkopke i'm not sure what you mean. I think the first return statement will only run if there's a matching first name but no property
slavastarikov
@slavastarikov
Jun 10 2017 05:24
ah i got it
Alexander Køpke
@alexanderkopke
Jun 10 2017 05:24
@slavastarikov yes you if statement is fine but you also have an else statement with a return statement. When functions return something, it is done. So the loop will stop when you return something.
slavastarikov
@slavastarikov
Jun 10 2017 05:25
i used
if (i == contacts.length - 1)
{return "No such contact";}
}
woo hoo its finally working!
Ken Haduch
@khaduch
Jun 10 2017 05:25
@slavastarikov - there are two different levels of things happening in the function. One is the for loop - it is iterating over the list of contacts and can correctly determine if there is a match on the firstName of any element, and if there is a firstName match, it can check for the property. If the property exists you return the value, or if the property doesn't exist, you return "No such property". A return statement exits the function. If you completely test all of the contacts in the list, and there was not a firstName match, you will get all the way through the loop, so you then have this condition:
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";
        }
    }
    // Got to this point, after the "for" loop is complete, and haven't returned...
    // The only thing left to do is indicate "No such contact", because you haven't found one above!
// Only change code above this line
}
Markus Ivancsics
@ivancsicsmarkus
Jun 10 2017 05:25
@slavastarikov Or you could just return "No such contact" outside of the loop.
slavastarikov
@slavastarikov
Jun 10 2017 05:27
got it, it didn't click to run no such contact outside of the loop
@khaduch thank you so much for your thorough explanation it was super helpful
CamperBot
@camperbot
Jun 10 2017 05:27
slavastarikov sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2966 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Jun 10 2017 05:28
@slavastarikov - you're welcome! It's a very good lesson in writing code, it gives many people some problems, it's pretty obvious once you see it in action!
Rick Riggs
@wikiwiggs
Jun 10 2017 05:28

Hey everyone, I asked this over in the 'LetsPair' room, but it's moving too slow for people responding, and I was hoping maybe someone here had some experience with this...

Has anyone here ever used codiad for pair programming?

slavastarikov
@slavastarikov
Jun 10 2017 05:28
@ivancsicsmarkus are you saying i didn't have to use the if statement
@alexanderkopke thank you!
CamperBot
@camperbot
Jun 10 2017 05:28
slavastarikov sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1468 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
slavastarikov
@slavastarikov
Jun 10 2017 05:29
@khaduch obvious now indeed, hope not to make that mistake again :smile:
Markus Ivancsics
@ivancsicsmarkus
Jun 10 2017 05:29
@slavastarikov Yes. You don’t need that outside the loop.
@wikiwiggs Not really.
Rick Riggs
@wikiwiggs
Jun 10 2017 05:31
@ivancsicsmarkus care to test it out really quick with me?
Markus Ivancsics
@ivancsicsmarkus
Jun 10 2017 05:31
@wikiwiggs I don’t have time, sorry.
Rick Riggs
@wikiwiggs
Jun 10 2017 05:31
I'm not looking for a full on pairing session, I just want to see how it acts.
slavastarikov
@slavastarikov
Jun 10 2017 05:32
@ivancsicsmarkus not sure how to do this. I tried this but it looks like the return will run after the for loop, whether the conditions in the for loop were or were not met. so it seems to make sense to me so far to only run the return if the for loop runs all the way through. i may be missing something
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";}
            }

{return "No such contact";}
}
Ken Haduch
@khaduch
Jun 10 2017 05:34
@slavastarikov - it's a learning experience!
Nurbek
@NurbekGithub
Jun 10 2017 05:34
Thanks @Rafase282 @coded9 for your help with Algorithm: Arguments Optional
CamperBot
@camperbot
Jun 10 2017 05:34
nurbekgithub sends brownie points to @rafase282 and @coded9 :sparkles: :thumbsup: :sparkles:
:cookie: 381 | @coded9 |http://www.freecodecamp.com/coded9
:star2: 1560 | @rafase282 |http://www.freecodecamp.com/rafase282
Rick Riggs
@wikiwiggs
Jun 10 2017 05:34
if a return is hit inside of a function, you will immediately escape out of it.
Ken Haduch
@khaduch
Jun 10 2017 05:34
@slavastarikov - my point above about return exits the function, and nothing that is in the function after you execute a return will run.
Raghu Raj Rai
@Raidestro
Jun 10 2017 05:36
Hello. Can someone please guide me with the tweet button for the random quote generator ?
Here's my project- https://codepen.io/Raidestro/pen/zzrpoG?editors=1010
Markus Ivancsics
@ivancsicsmarkus
Jun 10 2017 05:36
Rick Riggs
@wikiwiggs
Jun 10 2017 05:37
@slavastarikov if you want to see this in action, copy and paste your code here, and run it. pretty cool:
http://pythontutor.com/javascript.html#mode=edit
Ken Haduch
@khaduch
Jun 10 2017 05:38
@wikiwiggs - I've seen that - you might have meant that for @slavastarikov - http://pythontutor.com/javascript.html - it is pretty cool! A nice learning tool.. (and @wikiwiggs - I see that you changed your post... :) )
Cory Ramirez
@CoryARamirez
Jun 10 2017 05:38
Anyone mind telling me why I'm failing the challenge despite getting the correct result for the titleCase challenge?
var firstLetters = [];
var lastLetters = [];

function titleCase(str) {
  var splitString = str.split(" ");
  for (var i = 0; i < splitString.length; i++ ) {
    var firstLetter = splitString[i].charAt(0).toUpperCase();
    firstLetters.push(firstLetter);    
  }

  for (var j = 0; j < splitString.length; j++ ) {
    var lastLetter = splitString[j].substr(1).toLowerCase();
    lastLetters.push(lastLetter);
  }

  for (var k = 0; k < firstLetters.length; k++) {
      firstLetters[k] += lastLetters[k];
  }

 var finalString = firstLetters.toString();
 var parsedString = finalString.replace(/,/g, " ");
 return parsedString;
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
Rick Riggs
@wikiwiggs
Jun 10 2017 05:39
@khaduch sorry, I went to click on that name and right before I did, I think the chat jumped.
Raghu Raj Rai
@Raidestro
Jun 10 2017 05:39
@ivancsicsmarkus I made the button. But how can I pull the newQuoteText and newQuoteGenius text into the link ?
Here's the tweet button JS :
 $(tweet).attr("href", 'https://twitter.com/intent/tweet?text=' + 'newQuoteText' + "-" + json.newQuoteGenius);
I've tried everything :|
slavastarikov
@slavastarikov
Jun 10 2017 05:41

i just don't understand why this works:

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";}
            }
if (i == contacts.length - 1)
{return "No such contact";}
}

// Only change code above this line
}

yet this doesn't:

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";}
            }
return "No such contact";
}

// Only change code above this line
}

the only difference being in that last return

CamperBot
@camperbot
Jun 10 2017 05:41
:bulb: to format code use backticks! ``` more info
Markus Ivancsics
@ivancsicsmarkus
Jun 10 2017 05:42

@Raidestro move this:

$(tweet).attr("href", 'https://twitter.com/intent/tweet?text=' + newQuoteText + " - " + newQuoteGenius);

inside your click event!

@Raidestro so?
Raghu Raj Rai
@Raidestro
Jun 10 2017 05:44

@ivancsicsmarkus No success :|

 $('#tweet').click(function(evt){
    $(tweet).attr("href", 'https://twitter.com/intent/tweet?text=' + newQuoteText + " - " + newQuoteGenius);
    });

^This is what I did in JS.

Rick Riggs
@wikiwiggs
Jun 10 2017 05:44
@slavastarikov the second option, doesn't allow the for loop to get past the first contact
@slavastarikov does my statement make sense to you?
Markus Ivancsics
@ivancsicsmarkus
Jun 10 2017 05:47
@Raidestro Of course after the randomization...
Raghu Raj Rai
@Raidestro
Jun 10 2017 05:47
 <div class="wrapper"><a class="twitter-share-button" id="tweet" href="https://twitter.com/intent/tweet/?text=" data-size="large" target="_blank">
    <button type="button" class="btn btn-primary">Share this on twitter !</button></a></div>
^this is the html for my button
Markus Ivancsics
@ivancsicsmarkus
Jun 10 2017 05:47
@Raidestro But here you are, then:
     $('#quoteButton').click(function(evt){
            //define the containers of the info we target
            var quote = $('#quoteContainer p').text();
            var quoteGenius = $('#quoteGenius').text();
            //prevent browser's default action
            evt.preventDefault();
            //getting a new random number to attach to a quote and setting a limit
            var sourceLength = quoteSource.length;
            var randomNumber= Math.floor(Math.random()*sourceLength);
            //set a new quote
            for(i=0;i<=sourceLength;i+=1){
            var newQuoteText = quoteSource[randomNumber].quote;
            var newQuoteGenius = quoteSource[randomNumber].name;
            //console.log(newQuoteText,newQuoteGenius);
      var timeAnimation = 500;
      var quoteContainer = $('#quoteContainer');
      $(tweet).attr("href", 'https://twitter.com/intent/tweet?text=' + newQuoteText + " - " + newQuoteGenius); //end of tweet button
      //fade out animation with callback
      quoteContainer.fadeOut(timeAnimation, function(){
        quoteContainer.html('');
                quoteContainer.append('<p>'+newQuoteText+'</p>'+'<p id="quoteGenius">'+'-                                '+newQuoteGenius+'</p>');

        //fadein animation.
        quoteContainer.fadeIn(timeAnimation);
      });  

            break;
        };
Rick Riggs
@wikiwiggs
Jun 10 2017 05:47
@Raidestro you have an error at line 126
slavastarikov
@slavastarikov
Jun 10 2017 05:48
@wikiwiggs i got when you said "if a return is hit inside of a function, you will immediately escape out of it" . it's just that @ivancsicsmarkus said i can run the final return without an if statement and I'm still not sure how to do that...how to run the return outside of the for loop
Markus Ivancsics
@ivancsicsmarkus
Jun 10 2017 05:48

@slavastarikov You just say:

return "No such contact"

after your for loop ends

slavastarikov
@slavastarikov
Jun 10 2017 05:49
@ivancsicsmarkus that's what i tried to do in my second option above ^^^
not getting how to do that
Rick Riggs
@wikiwiggs
Jun 10 2017 05:50

@slavastarikov try this:

your original:

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";}
            }
return "No such contact";
}

// Only change code above this line
}

how to take @ivancsicsmarkus advice:

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";}
            }
}
return "No such contact";

// Only change code above this line
}
slavastarikov
@slavastarikov
Jun 10 2017 05:50
ah crap i thought i was doing that
damn bracket
geez. thank you @ivancsicsmarkus and @wikiwiggs so much for your explanations and patience!!
CamperBot
@camperbot
Jun 10 2017 05:51
slavastarikov sends brownie points to @ivancsicsmarkus and @wikiwiggs :sparkles: :thumbsup: :sparkles:
:cookie: 325 | @wikiwiggs |http://www.freecodecamp.com/wikiwiggs
:cookie: 601 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
Markus Ivancsics
@ivancsicsmarkus
Jun 10 2017 05:51
@slavastarikov This way if no conditions meet in the for loop, your will return with "no such contact"
slavastarikov
@slavastarikov
Jun 10 2017 05:51
got it,
Rick Riggs
@wikiwiggs
Jun 10 2017 05:52
It happens, but syntax mistakes are so awesome to make, because they engrain stuff into you like nothing else can
they suck though.
Raghu Raj Rai
@Raidestro
Jun 10 2017 05:52
No success !
Oh wait ! All this time I was trying it without bringing a quote in the container. !
Thanx ! It worked !!!
@ivancsicsmarkus thank you
CamperBot
@camperbot
Jun 10 2017 05:54
raidestro sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:cookie: 602 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
slavastarikov
@slavastarikov
Jun 10 2017 05:58
this community rocks i must say
Rick Riggs
@wikiwiggs
Jun 10 2017 05:59

@slavastarikov I would recommend to you to get a little more disciplined in how you return and indent your code. It will help you.
Your Example:

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";}
            }
}
return "No such contact";

// Only change code above this line
}

Good Practice:

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";
            }
        }
    }
    return "No such contact";

// Only change code above this line
}
slavastarikov
@slavastarikov
Jun 10 2017 06:00
yea i can sense that would help thanks for the input
also rick, im not sure how to use that link you provided
Uzair Ali
@uajkhan
Jun 10 2017 06:00
can someone help me with this problem
Escape Sequences in Strings ?
slavastarikov
@slavastarikov
Jun 10 2017 06:02
@uajkhan how far have you gotten?
Rick Riggs
@wikiwiggs
Jun 10 2017 06:02
@slavastarikov I can get on google hangouts with you and do a screen share, I just have to keep the sound off, because the family is asleep.
Uzair Ali
@uajkhan
Jun 10 2017 06:03
@slavastarikov I pass 3 out of 4 requiremnets
the only one I can't do is
myStr should have encoded text with the proper escape sequences and no spacing.
don't know what to do here
Raghu Raj Rai
@Raidestro
Jun 10 2017 06:03
I've decided to not proceed with any projects unless I've read and understood JS to an intermediate level. !
Raghu Raj Rai
@Raidestro
Jun 10 2017 06:04
FCC provided a paper base to develop our JS skills. And as a newbie to front end dev, I am annoyed with it !
slavastarikov
@slavastarikov
Jun 10 2017 06:04
@uajkhan can you copy and paste your code? or a screen capture?
Uzair Ali
@uajkhan
Jun 10 2017 06:05
var myStr="FirstLine\r\SecondLine\\nThirdLine"; // Change this line
slavastarikov
@slavastarikov
Jun 10 2017 06:07
i would suggest looking carefully at the instructions
it says FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
Uzair Ali
@uajkhan
Jun 10 2017 06:07
@slavastarikov I seriously got no clue
Johnny
@jtan3
Jun 10 2017 06:07
@uajkhan backslash is \\
slavastarikov
@slavastarikov
Jun 10 2017 06:07
your ordering doesn't match ^^
Uzair Ali
@uajkhan
Jun 10 2017 06:08
oh @slavastarikov I changed it to see if this works
@slavastarikov the other order did'nt work as well
slavastarikov
@slavastarikov
Jun 10 2017 06:08
your code has a carriage return after the first line and newline after the second
while the instructions ask for the reverse
Rick Riggs
@wikiwiggs
Jun 10 2017 06:09
also \r NOT \r\
Uzair Ali
@uajkhan
Jun 10 2017 06:09
@slavastarikov oh got it
slavastarikov
@slavastarikov
Jun 10 2017 06:09
right what rick said
Uzair Ali
@uajkhan
Jun 10 2017 06:09
@wikiwiggs @jtan3
var myStr="FirstLine\n\SecondLine\\rThirdLine"; // Change this line
i pasted \
\
but the message somehow only shows a single slash
\\
try it
Jan Shah
@JanShah
Jun 10 2017 06:11
import ranger from './ranger.png'
import ninja from './ninja.png'
const playerImg=new Image(64,64)

export const Player = detail =>{
  const details = new getDetails({...detail,name:'ranger'})
  playerImg.src=ranger 
  return {image:playerImg,...details}
}
I need help refactoring this so i don't have to hardcode playerImg.src, i.e. if I pass in the name 'ninja' to detail, the function refers to the imported image ninja
Rick Riggs
@wikiwiggs
Jun 10 2017 06:11
var myStr = "FirstLine\n\\SecondLine\\\rThirdLine";
slavastarikov
@slavastarikov
Jun 10 2017 06:11
@uajkhan in order to get a backslash you need to use two of the \
that's why rick's code has two after the \n and two before the \r
Rick Riggs
@wikiwiggs
Jun 10 2017 06:12
There is really no way of describing this exercise without giving you the answer
Vikas Saraf
@saraf007
Jun 10 2017 06:13

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

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

why i am getting null?
slavastarikov
@slavastarikov
Jun 10 2017 06:14
rick thanks for the offer
would like to get a walk through
if thats alright
don't have much time though
gonna go sleep soon
Rick Riggs
@wikiwiggs
Jun 10 2017 06:14
@slavastarikov someone is running into the same return problem
ramamrajdev
@ramamrajdev
Jun 10 2017 06:15
#170 returning the variable with updated value but the challenge is not to change the variable how it can be possible.
Rick Riggs
@wikiwiggs
Jun 10 2017 06:15
@saraf007 you are returning too early
Vikas Saraf
@saraf007
Jun 10 2017 06:15
help me
Rick Riggs
@wikiwiggs
Jun 10 2017 06:16
@saraf007 I'll be back in a few...
Cengiz Gonen
@cetico
Jun 10 2017 06:16
o
Rick Riggs
@wikiwiggs
Jun 10 2017 06:16
@slavastarikov let's hop into that call
Vikas Saraf
@saraf007
Jun 10 2017 06:17
@wikiwiggs what is meant by you are returning too early
niechen
@niechenN
Jun 10 2017 06:18
function palindrome(str) {
  var str1 = str.replace(/(\s+)(\,+)/ig,"");
  var arr = str1.split("").reverse();
  var str2 = arr.join("").toLowerCase();
  if(str1 == str) return true;
  return false;  
}

palindrome("nope");
help what's wrong?
why my answer is true? please
Jan Shah
@JanShah
Jun 10 2017 06:21
@niechen1992 do a console log on str1 and str2, you will find the answer there
Vikas Saraf
@saraf007
Jun 10 2017 06:22
@CentropyIT help me too please
Jan Shah
@JanShah
Jun 10 2017 06:22
console.log(str1,str2,arr)
@saraf007 whats the problem mate?
Vikas Saraf
@saraf007
Jun 10 2017 06:23

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
why i am getting null?

niechen
@niechenN
Jun 10 2017 06:23
Ok I will tyr
try
Jan Shah
@JanShah
Jun 10 2017 06:23
function palindrome(str) {
  var str1 = str.replace(/(\s+)(\,+)/ig,"");
  var arr = str1.split("").reverse();
  var str2 = arr.join("").toLowerCase();
    console.log(str,str1,str2)
  if(str1 == str) return true;
  return false;  
}

palindrome("nope");
There's this really cool app that I use for chrome called scratch js, I highly recommend it
niechen
@niechenN
Jun 10 2017 06:25

Return true if the given string is a palindrome. Otherwise, return false.

A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.

Jan Shah
@JanShah
Jun 10 2017 06:25
@saraf007 your return is in the middle of your loop, so it goes in once, then returns to the end
i looks like you've edited the code below the line you shouldn't have @saraf007
Rick Riggs
@wikiwiggs
Jun 10 2017 06:26
@saraf007 OK, I'm back, are you still struggling?
Vikas Saraf
@saraf007
Jun 10 2017 06:27
@wikiwiggs yes
Jan Shah
@JanShah
Jun 10 2017 06:28
@saraf007 I'd rewrite it from scratch, there's a number of issues, rethink it.
Rick Riggs
@wikiwiggs
Jun 10 2017 06:28
let's go through your code line by line:
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i=0; i < arr.length; i++) {
  for (var j=0; j < arr[i].length; j++) {
      // Only change code above this line
  return product * arr[j];
}}}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Jan Shah
@JanShah
Jun 10 2017 06:28
first thing to do is reset your code.
Vikas Saraf
@saraf007
Jun 10 2017 06:28
done @CentropyIT
Jan Shah
@JanShah
Jun 10 2017 06:28
only write code above the line where it says // Only change code above this line
Rick Riggs
@wikiwiggs
Jun 10 2017 06:29
Go ahead and paste the reset code back in here.
Jan Shah
@JanShah
Jun 10 2017 06:29
do a console log on arr, see what input you're getting
@saraf007
Ayush Mahajan
@ay2306
Jun 10 2017 06:29
https://codepen.io/ayush2306/pen/LLVOEV?editors=1101
I want place to be written inline with temperature. Help
Vikas Saraf
@saraf007
Jun 10 2017 06:30

@wikiwiggs function multiplyAll(arr) {
var product = 1;
// Only change code below this line

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

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

Jan Shah
@JanShah
Jun 10 2017 06:30
and from that, you will be able to devise a way, ensuring you always log your variables so you can see what your code is doing @saraf007
Rick Riggs
@wikiwiggs
Jun 10 2017 06:30

Your original:

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

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

Your reset code:

function multiplyAll(arr) {
    var product = 1;
    // Only change code below this line
    // Only change code above this line
    return product;
}
// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Jan Shah
@JanShah
Jun 10 2017 06:31
it's an array in an array, so create a first loop, then another loop within the first. make sure your first loop var (like var j) is different to the second one
@wikiwiggs that was confusing..
Vikas Saraf
@saraf007
Jun 10 2017 06:34
@CentropyIT @wikiwiggs still stuck
Rick Riggs
@wikiwiggs
Jun 10 2017 06:35
@CentropyIT I am trying to go line by line, and Vikas needs help understanding. I need him to see what he was thinking, and how he can get past it.
@saraf007 first look at your multiplyAll call at the last line, what does the array look like?
Vikas Saraf
@saraf007
Jun 10 2017 06:37
@wikiwiggs @CentropyIT see i am trying to do is creating 2 for loops and then multiply it with the already defined variable product
Jan Shah
@JanShah
Jun 10 2017 06:37
@saraf007 exactly right
Rick Riggs
@wikiwiggs
Jun 10 2017 06:37
@saraf007 in other words, you are immediately thinking nesting loops.
Jan Shah
@JanShah
Jun 10 2017 06:37
but the return happened in the loop
Rick Riggs
@wikiwiggs
Jun 10 2017 06:37
and you showed that intent in your original code
Vikas Saraf
@saraf007
Jun 10 2017 06:38
@CentropyIT plz explain
Rick Riggs
@wikiwiggs
Jun 10 2017 06:38
@saraf007 as soon as you issue a return statement it will force you to escape the function, and uses that statement as the total result of the function.
Jan Shah
@JanShah
Jun 10 2017 06:38
if you return something, it returns outside a loop and cancels the loop it was in.
Vikas Saraf
@saraf007
Jun 10 2017 06:38
okk
CallMeOrange
@EgnaroDev
Jun 10 2017 06:39
I think you should add else to return true or false
I dont think two returns in single block works
Jan Shah
@JanShah
Jun 10 2017 06:39
by returning in the second loop, you skip the other values in the second loop
two returns can work in certain circumstances, @MCTwoDigitZero possible in this one too
Vikas Saraf
@saraf007
Jun 10 2017 06:40
@CentropyIT so should i return outside both the loops?
Rick Riggs
@wikiwiggs
Jun 10 2017 06:40
Yes
CallMeOrange
@EgnaroDev
Jun 10 2017 06:40
@CentropyIT I see
Rick Riggs
@wikiwiggs
Jun 10 2017 06:40
But you need to capture your results in a variable
Jan Shah
@JanShah
Jun 10 2017 06:40
you need to aggregate the values first and then return the sum don't you? @saraf007
first you make the sums, then return them. as a whole.
Rick Riggs
@wikiwiggs
Jun 10 2017 06:41
all said and done, return the variable at the very end that has the product in it.
Vikas Saraf
@saraf007
Jun 10 2017 06:42
ok will try
Jan Shah
@JanShah
Jun 10 2017 06:42
are you supposed to return 3 sums or one sum? @saraf007 I don't know what the expected results are
Rick Riggs
@wikiwiggs
Jun 10 2017 06:42
@saraf007 I can help you reduce this down to one loop only, and it will help.
it has to multiply every number to each other -> one product
Vikas Saraf
@saraf007
Jun 10 2017 06:43
@CentropyIT one
@wikiwiggs help
Rick Riggs
@wikiwiggs
Jun 10 2017 06:44
@saraf007 before doing anything inside of the function try this:
var flatStr = arr.toString(); 
var newArr = flatStr.split(',');
Vikas Saraf
@saraf007
Jun 10 2017 06:45
@wikiwiggs where
Rick Riggs
@wikiwiggs
Jun 10 2017 06:46
@saraf007
function multiplyAll(arr) {
    var product = 1;
    // Only change code below this line
    var flatStr = arr.toString(); 
    var newArr = flatStr.split(',');
    // Only change code above this line
    return product;
}
// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Vikas Saraf
@saraf007
Jun 10 2017 06:47
its returning 1
@wikiwiggs
Rick Riggs
@wikiwiggs
Jun 10 2017 06:47
@saraf007 remember this is the original code to your exercise, you still have to work through it.
Vikas Saraf
@saraf007
Jun 10 2017 06:48
@wikiwiggs Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr
Rick Riggs
@wikiwiggs
Jun 10 2017 06:48
@saraf007 sorry I made a mistake in where I placed it, look again
what values would you expect to see in newArr?
I'll rewrite a test function so you can run it in your exercise:
function multiplyAll(arr) {
    var product = 1;
    // Only change code below this line
    var flatStr = arr.toString(); 
    var newArr = flatStr.split(',');
    console.log(newArr);
    // Only change code above this line
    return product;
}
// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Din
@DinShpati
Jun 10 2017 06:51
hello, does anyone recommend any good online bootstrap 4 or 3 classes??
Vikas Saraf
@saraf007
Jun 10 2017 06:52

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

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

see this
still returning null
Jan Shah
@JanShah
Jun 10 2017 06:55
@saraf007 arr[0][0] is the number 1. arr[0] is an array. what are you multiplying?
Rick Riggs
@wikiwiggs
Jun 10 2017 06:55
Try this:
instead of product = product * arr[j]
try:
product = product * arr[i][j];
Rick Riggs
@wikiwiggs
Jun 10 2017 07:00
@saraf007 you good?
tiennguyen15
@tiennguyen15
Jun 10 2017 07:02
boring noe
js too much thing
Jan Shah
@JanShah
Jun 10 2017 07:03
import ranger from './ranger.png'
import ninja from './ninja.png'
const playerImg=new Image(64,64)

export const Player = detail =>{
  const details = new getDetails({...detail,name:'ranger'})
  playerImg.src=ranger 
  return {image:playerImg,...details}
}
I need help refactoring this so i don't have to hardcode playerImg.src, i.e. if I pass in the name 'ninja', the function refers to the imported image ninja
@tiennguyen15 this will brighten up your day :)
tiennguyen15
@tiennguyen15
Jun 10 2017 07:04
haha
too many thing to learn for Js today
too fast too.....
every year newer coming
get tired on FE path
centem
@centem
Jun 10 2017 07:05

My code is not passing Counting Cards challenge. What is wrong with my code? Thank you. `
var count = 0;

function cc(card) {
// Only change code below this line
if (card >= 2 && card <= 6) {
count = count + 1;
return count + " Bet";
} else if (card >= 7 && card <= 9) {
return " Hold";
} else if (card == 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A') {
count = count - 1;
return count + " Hold";
} else {
return "Change Me";
}

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

Jan Shah
@JanShah
Jun 10 2017 07:06
@centem is there anything being returned outside the if else ?
Vikas Saraf
@saraf007
Jun 10 2017 07:07
@wikiwiggs @CentropyIT its working
centem
@centem
Jun 10 2017 07:07
Yea it returns " 0 Hold"
Vikas Saraf
@saraf007
Jun 10 2017 07:07
tq guys
Rick Riggs
@wikiwiggs
Jun 10 2017 07:07
@saraf007 good to hear it.
Jan Shah
@JanShah
Jun 10 2017 07:07
@centem you should use === just observations, I'm still looking
fdemaa
@fdemaa
Jun 10 2017 07:07

guys i have a simple question on the basics of js:

I read that a parameter is like a variable,so why i dont use double quotes to define it?

tiennguyen15
@tiennguyen15
Jun 10 2017 07:08
=== compare type of obj as well too strict too compare int and string in this case
centem
@centem
Jun 10 2017 07:09
=== still does not pass. Thank you though.
Jan Shah
@JanShah
Jun 10 2017 07:09
return " Hold"; < could it be the space ?
@centem that was just an observation, doesn't make any difference to the result here
centem
@centem
Jun 10 2017 07:09
This is one of the tests it does not pass: Cards Sequence 7, 8, 9 should return "0 Hold"
tiennguyen15
@tiennguyen15
Jun 10 2017 07:10
put the var count in side
centem
@centem
Jun 10 2017 07:10
This one passes: Cards Sequence 2, 3, 4, 5, 6 should return "5 Bet"
Rick Riggs
@wikiwiggs
Jun 10 2017 07:11
@centem you have to run all cards, then return based on the accumulated count, not return for every card.
centem
@centem
Jun 10 2017 07:12
Thanks Rick. I will try that.
Rick Riggs
@wikiwiggs
Jun 10 2017 07:12
@centem it will work
@fdemaa I'm not sure what you are asking?
Jan Shah
@JanShah
Jun 10 2017 07:15
var count = 0;
function cc(card) {
// Only change code below this line
if (card >= 2 && card <= 6) {
count = count + 1;
return count + " Bet";
} else if (card >= 7 && card <= 9) {
return " Hold";
} else if (card == 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A') {
count = count - 1;
return count + " Hold";
} else {
return "Change Me";
}
// Only change code above this line
}
// Add/remove calls to test your function.
// Note: Only the last will display
console.log(cc(2)); console.log(cc(3)); console.log(cc(7)); console.log(cc('K')); cc('A');
centem
@centem
Jun 10 2017 07:15
Let me see if I understand. For every count conditionally increment or decrement count. So, at the end I return the count. But where then do I test to see if I return Hold or Bet?
Jan Shah
@JanShah
Jun 10 2017 07:16
@centem this isn't the solution to the problem, but you'll see your output happening one by one
Rick Riggs
@wikiwiggs
Jun 10 2017 07:16
@centem based on final count < 0 OR count === 0 OR count >0
@fdemaa because console.log() doesn't know what to do with all of those numbers unless you tell it.
fdemaa
@fdemaa
Jun 10 2017 07:18
yes i have a *
but i dot know
tiennguyen15
@tiennguyen15
Jun 10 2017 07:18
you sa
fdemaa
@fdemaa
Jun 10 2017 07:18
why when i paste it
they dont appear
tiennguyen15
@tiennguyen15
Jun 10 2017 07:19
you said pass 7 8 9 to return 0 Hold
how can
it will return Hold
fdemaa
@fdemaa
Jun 10 2017 07:20
function textFun (x, y, z) {
    console.log(x * y * z);
}

textFun (2,2,10);
thats what i have
@wikiwiggs
Rick Riggs
@wikiwiggs
Jun 10 2017 07:20
@fdemaa try this:
function textFun (x, y, z) {
    console.log((x * y * z)+"");
}

textFun (2,2,10);
fdemaa
@fdemaa
Jun 10 2017 07:22
@wikiwiggs yes man , what it does the plus and "" ?
it work
Rick Riggs
@wikiwiggs
Jun 10 2017 07:23
@fdemaa console.log expects a string
adding numbers to empty quotes converts it over to a string
centem
@centem
Jun 10 2017 07:23

Here is my updated code which still won't pass. Not sure I understood the guidance. Thanks. ```var count = 0;

function cc(card) {
// Only change code below this line
if (card >== 2 && card <== 6) {
count = count + 1;
} else if (card >== 7 && card <== 9) {
count = count; // count remains unchanged
} else if (card === 10 || card === 'J' || card === 'Q' || card === 'K' || card === 'A') {
count = count - 1;
} else {
return "Change Me";
}

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

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

fdemaa
@fdemaa
Jun 10 2017 07:24
@wikiwiggs thanks
CamperBot
@camperbot
Jun 10 2017 07:24
fdemaa sends brownie points to @wikiwiggs :sparkles: :thumbsup: :sparkles:
:cookie: 326 | @wikiwiggs |http://www.freecodecamp.com/wikiwiggs
Rick Riggs
@wikiwiggs
Jun 10 2017 07:24
@fdemaa You are welcome
@centem don't return "Change Me"; remove this
Jan Shah
@JanShah
Jun 10 2017 07:26
@centem try two sets of if statements, one to increment and decrement the count
Ronald T. Casili
@nvlled
Jun 10 2017 07:27
@wikiwiggs Not really, you can pass any type on console.log and it'll do the string conversion itself.
But then again, it probably depends on the implementation but so far I have not encountered one that strictly requires a string input.
console.log({}, [], 1234, 123.45); // this works just fine
Jan Shah
@JanShah
Jun 10 2017 07:27
and another to see if the count is <1 or 0 or >1 and return the appropriate string
Rick Riggs
@wikiwiggs
Jun 10 2017 07:29
@CentropyIT He's already good on his if statements, just not the final else block in the top one.
Mark R. Baker
@mrbaker1917
Jun 10 2017 07:30
Hello all. I am working on the Finders Keepers challenge. Here is my code:

function findElement(arr, func) {
  var num = arr.filter(function(num) {
     return num % 2 === 0;
  });
  return num[0];
}

findElement([1, 2, 3, 4], function(num){ return num % 2 === 0; });
Jan Shah
@JanShah
Jun 10 2017 07:30
@wikiwiggs I agree.
Mark R. Baker
@mrbaker1917
Jun 10 2017 07:30
This works, but I think I was supposed to somehow invoke the function from the second argument without re-typing it inside the function.
Markus Kiili
@Masd925
Jun 10 2017 07:31
@mrbaker1917 Yes, you need to use func.
centem
@centem
Jun 10 2017 07:31
Thanks Shah! It passes.
Mark R. Baker
@mrbaker1917
Jun 10 2017 07:31
so just arr.filter(func);
Jan Shah
@JanShah
Jun 10 2017 07:32
great :) @centem
Mark R. Baker
@mrbaker1917
Jun 10 2017 07:32
that worked! thanks @Masd925 !
CamperBot
@camperbot
Jun 10 2017 07:32
mrbaker1917 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4239 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jun 10 2017 07:33
@mrbaker1917 Filter is quite inefficient way of finding an element that fulfills a condition, since it always looks through all the array elements even when the first element was the one.
Rick Riggs
@wikiwiggs
Jun 10 2017 07:33
@nvlled MDN says console.log needs a string representation of the parameters given.
blob
Mark R. Baker
@mrbaker1917
Jun 10 2017 07:34
OK, but I think in this exercise I was supposed to use the filter() method, right?
Jan Shah
@JanShah
Jun 10 2017 07:35
@wikiwiggs are you sure?
Rick Riggs
@wikiwiggs
Jun 10 2017 07:35
@CentropyIT about what?
Jan Shah
@JanShah
Jun 10 2017 07:35
ParametersEDIT
obj1 ... objN
A list of JavaScript objects to output. The string representations of each of these objects are appended together in the order listed and output.
Markus Kiili
@Masd925
Jun 10 2017 07:35
@mrbaker1917 No really. That is just a (bad) istruction.
Mark R. Baker
@mrbaker1917
Jun 10 2017 07:36
would a for loop be more efficient, returning the first hit?
Jan Shah
@JanShah
Jun 10 2017 07:36
it doesn't need a string. you can log almost anything
just put it in brackets and run
Pieter Stokkink
@forkerino
Jun 10 2017 07:37
@mrbaker1917 that works, you can also use .findIndex
Or .find
I forgot
Markus Kiili
@Masd925
Jun 10 2017 07:37
@mrbaker1917 Yes.
Jan Shah
@JanShah
Jun 10 2017 07:37
and it runs the output too, logging is one of the best helpers in javascript, for anything
Mark R. Baker
@mrbaker1917
Jun 10 2017 07:38
so which is the most efficient way to find the first true instance in an array?
Rick Riggs
@wikiwiggs
Jun 10 2017 07:38
@CentropyIT I don't really know what to say, it worked for fdemaa
Markus Kiili
@Masd925
Jun 10 2017 07:38
@mrbaker1917 For loop.
Mark R. Baker
@mrbaker1917
Jun 10 2017 07:38
Great thanks!
and @forkerino thanks!
CamperBot
@camperbot
Jun 10 2017 07:38
mrbaker1917 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2538 | @forkerino |http://www.freecodecamp.com/forkerino
Rick Riggs
@wikiwiggs
Jun 10 2017 07:40
@CentropyIT I tend to agree with give this console.log() all sorts of junk inside and it usually works, but the MDN does say it gets the string version, so converting it to it's string version seemed to work
Jan Shah
@JanShah
Jun 10 2017 07:41
I dont know what that means bro
can anyone help with a reactjs problem?
Rick Riggs
@wikiwiggs
Jun 10 2017 07:42
@CentropyIT I would simply say that it means when all else fails: try passing console.log() a string instead of whatever raw value you currently are failing on.
Jan Shah
@JanShah
Jun 10 2017 07:43
import ranger from './ranger.png'
import ninja from './ninja.png'
const playerImg=new Image(64,64)

export const Player = detail =>{
  const details = new getDetails({...detail,name:'ranger'})
  playerImg.src=ranger 
  return {image:playerImg,...details}
}
I need help refactoring this so i don't have to hardcode playerImg.src, i.e. if I pass in the name 'ninja', the function refers to the imported image ninja
Pieter Stokkink
@forkerino
Jun 10 2017 07:43
@wikiwiggs any object or primitive type can be converted to a string with their .toString() method. (in primitive types it is wrapped in an object first and unwrapped after).
So this is the way JS converts anything to a string automatically.
Rick Riggs
@wikiwiggs
Jun 10 2017 07:43
@forkerino Yeah but numbers can be weird
Pieter Stokkink
@forkerino
Jun 10 2017 07:43
If a method requires a string as input, it invokes the .toString() method on it
Ogundele Olumide
@Lumexralph
Jun 10 2017 07:43
@Masd925 Good Morning
Pieter Stokkink
@forkerino
Jun 10 2017 07:43
@wikiwiggs how so?
Rick Riggs
@wikiwiggs
Jun 10 2017 07:44
for instance "1"+"2"+"3" vs. "1"+""+"2"+""+"3"
Pieter Stokkink
@forkerino
Jun 10 2017 07:44
@wikiwiggs those are not numbers, those are strings. :P
Rick Riggs
@wikiwiggs
Jun 10 2017 07:45
those are string representations of numbers
if you get in the wrong js engine this can act funny
Ogundele Olumide
@Lumexralph
Jun 10 2017 07:46
@Masd925 Good Morning
cucy
@cucy
Jun 10 2017 07:46
studlyCapVar should use camelCase in both declaration and assignment sections.
Pieter Stokkink
@forkerino
Jun 10 2017 07:46
@wikiwiggs yeah, I just don't see how this relates to what you said earlier about console.log
cucy
@cucy
Jun 10 2017 07:46
what error?
Jan Shah
@JanShah
Jun 10 2017 07:47
can anyone help with reactjs problem.. I'm sure it's a simple solution, I cannot figure it out
it's not even specific to reactjs
Rick Riggs
@wikiwiggs
Jun 10 2017 07:47
@CentropyIT I think you need to add parenthesis
and pass in the ranger var as a parameter to the function.
@forkerino You know es6 right?
Pieter Stokkink
@forkerino
Jun 10 2017 07:48
yes
Rick Riggs
@wikiwiggs
Jun 10 2017 07:49
can you look at @CentropyIT problem above?
makalohri
@makalohri
Jun 10 2017 07:50
@knrt10 That was cool man thanks
CamperBot
@camperbot
Jun 10 2017 07:50
makalohri sends brownie points to @knrt10 :sparkles: :thumbsup: :sparkles:
:cookie: 423 | @knrt10 |http://www.freecodecamp.com/knrt10
Rick Riggs
@wikiwiggs
Jun 10 2017 07:50
shouldnt this look something like (imgsrc) => {
Jan Shah
@JanShah
Jun 10 2017 07:50
@wikiwiggs I don't know what you mean mate, can you clarify>
it doesn't need that if one parameter is passed
the problem isn't there. it's how to call a variable from a string with the same name
Rick Riggs
@wikiwiggs
Jun 10 2017 07:51
@CentropyIT
import ranger from './ranger.png'
import ninja from './ninja.png'
const playerImg=new Image(64,64)

export const Player = (detail, imgSrc) =>{
  const details = new getDetails({...detail,name:'ranger'})
  playerImg.src=imgSrc 
  return {image:playerImg,...details}
}
HappyRedditor59
@HappyRedditor59
Jun 10 2017 07:51

if i have the following array:

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"]
    }
];

can i loop through it like i would with normal arrays? you know, like the ones with index?

Manish Giri
@Manish-Giri
Jun 10 2017 07:51
yup
@HappyRedditor59
every array has indices
this one does too
cucy
@cucy
Jun 10 2017 07:52

// Declarations
var StUdLyCapVaR;
var properCamelCase;
var TitleCaseOver;
var studlyCapVar ;
// Assignments
STUDLYCAPVAR = 10;
PRoperCAmelCAse = "A String";
tITLEcASEoVER = 9000;

var studlyCapVar ;

var studlyCapVar;
studlyCapVar = 10;

var properCamelCase   = "A String";
var titleCaseOver =9000;

var titleCaseOver ;
error?
Manish Giri
@Manish-Giri
Jun 10 2017 07:52
at index 0 you have the object
{
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    }
and so on
cucy
@cucy
Jun 10 2017 07:52
studlyCapVar should use camelCase in both declaration and assignment sections. ??
Manish Giri
@Manish-Giri
Jun 10 2017 07:53
@cucy you should be modifying the existing declarations and assignments.
not make new ones.
Jan Shah
@JanShah
Jun 10 2017 07:53
@wikiwiggs I don't know what that does, but it's not what I need.
export const Player = detail =>{
  const details = new getDetails({...detail,name:detail.name})
  playerImg.src=detail.name //<< or whatever works, this doesn't. 
  return {image:playerImg,...details}
}
Rick Riggs
@wikiwiggs
Jun 10 2017 07:54
@CentropyIT Unfortunately I don't either, I was just noticing that you need to pass it in somewhere, but I don't know the ES6 way of doing this well enough.
Jan Shah
@JanShah
Jun 10 2017 07:55
I need it to return only the stuff I put in and not have it's own opinions.
Pieter Stokkink
@forkerino
Jun 10 2017 07:55
@CentropyIT the easiest way I can think of is to use a ternary to set playerImg.src , which would be hardcoding too. Not sure if there is an easy way to convert a string to a variable name. If you have many different images, I'd probably use a lookup object.
Jan Shah
@JanShah
Jun 10 2017 07:55
I'm having to hard code player name and img
@forkerino lookup like an array?
let weaponList=[axe,sword,hammer,knife,staff]
let weaponName=['axe','sword','hammer','knife','staff']
const weapon=new Image(64,64)
var chosenWeapon=rw(0,4)
weapon.src=weaponList[chosenWeapon]
weapon.name=weaponName[chosenWeapon]

class getDetails {
  constructor(props) {
    this.name=props.name
    this.x=props.x
    this.y=props.y
    this.weapon={name:weapon.name,img:weapon}
    this.xp=props.xp
    this.bonus={bonus:bonus.name,img:bonus}
  }
  get location() {
    return [this.x,this.y,1,1]
  }
}
Rick Riggs
@wikiwiggs
Jun 10 2017 07:57
@CentropyIT Try this first, this might be a react thing: const details = new getDetails({{...detail,name:detail.name}})
Pieter Stokkink
@forkerino
Jun 10 2017 07:57
@CentropyIT more like an object:
{ 
  'ranger' : './ranger.png', 
  ...
}
Rick Riggs
@wikiwiggs
Jun 10 2017 07:57
meaning double up the mustache
its a jsx nuance