These are chat archives for FreeCodeCamp/HelpJavaScript

2nd
Jan 2017
Joseph
@revisualize
Jan 02 2017 00:01
This message was deleted
CamperBot
@camperbot
Jan 02 2017 00:01
:bulb: to format code use backticks! ``` more info
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:02
try using /[^a-zA-Z0-9]/g for the regex instead
Joseph
@revisualize
Jan 02 2017 00:02

If you are posting code that is large, Please use Gist - https://gist.github.com/ then please paste the link here.
...
How to do code block format: ..... PLEASE try with a small block of code before you try to make a bigger one.
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code
```js [SHIFT+ENTER]
// your code here
``` [CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

...
You can also do inline code formatting:
A string of text with a `variable` or `other bit of code`.
Output:
A string of text with a variable or other bit of code.

mitron6
@mitron6
Jan 02 2017 00:16
@davidpetric Hi David. Looks like you are having a little trouble with your palindrome checker.
Joseph
@revisualize
Jan 02 2017 00:18
@mitron6 They were using \W and not realizing that \W also includes the _ @HeebieGeeBee gave them one response to fix their issue.
mitron6
@mitron6
Jan 02 2017 00:19
@revisualize Am I the only one who has trouble following a conversation when there are undirected responses?
Joseph
@revisualize
Jan 02 2017 00:20
Well, The response came directly after they made their post. And no one said anything else. So...
mitron6
@mitron6
Jan 02 2017 00:21
@revisualize So thus I'm the only stupid one... :)
Joseph
@revisualize
Jan 02 2017 00:21
OH! Should I tag you or will you realize that undirected response is for you?
I didn't say that.
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:21
i often forget to tag ppl
Joseph
@revisualize
Jan 02 2017 00:22
It's fine.
mitron6
@mitron6
Jan 02 2017 00:23
Maybe @davidpetric didn't notice your help. He didn't answer.
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:23
i wont lose sleep over it
Joseph
@revisualize
Jan 02 2017 00:24
HEHE
mitron6
@mitron6
Jan 02 2017 00:24
@HeebieGeeBee But how do you keep track when there are many conversations going on at once?
Joseph
@revisualize
Jan 02 2017 00:24
People start tagging people.
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:24
i just give up if i get lost
mitron6
@mitron6
Jan 02 2017 00:25
So when there are just a few folks talking, it is just fine to skip tagging.
Joseph
@revisualize
Jan 02 2017 00:25
Sure.
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:25
Can someone help me with the profile lookup challenge? I've been stuck on it for like half an hour and I'm still not sure why it's not working ;( .
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:25
of course
Joseph
@revisualize
Jan 02 2017 00:25
Sure. What's your code.
Just look at the conversation we have had here.. There hasn't been much tagging at all.
But, you can follow the flow.
And if I ask a question.
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:26
I'm not sure how to format my code to the chat though
Joseph
@revisualize
Jan 02 2017 00:26
Can you please just post the code for your function and not post the object?
One sec.
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:26
ppl pasting huge blocks of code one after the other is the thing that leads me to getting lost and giving up
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:26

function lookUpProfile(firstName, prop){

for (var i = 0; i < contacts.length; i++) {
if (firstName === contacts[i].firstName) {
if (prop === contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
} else {
return "No such property";
}
} return "No such contact";
}
}

lookUpProfile("Akira", "likes");

Joseph
@revisualize
Jan 02 2017 00:26
@BozhidarKabzamalov Okay. Can I ask you a side question?
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:26
Yes
Joseph
@revisualize
Jan 02 2017 00:26
@BozhidarKabzamalov Let's say you were at a big business event and throughout the event you got handed 200 business cards. Now, I walk up to you at the end and ask you.. Do you have a Business Card for "Jane Smith"? Now you loop look through your stack of 200 business cards. When would you tell me that you didn't have a business card for Jane?
OH WAIT!
That isn't your issue.
@BozhidarKabzamalov This (prop === contacts[i].hasOwnProperty(prop)) is your issue.
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:28
Hmm, how so?
Joseph
@revisualize
Jan 02 2017 00:28
@BozhidarKabzamalov .hasOwnProperty() only returns true or false. Will prop ever be true or false?
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:28
oooohhh
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:29
also it asks you if firstname exists && it has the property of prop
Ming Lei
@dabeister
Jan 02 2017 00:29
Thanks @kirah1314 @Rafase282 @jsommamtek @oshliaer for your help with Algorithm: Chunky Monkey
CamperBot
@camperbot
Jan 02 2017 00:29
:cookie: 314 | @jsommamtek |http://www.freecodecamp.com/jsommamtek
:cookie: 347 | @oshliaer |http://www.freecodecamp.com/oshliaer
:cookie: 987 | @kirah1314 |http://www.freecodecamp.com/kirah1314
:star2: 1432 | @rafase282 |http://www.freecodecamp.com/rafase282
dabeister sends brownie points to @kirah1314 and @rafase282 and @jsommamtek and @oshliaer :sparkles: :thumbsup: :sparkles:
Joseph
@revisualize
Jan 02 2017 00:29
@HeebieGeeBee That logic is fine.
Hence the reason for the first if then the nested if / else
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:30
i dont like it
Joseph
@revisualize
Jan 02 2017 00:30
I do.
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:30
Wait so what function should I use instead of it? I can't recall any from the previous exercises.
Joseph
@revisualize
Jan 02 2017 00:30
@BozhidarKabzamalov So, did you remove the prop ===
@BozhidarKabzamalov You're fine.
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:31
Ah yes
Joseph
@revisualize
Jan 02 2017 00:31
@BozhidarKabzamalov I'm guessing that if you remove the prop === your code may still not work.
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:31
you dont need to use a different function its just either true or false
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:31
Now it seems to work partially, I might be able to figure it out on my own now :)
Thanks for the help
Joseph
@revisualize
Jan 02 2017 00:31
@BozhidarKabzamalov Well.. There's one other part.
That's where this..
@BozhidarKabzamalov Let's say you were at a big business event and throughout the event you got handed 200 business cards. Now, I walk up to you at the end and ask you.. Do you have a Business Card for "Jane Smith"? Now you loop look through your stack of 200 business cards. When would you tell me that you didn't have a business card for Jane?
comes in.
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:33
i wouldnt search through 200 business cards i would just say no and get another one
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:33
After I look through them all? :D
eksilva
@eksilva
Jan 02 2017 00:33
Any suggestions for the Word Blanks challenge?
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:34
use spaces @eksilva
he wants you to say what Jane is @BozhidarKabzamalov
i think or maybe he's trying to start a deep philosophical discussion
what isa name really
mitron6
@mitron6
Jan 02 2017 00:37
@BozhidarKabzamalov Trace your code for the first contact. What happens if the name for the first contact does not match?
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:37
Shouldn't it return "No such contact"; ?
Sara Dorris
@saralee233
Jan 02 2017 00:38
MyDecimal. I'm sure I'm doing it wrong but I can't figure out why...it seems simple enough that setting var myDecimal= 5.7 should be the answer. What am I doing wrong?
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:38
how do you know if theres no such contact
Zerka1982
@Zerka1982
Jan 02 2017 00:39
hi guys , can anybody help me with one css issue please
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:39
put up your code @saralee233
this is a javascript chat but yeah most likey @Zerka1982
Sara Dorris
@saralee233
Jan 02 2017 00:40
@HeebieGeeBee i fixed it...i forgot to add the semicolon
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:40
cool well done
Zerka1982
@Zerka1982
Jan 02 2017 00:40
I apologise !
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:40
lol no need to be sorry
Zerka1982
@Zerka1982
Jan 02 2017 00:40
I need help with one tricky thing please
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:41
then say what it is
Zerka1982
@Zerka1982
Jan 02 2017 00:41
I wanna make a photo to be clickable button

I wrote the code this way

<input type="image" src="/images/send.png">

HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:41
ok
Zerka1982
@Zerka1982
Jan 02 2017 00:42
The problem is that I cannot display the photo :(
I am not sure if I did any mistake inside src="/images/send.png"
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:42
whats it going to do?
you want it to be a link?
Moisés Man
@moigithub
Jan 02 2017 00:43
if u wanna display a photo.. u need to use img tag.. not input
http://www.w3schools.com/tags/tag_img.asp @Zerka1982
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:44
Ok my code seems to be working only for the first object in my array, however, it says "No such contact" for the first name of the second object, even though there is such contact.
Zerka1982
@Zerka1982
Jan 02 2017 00:44
I tried also <img src="/images/send.png"> and still not working
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:44
this is confusing me so hard right now
Moisés Man
@moigithub
Jan 02 2017 00:45
make sure the path point to an existant image file @Zerka1982
Joseph
@revisualize
Jan 02 2017 00:45
@Zerka1982 I don't believe you.
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:45
@Zerka1982 i take you you actually have this send.png in a images folder
Zerka1982
@Zerka1982
Jan 02 2017 00:45
send.png is inside images folder
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:45
and this images folder is in the same directory as your html file
Joseph
@revisualize
Jan 02 2017 00:45
@BozhidarKabzamalov What is your problem?
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:45
I changed the function to :
Zerka1982
@Zerka1982
Jan 02 2017 00:45
my html file is not inside images
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:46

function lookUpProfile(firstName, prop){

for (var i = 0; i < contacts.length; i++) {
if (firstName === contacts[i].firstName) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
} else {
return "No such property";
}
} return "No such contact";
}
}

HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:46
no in images folder
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:46
and now it only works for the first object in my array
Brian Mayrose
@intoro
Jan 02 2017 00:46
I need help with the "Nesting For Loops" lesson please somebody
Joseph
@revisualize
Jan 02 2017 00:46
@BozhidarKabzamalov Okay. Did you answer my other question?
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:46
just that the html file and images folder are in the same root
Zerka1982
@Zerka1982
Jan 02 2017 00:47
@HeebieGeeBee so what should i do
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:47
@Joseph Not sure how it answer it
Joseph
@revisualize
Jan 02 2017 00:47
@BozhidarKabzamalov Let's say you were at a big business event and throughout the event you got handed 200 business cards. Now, I walk up to you at the end and ask you.. Do you have a Business Card for "Jane Smith"? Now you loop look through your stack of 200 business cards. When would you tell me that you didn't have a business card for Jane?
Cindy Lee
@leecindy
Jan 02 2017 00:48
Hi! Can someone help me on Manipulating Complex Objects?
Instructions:
Add a new album to the myMusic array. Add artist and title strings, release_year number, and a formats array of strings.
Code:
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:48
@Zerka1982 you need to absolutely sure that the src is pointing to the correct file
Zerka1982
@Zerka1982
Jan 02 2017 00:48
I ll check it again
Joseph
@revisualize
Jan 02 2017 00:48
@BozhidarKabzamalov Imagine I'm a 5 year old. And I just asked that question. How would you answer it in the simplest terms?
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:48
thats the only reason it wont display
Cindy Lee
@leecindy
Jan 02 2017 00:48
What am I supposed to do there? the instruction is not very helpful there...
Joseph
@revisualize
Jan 02 2017 00:49
@BozhidarKabzamalov I'm not asking you a programming question just a side question to help change some of your logic to think like a programmer.
Brian Mayrose
@intoro
Jan 02 2017 00:49
I need help with the "Nesting For Loops" lesson please somebody
Monesul Haque
@mones-cse
Jan 02 2017 00:49
@intoro sure
Brian Mayrose
@intoro
Jan 02 2017 00:49
@mones-cse thanks
CamperBot
@camperbot
Jan 02 2017 00:50
:cookie: 446 | @mones-cse |http://www.freecodecamp.com/mones-cse
intoro sends brownie points to @mones-cse :sparkles: :thumbsup: :sparkles:
Joseph
@revisualize
Jan 02 2017 00:50
@intoro Should I paste that again?
Brian Mayrose
@intoro
Jan 02 2017 00:50
from the example i cant figure out the solution
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:50
@leecindy ask @revisualize to put up his gist link
Brian Mayrose
@intoro
Jan 02 2017 00:50
@mones-cse from the example i cant figure out the solution
Monesul Haque
@mones-cse
Jan 02 2017 00:50
@intoro can you give me the problem link
Joseph
@revisualize
Jan 02 2017 00:50
@HeebieGeeBee @leecindy I don't have a gist for that one.
I manually type this one out.
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:51
@revisualize I understand and I'm trying to figure out how it relates to the code. I guess that I'd tell you that I don't have a card for Jane after I've looped through the cards
Joseph
@revisualize
Jan 02 2017 00:51
@BozhidarKabzamalov That is the answer I was looking for.
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:51
so slack @revisualize
Monesul Haque
@mones-cse
Jan 02 2017 00:51
ok give me 1 min
Joseph
@revisualize
Jan 02 2017 00:51
@BozhidarKabzamalov Not a programming question.
@BozhidarKabzamalov Now.
@BozhidarKabzamalov So, you're saying that after you loop look through all of the contacts cards in your array of object stack. That you'd tell me you don't have one for the individual?
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:52
Oooooooooooh,
it worked
wow
that was so
Joseph
@revisualize
Jan 02 2017 00:52
@BozhidarKabzamalov Now do you understand how it is a programming question?
Bozhidar Stoyanov Kabzamalov
@BozhidarKabzamalov
Jan 02 2017 00:52
simple yet hard to understand
yeah, thanks a lot
Sara Dorris
@saralee233
Jan 02 2017 00:54
I know I shouldn't have 2 equal signs but what else should I have
// Only change code below this line
var remainder= 11 % 3 = 2;
Monesul Haque
@mones-cse
Jan 02 2017 00:54

@intoro

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

did you understand this code that given in the example ?

HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 00:54
just the 11 % 3 @saralee233
Sara Dorris
@saralee233
Jan 02 2017 00:55
@HeebieGeeBee Thanks!
CamperBot
@camperbot
Jan 02 2017 00:55
saralee233 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 424 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Monesul Haque
@mones-cse
Jan 02 2017 00:56
@revisualize good share (y)
Joseph
@revisualize
Jan 02 2017 00:57
I only shared it three times in this chat in the last 40min.
Monesul Haque
@mones-cse
Jan 02 2017 00:57
ha ha ha :smile:
Joseph
@revisualize
Jan 02 2017 00:59
So, how long do I wait for the check at a restaurant before the food is free?
The waitress even cleared away my dishes.
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:00
just walk out
Anthony Mitchell
@Drantho
Jan 02 2017 01:01
Is anyone good with closures?
Joseph
@revisualize
Jan 02 2017 01:01
Nope.
No one is good with closures.
Closures suck
Anthony Mitchell
@Drantho
Jan 02 2017 01:02
lol that is what im learning
soccer1119
@soccer1119
Jan 02 2017 01:02
how do I make a assigned to b with =
Joseph
@revisualize
Jan 02 2017 01:02
@soccer1119 How do you assign the value of 7 to a variable num? ... var num = 7;
Now if you want you can use a variable to store values.
Like in mathmatics. num + 3 = 10 What is the value of num?
var x = num + 3; ... That outputs 10
So, you can do several things with variables. But, you need to understand that variables hold values and variables can be used with other variables.
So, how do you assign the value of 5 to a variable x? ... x = 5; (Which is also overwriting the previous value of 10 from above.
How do you assign the value of x to a variable y?
Look at the way things are written. var y = x;
How do you assign the value of 42 to a variable answer? ... What is the answer?
Variables hold values. Just understand that.
Anthony Mitchell
@Drantho
Jan 02 2017 01:05
@revisualize maybe you could help me understand this error: ```
soccer1119
@soccer1119
Jan 02 2017 01:05
@revisualize Thank you!
CamperBot
@camperbot
Jan 02 2017 01:05
soccer1119 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2794 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jan 02 2017 01:05
@soccer1119 Does all of that make sense?
Anthony Mitchell
@Drantho
Jan 02 2017 01:06

```function addTogether(num1, num2) {

if(num2 !== null){
return num1 + num2;
} else{

return function(num2){
  return num1 + num2;
};

}

}

addTogether(2)(3);```

that is weird
Joseph
@revisualize
Jan 02 2017 01:06
@Drantho That isn't a Closure.
That's Currying.
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:07
mmm curry
Joseph
@revisualize
Jan 02 2017 01:08
@Drantho If you google Currying Function it may give you better results.
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:08
you have a long way to go with that exercise @Drantho
its not nice
Anthony Mitchell
@Drantho
Jan 02 2017 01:08
@revisualize @HeebieGeeBee thanks this one did kinda come out of nowhere
CamperBot
@camperbot
Jan 02 2017 01:08
drantho sends brownie points to @revisualize and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 425 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:star2: 2795 | @revisualize |http://www.freecodecamp.com/revisualize
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:09
theres no easy anymore
Anthony Mitchell
@Drantho
Jan 02 2017 01:10
@revisualize will currying satisfy this silly excersize or do I need to learn what a closure actually is and make that work?
Joseph
@revisualize
Jan 02 2017 01:10
This lady took my plate three other tables have came in and ate and are leaving and she still hasn't given me my bill.
OH!
Shit.
Joseph
@revisualize
Jan 02 2017 01:10
She just gave me my bill.
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:11
that took me like 2days, and many times i just scrapped all my code
@Drantho
dont even start writing code really until youve planned out everything that you need to do
i think theres like 6 steps
Joseph
@revisualize
Jan 02 2017 01:12
It can't be that hard.
Brian Mayrose
@intoro
Jan 02 2017 01:12
@mones-cse i did understand the example, I just dont know what to use to change it from displaying the numbers to multiplying them

```` for (var i=0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++) {
console.log(arr[i]*[j]);

}

}````

HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:12
well i didnt spend 48 hours on it
have you done it @revisualize
Michael Grant Warshowksy
@step48765
Jan 02 2017 01:14
yo dudes
Monesul Haque
@mones-cse
Jan 02 2017 01:14
@intoro
arr[i][j]
itself a value
you should have a product variable which have initial value 1
which will multiply with arr[i][j]
Michael Grant Warshowksy
@step48765
Jan 02 2017 01:14
@c0d0er2 what is that link for?
Brian Mayrose
@intoro
Jan 02 2017 01:16
@mones-cse yes i do
Michael Grant Warshowksy
@step48765
Jan 02 2017 01:16
@c0d0er2 it dos'nt seem so hard what do u need help on it with
@HeebieGeeBee do u now how to turn on notifications for this IM
Monesul Haque
@mones-cse
Jan 02 2017 01:16
like product=product*arr[i][j];
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:17
huh?
Brian Mayrose
@intoro
Jan 02 2017 01:17
@mones-cse thanks I got it, you are legit
CamperBot
@camperbot
Jan 02 2017 01:17
intoro sends brownie points to @mones-cse :sparkles: :thumbsup: :sparkles:
:warning: intoro already gave mones-cse points
Monesul Haque
@mones-cse
Jan 02 2017 01:18
@intoro :v:
Hasan
@MHAhmed
Jan 02 2017 01:18
i feel my javascript is very weak. any advise on how to get better at it?
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:18
read and practise
John Andrew Torres
@jandrewtorres
Jan 02 2017 01:18
Do the bonfires
Joseph
@revisualize
Jan 02 2017 01:19
If only someone would have spent 5+ hours writing a document about nested for loops. Gist by revisualize / FreeCodeCamp - Nesting For Loops.js
John Andrew Torres
@jandrewtorres
Jan 02 2017 01:19
best javascript training ive had thusfar
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:19
thats all im doing
John Andrew Torres
@jandrewtorres
Jan 02 2017 01:19
  • regex experience
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:19
watching videos about it too
Hasan
@MHAhmed
Jan 02 2017 01:19
like i have done the basic javascript stuff so far but i feel i need more practice and need to put it all in to practice for it to sink in
Joseph
@revisualize
Jan 02 2017 01:20
@MHAhmed Write some JavaScript that does stuff. Write some JavaScript that does stuff. Write some JavaScript that does stuff. Write some JavaScript that does stuff. Write some JavaScript that does stuff. Write some JavaScript that does stuff. Over and over and over and over and over and over and over and over and over and over and over and over and over and over and ... you get the idea.
Alando
@Landoghini
Jan 02 2017 01:21
Im trying to make a grid using jquery, but its coming up incomplete can some try to explain why please?
Hasan
@MHAhmed
Jan 02 2017 01:21
@revisualize thats the best way to learn
Joseph
@revisualize
Jan 02 2017 01:21
Well, I finally paid for my food that I ate an hour ago.
Time for me to go home.
John Andrew Torres
@jandrewtorres
Jan 02 2017 01:21
Its also a matter of programming exp. It will be a tough learning curve if you don't have programming experience, because you're not just learning how to program in javascript, your learning how to program. If you understand other languages such as python, c, java etc. it will be easier to pick up. If not, keep trucking!
I've learned a lot by reworking the bonfires, even after I complete them, to make them better.
Hasan
@MHAhmed
Jan 02 2017 01:21
@jandrewtorres i did some basic python
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:22
@revisualize you'll be hungry by thte time you get home
@Landoghini how can we do that when we have no idea what you have done
Hasan
@MHAhmed
Jan 02 2017 01:22
i understand the concept behind it all i just need to see it in practice
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:23
@MHAhmed set yourself little projects to do
zamora88
@zamora88
Jan 02 2017 01:24
I have been studying code with FreeCodeCamp and also w3schools.com and was wondering what the reputation of that website is in the coding world?
Hasan
@MHAhmed
Jan 02 2017 01:25
i been told w3schools is a little out dated
zamora88
@zamora88
Jan 02 2017 01:25
Are their certifications legitimate or a waste of time and money?
Hasan
@MHAhmed
Jan 02 2017 01:25
but i do find it good for quick ref
zamora88
@zamora88
Jan 02 2017 01:25
@MHAhmed I have heard other people say that.
Tony Ko
@htkoca
Jan 02 2017 01:25
Hey free code camp !
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:25
@zamora88 i think in the coding world youre judged on your work not one certifications
zamora88
@zamora88
Jan 02 2017 01:26
I am trying to figure out if I should bother with their certifications?
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:26
and im pretty sure freecodecamp is free
zamora88
@zamora88
Jan 02 2017 01:26
@HeebieGeeBee I agree. I have read different opinions about work vs cert.
Tony Ko
@htkoca
Jan 02 2017 01:26
I've got a question about a certain challenge if anyone's free
zamora88
@zamora88
Jan 02 2017 01:26
haha
Alando
@Landoghini
Jan 02 2017 01:26
@HeebieGeeBee https://jsfiddle.net/landoghini/0pjm0any/ this is the grid
Hasan
@MHAhmed
Jan 02 2017 01:27
@zamora88 i think you would be better off showcasing the work you have done and what you can do than show them a paper but thats my opinion
Tony Ko
@htkoca
Jan 02 2017 01:27
Wouldn't hurt to do both, but if you have substantial work it is obviously better
Hasan
@MHAhmed
Jan 02 2017 01:27
like many people with degrees these days but when you apply for the job they ask what exp. you have
Tony Ko
@htkoca
Jan 02 2017 01:28
People want to see you know the stuff and can do the work so what @hasan said
zamora88
@zamora88
Jan 02 2017 01:28
@MHAhmed Good point!
c0d0er
@c0d0er
Jan 02 2017 01:28
i have .exe files in windows 10, but cannot open, it shows: Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item. could anybody help to resolve this problem?
Joseph
@revisualize
Jan 02 2017 01:28
@HeebieGeeBee But, I'm home.
Tony Ko
@htkoca
Jan 02 2017 01:29
Kind of not the scope of this channel @c0d0er , but that error could be from a lot of reasons
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:29
well youre lucky enough to live close to a restaurant then @revisualize
Joseph
@revisualize
Jan 02 2017 01:29
@HeebieGeeBee The place I ate at was like a block and a half away from my place.
Tony Ko
@htkoca
Jan 02 2017 01:29
@c0d0er do you have read / execute permissions of the exe (properties menu)
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:30
cool my nearest restaurant is 6 miles away
Joseph
@revisualize
Jan 02 2017 01:30
Wow. That's pretty far.
Tony Ko
@htkoca
Jan 02 2017 01:30
anyway, anyone finished the "smallest common multiple challenge?"
c0d0er
@c0d0er
Jan 02 2017 01:30
@htko89 how could i reade/execute permissions of the exe?
Tony Ko
@htkoca
Jan 02 2017 01:31
right click > properties > permissions i think
Joseph
@revisualize
Jan 02 2017 01:31
@HeebieGeeBee I have over 10 restaurants within 10 blocks of my apartment.
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:31
yes @htko89 its not easy
Tony Ko
@htkoca
Jan 02 2017 01:31
i haven't used windows in a few weeks
I'm really confused at what it means "evenly divided by both"
Hasan
@MHAhmed
Jan 02 2017 01:31
@zamora88 if i was you i would just make a personal website and build some personal project and maybe when you get more exp at coding go freelance and do some small projects list them on your website and show your code too. and get your freelancer to post a comment to your work and showcase that to an employee in an interview which would be much better than you going in and saying i got this paper that says i can do this. instead you can say i can do this and here is the evidence
Joseph
@revisualize
Jan 02 2017 01:31
LOL! I look at this: https://files.gitter.im/FreeCodeCamp/FreeCodeCamp/1YNI/20161230_234231.jpg And thing.. Damn people must thing I'm a horrible alcoholic.
Why is it upside down!?
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:32
i have a bottle of crown royal
but nothing else i dont think
my vodkz is smirnoff
why so much captain morgan
Joseph
@revisualize
Jan 02 2017 01:34
@HeebieGeeBee Poor choices.
Tony Ko
@htkoca
Jan 02 2017 01:34
Theres at least 4 in there lol
Joseph
@revisualize
Jan 02 2017 01:35
I bought a small bottle for a party and my ride to the party had to cancel.
So, I got the extra small bottle.
Chris
@chriiisdugger
Jan 02 2017 01:35
hey guys
Joseph
@revisualize
Jan 02 2017 01:35
I got an extra bigger bottle because well my other bottle was about to run out.
I like to have two of everything.
Except fireball
Tony Ko
@htkoca
Jan 02 2017 01:35
If i kept all the beer bottles I have ever drank, it would probably fill a room
but then again its beer
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 01:36
i dont drink much
Chris
@chriiisdugger
Jan 02 2017 01:36
i dont see what im doing wrong here can someone please help me?
Tony Ko
@htkoca
Jan 02 2017 01:36
whats up christ
chris*
LOL
sorry keyboard habit
Chris
@chriiisdugger
Jan 02 2017 01:37

var myVar = 87;

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

Joseph
@revisualize
Jan 02 2017 01:37
OH! That's easy.
Tony Ko
@htkoca
Jan 02 2017 01:37
do myVar++
Joseph
@revisualize
Jan 02 2017 01:37

@chriiisdugger

var num = 5;
num = num + 1; // 6
num += 1; // 7
num++; // 8

See how the one for getting num from 7 to 8 doesn't use the assignment operator (=)?
The lesson is requesting that you recreate that process so that you know how to increment and decrement a number with short notation.

Chris
@chriiisdugger
Jan 02 2017 01:37
@htko89 thanks buddy I had no clue
CamperBot
@camperbot
Jan 02 2017 01:37
chriiisdugger sends brownie points to @htko89 :sparkles: :thumbsup: :sparkles:
:cookie: 295 | @htko89 |http://www.freecodecamp.com/htko89
Tony Ko
@htkoca
Jan 02 2017 01:38
@revisualize had the more concise answer though :)
thanks @revisualize
CamperBot
@camperbot
Jan 02 2017 01:38
htko89 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2796 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jan 02 2017 01:38
@htko89 But, I also explained WHY.
The WHY is the important part.
Chris
@chriiisdugger
Jan 02 2017 01:38
@revisualize thanks buddy
CamperBot
@camperbot
Jan 02 2017 01:38
chriiisdugger sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2797 | @revisualize |http://www.freecodecamp.com/revisualize
Tony Ko
@htkoca
Jan 02 2017 01:38
yes :sparkles:
Christian Payumo
@SLYMoosic
Jan 02 2017 01:38
help me with queue in javascript
CamperBot
@camperbot
Jan 02 2017 01:38
no wiki entry for: me with queue in javascript
WVKING20
@WVKING20
Jan 02 2017 01:40
Can someone please explain the directions for Local Scope and Functions excersise
Joseph
@revisualize
Jan 02 2017 01:40
@SLYMoosic What's your function?
Christian Payumo
@SLYMoosic
Jan 02 2017 01:40
nextInLine
Joseph
@revisualize
Jan 02 2017 01:41
@SLYMoosic Do you realize the answer you gave is like me asking ... What are you drinking? ... A liquid
Tony Ko
@htkoca
Jan 02 2017 01:41
@WVKING20 what do you need help with?
Joseph
@revisualize
Jan 02 2017 01:41
@SLYMoosic Then I look at you funny and wonder .. How do you drink non-liquids?
@SLYMoosic What is your function?
Yang Lu
@Luyang2016
Jan 02 2017 01:42

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

}

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

// Change this value to test
myTest(1); I know this isn't the correct way to use "switch", but I passed . So how to use the switch clause? How should I write that?

Christian Payumo
@SLYMoosic
Jan 02 2017 01:42
sry idk anymore this is so complicated
WVKING20
@WVKING20
Jan 02 2017 01:42
@htko89 I don't understand what they are asking
Joseph
@revisualize
Jan 02 2017 01:43
@SLYMoosic How can I help you if I can't see your code?
Christian Payumo
@SLYMoosic
Jan 02 2017 01:43
i haven't started, i don't know how to execute it
Tony Ko
@htkoca
Jan 02 2017 01:43
well you're used to declaring variables globally, var testvar = 12; will return 12 in every function
Joseph
@revisualize
Jan 02 2017 01:43
What is your FUNCTION?
WVKING20
@WVKING20
Jan 02 2017 01:43
@htko89 true
Joseph
@revisualize
Jan 02 2017 01:43
Omg.
some people.
Alando
@Landoghini
Jan 02 2017 01:44
Can some one try to explain why my grid is incomplete? https://jsfiddle.net/landoghini/0pjm0any/
Tony Ko
@htkoca
Jan 02 2017 01:44
what its asking you to do , is declare a variable inside a function, instead of outside one. When that happens, the variable is a "local" variable
local variables only work inside their function, and will return nothing in functions outside the one its declared in
WVKING20
@WVKING20
Jan 02 2017 01:45

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

console.log(myVar);
}
myLocalScope();
var myVar = "Strict";
// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);

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

Have I not done this?
Tony Ko
@htkoca
Jan 02 2017 01:46
yes you did, but you also declared it globally
delete var myvar.. outside the function

should be like ```function myLocalScope() {
'use strict';
var myVar = "strict";
console.log(myVar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);
```

WVKING20
@WVKING20
Jan 02 2017 01:46
It still says I need a local variable
Christian Payumo
@SLYMoosic
Jan 02 2017 01:47

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

return item; // Change this line
}

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

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

Tony Ko
@htkoca
Jan 02 2017 01:48
@WVKING20 lemme check
wow that challenge is kind of buggy
uriznik
@uriznik
Jan 02 2017 01:49
@Landoghini Your container width is smaller than the size of the grid so it gets wrapped. You're also counting from 1 through 19 , is that what you meant to do?
WVKING20
@WVKING20
Jan 02 2017 01:49
Thats what I thought because I've made a local variable multiple times
Tony Ko
@htkoca
Jan 02 2017 01:49
lol wtf
function myLocalScope() {
  'use strict';
  var myVar = 'strict';

  console.log(myVar);
}
myLocalScope();
// Run and check the console
// myVar is not defined outside of myLocalScope
// console.log(myVar);

// Now remove the console log line to pass the test
zamora88
@zamora88
Jan 02 2017 01:50
@MHAhmed thanks so much for your advice!
CamperBot
@camperbot
Jan 02 2017 01:50
zamora88 sends brownie points to @mhahmed :sparkles: :thumbsup: :sparkles:
:cookie: 222 | @mhahmed |http://www.freecodecamp.com/mhahmed
WVKING20
@WVKING20
Jan 02 2017 01:50
It says refreshing the page may help if you get stuck but it hasn't worked so far
Diego Mayer
@Chrono79
Jan 02 2017 01:51
@WVKING20 show your code
WVKING20
@WVKING20
Jan 02 2017 01:52

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

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

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);

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

Diego Mayer
@Chrono79
Jan 02 2017 01:52
@WVKING20 delete the last console.log
Tony Ko
@htkoca
Jan 02 2017 01:54
@WVKING20 see if that works what @Chrono79 said, it doesnt work for me for some reason
WVKING20
@WVKING20
Jan 02 2017 01:54
Thanks that worked this time @Chrono79 @htko89
CamperBot
@camperbot
Jan 02 2017 01:54
wvking20 sends brownie points to @chrono79 and @htko89 :sparkles: :thumbsup: :sparkles:
:star2: 3012 | @chrono79 |http://www.freecodecamp.com/chrono79
:cookie: 296 | @htko89 |http://www.freecodecamp.com/htko89
Diego Mayer
@Chrono79
Jan 02 2017 01:54
:+1:
Tony Ko
@htkoca
Jan 02 2017 01:54
lol woot
WVKING20
@WVKING20
Jan 02 2017 01:55
I've tried that before though and it didn't work until I refreshed it
Tony Ko
@htkoca
Jan 02 2017 01:55
yeah i just did the same lol, i guess it got confused
Diego Mayer
@Chrono79
Jan 02 2017 01:56
Check how to format your code in the chat room @WVKING20, click in more info below
CamperBot
@camperbot
Jan 02 2017 01:56
:bulb: to format code use backticks! ``` more info
zyj12345
@zyj12345
Jan 02 2017 01:56

var array = [4,5,6,7,8];
var singleVal = 0;

// 只能在这一行下面写代码
array.reduce(function(previousVal, currentVal) {
return previousVal+currentVal;
});
singleVal = array;

Diego Mayer
@Chrono79
Jan 02 2017 01:57
@zyj12345 use singleVal = array.reduce...
Tony Ko
@htkoca
Jan 02 2017 02:01
array.reduce returns a result. when you do singleVal=array all you're doing is making singleVal = [4,5,6,7,8]
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 02:02
@Landoghini did you sort your problem with the grid?
Thiago Cruz
@thy705
Jan 02 2017 02:05

Hey guys! What am I doing wrong here? Maybe it has to do with me never playing blackjack, but I doubt it: var count = 0;

function cc(card) {
// Only change code below this line

if (card == 2 || card == 3 || card==4||card==5||card==6){

count++;
return count + "Bet";

} else if (card ==10||card=='J'||card=='Q'||card=='K'||card=='A'){

count--;
return count + "Hold";

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

Tony Ko
@htkoca
Jan 02 2017 02:06
function cc(card) {
// Only change code below this line
if (card == 2 || card == 3 || card==4||card==5||card==6){
count++;
return count + "Bet";
} else if (card ==10||card=='J'||card=='Q'||card=='K'||card=='A'){
count--;
return count + "Hold";
} 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');
For better viewing
Thiago Cruz
@thy705
Jan 02 2017 02:07
I also tried replacing the if statements with swtich ones, but nothing.
Thanks Tony
first time asking for help, didn't really know how to post it.
Tony Ko
@htkoca
Jan 02 2017 02:08
yeah its okay use ``` next time around your code
HeebieGeeBee
@HeebieGeeBee
Jan 02 2017 02:09
@Landoghini are you here?
Tony Ko
@htkoca
Jan 02 2017 02:09
@thy705 it sohuld only return hold or bet when the count is above or below a certain value
if(count > 0){
return count + "hold";
}else{
return count + "bet";
}
so in total something like
function cc(card) {
  // Only change code below this line
  if (card == 2 || card == 3 || card==4||card==5||card==6){
    count++;
  } else if (card ==10||card=='J'||card=='Q'||card=='K'||card=='A'){
    count--;
  } else {
  }
  if(count > 0){
    return count + "hold";
  }else{
    return count + "bet";
  }
  // 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');
I'm not quite exactly sure what the criteria is, sorry if i aint helping lol
do you have the challenge link?
Joseph
@revisualize
Jan 02 2017 02:13
Bet is not the same as bet
Thiago Cruz
@thy705
Jan 02 2017 02:13
I think I get it now. I tried it like that, but it was hard to figure out what to do with the 7,8 or 9. The whole thing was confusing to me because of the similarities between the var names (cards and count). But I got it now. Many thanks!
Joseph
@revisualize
Jan 02 2017 02:13
Hold isn't the same as hold
Tony Ko
@htkoca
Jan 02 2017 02:14
True @revisualize
should be "Hold" and "Bet"
Thiago Cruz
@thy705
Jan 02 2017 02:14
Let me try it out.
Joseph
@revisualize
Jan 02 2017 02:15
Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.
The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
Tony Ko
@htkoca
Jan 02 2017 02:16
ex return count + " Bet";
Thiago Cruz
@thy705
Jan 02 2017 02:21

sorry guys, I'm back. Here is how my code looks like now:
"var count = 0;

function cc(card) {
// Only change code below this line

if (card == 2 || card == 3 || card==4||card==5||card==6){

count++;

} else if (card ==10||card=='J'||card=='Q'||card=='K'||card=='A'){

count--;

} if (count > 1){

return count + "Bet";

} else if (count < 1){
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');
"

´´´var count = 0;
function cc(card) {
// Only change code below this line
if (card == 2 || card == 3 || card==4||card==5||card==6){
count++;
} else if (card ==10||card=='J'||card=='Q'||card=='K'||card=='A'){
count--;
} if (count > 1){
return count + "Bet";
} else if (count < 1){
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');
´´´
Sorry, not sure how to make my code look good here. Do I put quotes or what around it?
Somia ♡
@somiajagadish
Jan 02 2017 02:23

You can run the same code multiple times by using a loop.

The most common type of JavaScript loop is called a "for loop" because it runs "for" a specific number of times.

For loops are declared with three optional expressions separated by semicolons:

for ([initialization]; [condition]; [final-expression])

The initialization statement is executed one time only before the loop starts. It is typically used to define and setup your loop variable.

The condition statement is evaluated at the beginning of every loop iteration and will continue as long as it evaluates to true. When condition is false at the start of the iteration, the loop will stop executing. This means if condition starts as false, your loop will never execute.

The final-expression is executed at the end of each loop iteration, prior to the next condition check and is usually used to increment or decrement your loop counter.

In the following example we initialize with i = 0 and iterate while our condition i < 5 is true. We'll increment i by 1 in each loop iteration with i++ as our final-expression.

var ourArray = [];
for (var i = 0; i < 5; i++) {
  ourArray.push(i);
}

ourArray will now contain [0,1,2,3,4].
Instructions

Use a for loop to work to push the values 1 through 5 onto myArray.

Help?
Thiago Cruz
@thy705
Jan 02 2017 02:26
var count = 0; function cc(card) { // Only change code below this line if (card == 2 || card == 3 || card==4||card==5||card==6){ count++; } else if (card ==10||card=='J'||card=='Q'||card=='K'||card=='A'){ count--; } if (count > 1){ return count + "Bet"; } else if (count < 1){ 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');
Tony Ko
@htkoca
Jan 02 2017 02:27
press the markdown button on the right side of the chat area
Somia ♡
@somiajagadish
Jan 02 2017 02:27

You can run the same code multiple times by using a loop.

The most common type of JavaScript loop is called a "for loop" because it runs "for" a specific number of times.

For loops are declared with three optional expressions separated by semicolons:

for ([initialization]; [condition]; [final-expression])

The initialization statement is executed one time only before the loop starts. It is typically used to define and setup your loop variable.

The condition statement is evaluated at the beginning of every loop iteration and will continue as long as it evaluates to true. When condition is false at the start of the iteration, the loop will stop executing. This means if condition starts as false, your loop will never execute.

The final-expression is executed at the end of each loop iteration, prior to the next condition check and is usually used to increment or decrement your loop counter.

In the following example we initialize with i = 0 and iterate while our condition i < 5 is true. We'll increment i by 1 in each loop iteration with i++ as our final-expression.

var ourArray = [];
for (var i = 0; i < 5; i++) {
  ourArray.push(i);
}

ourArray will now contain [0,1,2,3,4].
Instructions

Use a for loop to work to push the values 1 through 5 onto myArray.

Help????????/
Gant Allen
@I-Am-Booger
Jan 02 2017 02:28
''' '''
CamperBot
@camperbot
Jan 02 2017 02:28
:bulb: to format code use backticks! ``` more info
Tony Ko
@htkoca
Jan 02 2017 02:28
@somiajagadish You;re starting at var i = 0, do var i = 1
@thy705 camperbot is here to help lol
Somia ♡
@somiajagadish
Jan 02 2017 02:28
@htko89 ??
Andre Goh
@Andreweijie
Jan 02 2017 02:29
Hi guys, I'm doing the Profile lookup function and I don't know how to check whether a value corresponds with a certain property?
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"]
}
];
in this case what does contacts.firstName give you?
Somia ♡
@somiajagadish
Jan 02 2017 02:30
nvm
Tony Ko
@htkoca
Jan 02 2017 02:30
@somiajagadish your for loop, starts the loop from 0 (var i = 0) to 4 (i < 5)
to loop from 1-5 use var i =1 and i<6
zyj12345
@zyj12345
Jan 02 2017 02:30

var Car = function() {
// this is a private variable
var speed = 10;

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

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

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

var Bike = function() {

// 只能在这一行下面写代码
var gear;
this.setGear=function(num){
return gear==num;

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

};

var myCar = new Car();

var myBike = new Bike();
console.log(myBike.setGear(4));
myBike.getGear();

Tony Ko
@htkoca
Jan 02 2017 02:31
@thy705 you may be missing return count + " Hold"; (note the space in the quotes)
babajide odusola
@cesarecaravaggio
Jan 02 2017 02:31
guys can you help me with this please?
var myStr = I am a, \"double quoted" string inside "double quotes"\".");
Tony Ko
@htkoca
Jan 02 2017 02:32
@Andreweijie contacts.firstName won't give you anything because firstName is in an object in the array firstName
@Andreweijie to access it use contacts[index].firstname
@cesarecaravaggio a string definition needs to be quoted, IE var myStr = "a string here"
Ppstah
@Ppstah
Jan 02 2017 02:34
var Car = function(wheels, seats, engines) {
  //Change this constructor
  this.wheels = 4;
  this.seats = 5;
  this.engines = 1;
};

//Try it out here
var myCar = new Car(11, 1, 2);
I know, it is very simple, but I am not doing it right somehow
Could someone please direct me?
Tony Ko
@htkoca
Jan 02 2017 02:34
@cesarecaravaggio You're missing the outside quotes, and you need to backslash all quotes inside these outside ones
EX var myStr = " a string with \"double quotes\" here"
Thiago Cruz
@thy705
Jan 02 2017 02:35
@htko89 many thanks Tony! Finally got it!! This one was tough but fun! Thanks again!
CamperBot
@camperbot
Jan 02 2017 02:35
thy705 sends brownie points to @htko89 :sparkles: :thumbsup: :sparkles:
:cookie: 297 | @htko89 |http://www.freecodecamp.com/htko89
Tony Ko
@htkoca
Jan 02 2017 02:35
Np :)
Diego Mayer
@Chrono79
Jan 02 2017 02:35
@Ppstah you have to use the constructor params to set the properties values
this.wheels = 4; // use wheels instead of 4
Andre Goh
@Andreweijie
Jan 02 2017 02:36
any help guys?
@htko89 I see
Tony Ko
@htkoca
Jan 02 2017 02:36
@Andreweijie contacts.firstName won't give you anything because firstName is in an object in the array firstName
@Andreweijie to access it use contacts[index].firstname
Yes lol
note the [ and ] characters preceding and after the individual objects in {}
that means contacts is an array that contains these objects
stakeley1
@stakeley1
Jan 02 2017 02:37
Hello all
babajide odusola
@cesarecaravaggio
Jan 02 2017 02:37
@htko89 thank you
CamperBot
@camperbot
Jan 02 2017 02:37
cesarecaravaggio sends brownie points to @htko89 :sparkles: :thumbsup: :sparkles:
:cookie: 298 | @htko89 |http://www.freecodecamp.com/htko89
Andre Goh
@Andreweijie
Jan 02 2017 02:37
@htko89 so multiple objects in a variable are considered an array?
Tony Ko
@htkoca
Jan 02 2017 02:37
:)
Ppstah
@Ppstah
Jan 02 2017 02:37
@Chrono79 oh, thank you
CamperBot
@camperbot
Jan 02 2017 02:37
ppstah sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3013 | @chrono79 |http://www.freecodecamp.com/chrono79
Somia ♡
@somiajagadish
Jan 02 2017 02:38

// Setup
var myArray = [];

// Only change code below this line.
for(var i = 0; i<5; i++) {
myArray.push(i);
}

whats wronf with my code
*wrong
Diego Mayer
@Chrono79
Jan 02 2017 02:39
@somiajagadish what are the instructions?
Somia ♡
@somiajagadish
Jan 02 2017 02:39
@Chrono79 Use a for loop to work to push the values 1 through 5 onto myArray.
Tony Ko
@htkoca
Jan 02 2017 02:39
Well anything in these [] characters means its an array EX: var array = ["hello","world"] -> console.log(array[1]); would return "hello"
@Andreweijie
Diego Mayer
@Chrono79
Jan 02 2017 02:39
@somiajagadish that code pushes 0 to 4
Anthony Mitchell
@Drantho
Jan 02 2017 02:39

Im really close on this assignment Arguments Optional but for some reason my isNaN() is returning false when it should be true at line 14. Even if I swap my if and else statements it still comes out wrong```function addTogether(num1, num2) {

if(!isNaN(num1)){
if(arguments.length > 1){
if(isNaN(num1)){
return undefined;
}
else{
return num1+num2;
}
}
else{
return function(num2){
if(isNaN(num1) || isNaN(num2)){
return undefined;
}
else{
return num1+num2;
}

  };
}

}
}

addTogether(2)([3]);```

Somia ♡
@somiajagadish
Jan 02 2017 02:40
@Chrono79 how do i oush it from 1 to 5 then
Anthony Mitchell
@Drantho
Jan 02 2017 02:40
aaaand my code thing is weird
Somia ♡
@somiajagadish
Jan 02 2017 02:40
*oush
*push
omg i cant spell lol
Diego Mayer
@Chrono79
Jan 02 2017 02:40
changing the numbers in your for loop
Gant Allen
@I-Am-Booger
Jan 02 2017 02:40
Brain not working on Stand in Line.
Somia ♡
@somiajagadish
Jan 02 2017 02:40
@Chrono79 got it thanks
CamperBot
@camperbot
Jan 02 2017 02:40
somiajagadish sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3014 | @chrono79 |http://www.freecodecamp.com/chrono79
Tony Ko
@htkoca
Jan 02 2017 02:40
Beep boop brain in idle standby
Diego Mayer
@Chrono79
Jan 02 2017 02:41
review array manipulation challenges, you need to use 2 methods there @I-Am-Booger
Andre Goh
@Andreweijie
Jan 02 2017 02:41
@htko89 Then how do I test whether a value of firstName really exists?
Tony Ko
@htkoca
Jan 02 2017 02:41
do you have the challenge name / link so i can see?
Andre Goh
@Andreweijie
Jan 02 2017 02:42
it's called "Profile Lookup" under Basic Javascript
Anthony Mitchell
@Drantho
Jan 02 2017 02:42
@Andreweijie are you asking whether firstName has a value or whether an object has a firstName property?
Gant Allen
@I-Am-Booger
Jan 02 2017 02:43
Thanks Diego Mayer Let me go check that out. It's making my brain hurt
Diego Mayer
@Chrono79
Jan 02 2017 02:43
:+1:
Andre Goh
@Andreweijie
Jan 02 2017 02:43
@Drantho I'm asking if i give a random value, i want to test whether that value exists in a firstName property in the contacts variable
Gant Allen
@I-Am-Booger
Jan 02 2017 02:43
@Chrono79
Paul Vu
@shamwoox
Jan 02 2017 02:43
I"m stuck on the same problem as Andre
How do you check if the value of a firstName and property exists
Tony Ko
@htkoca
Jan 02 2017 02:45
@Andreweijie
for (i=0; i < contacts.len; i++){
  if( contacts[1]["firstName"] == firstName ){
    // something happens here
  }
}
Gant Allen
@I-Am-Booger
Jan 02 2017 02:45

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

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Tony Ko
@htkoca
Jan 02 2017 02:45
woops, spelling mistake :smile: this is the correct version
for (i=0; i < contacts.length; i++){
  if( contacts[i]["firstName"] == firstName ){
    // something happens here
  }
}
Andre Goh
@Andreweijie
Jan 02 2017 02:46
I see...I was thinking of that but I thought there must surely be a simpler way
Somia ♡
@somiajagadish
Jan 02 2017 02:46

// Setup
var myArray = [];

// Only change code below this line.
for(var i = 0; i < 10; i += 3){
myArray.push();
}

Help??
Gant Allen
@I-Am-Booger
Jan 02 2017 02:46
That's what I had
Somia ♡
@somiajagadish
Jan 02 2017 02:46
Instructions: Push the odd numbers from 1 through 9 to myArray using a for loop.
Andre Goh
@Andreweijie
Jan 02 2017 02:46
@htko89 thanks a lot
Tony Ko
@htkoca
Jan 02 2017 02:46
np
Im not sure I actually helped :P LOL
Andre Goh
@Andreweijie
Jan 02 2017 02:47
@htko89 haha you did, I didn't realise it was an array LOL
Paul Vu
@shamwoox
Jan 02 2017 02:47
@somiajagadish it should be (var i = 1; var < 10; i += 2)
Tony Ko
@htkoca
Jan 02 2017 02:48
:)
Somia ♡
@somiajagadish
Jan 02 2017 02:48
@shamwoox no they whant to count by odd numbers
zyj12345
@zyj12345
Jan 02 2017 02:48

var oldArray = [1,2,3,4,5];

// 只能在这一行下面写代码
oldArray.map(function(val){
return val+3;
});
var newArray = oldArray;

Andre Goh
@Andreweijie
Jan 02 2017 02:48
@somiajagadish you need to increment by 2
and i = 1 not 0
Margaret
@Margaret2
Jan 02 2017 02:49
@somiajagadish 1+2 = 3, 3+ 2 = 5, etc.
Somia ♡
@somiajagadish
Jan 02 2017 02:49

@Andreweijie // Setup
var myArray = [];

// Only change code below this line.
for(var i = 1; i < 10; i += 2){
myArray.push();
}

It says its wrong....
babajide odusola
@cesarecaravaggio
Jan 02 2017 02:49
var myStr =" FirstLine \n
SecondLine \r
ThirdLine ";
i'm supposed to have this FirstLine newline backslashSecondLinebackslashcarriage-return ThirdLine
Tony Ko
@htkoca
Jan 02 2017 02:49
@zyj12345
var oldArray = [1,2,3,4,5];

// 只能在这一行下面写代码
var newArray = oldArray.map(function(val){
          return val+3;
             });
Andre Goh
@Andreweijie
Jan 02 2017 02:49
haha
you forgot
Margaret
@Margaret2
Jan 02 2017 02:49
@somiajagadish also, you need to push something... there is nothing inside your () to push right now
Andre Goh
@Andreweijie
Jan 02 2017 02:49
the i
Paul Vu
@shamwoox
Jan 02 2017 02:49
@somiajagadish myArray.push(i);
Andre Goh
@Andreweijie
Jan 02 2017 02:49
@Margaret2 @so'
Somia ♡
@somiajagadish
Jan 02 2017 02:50
@Margaret2 OHH THANKS HAHA
Andre Goh
@Andreweijie
Jan 02 2017 02:50
@Margaret2 @somiajagadish yup
CamperBot
@camperbot
Jan 02 2017 02:50
somiajagadish sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:cookie: 950 | @margaret2 |http://www.freecodecamp.com/margaret2
Paul Vu
@shamwoox
Jan 02 2017 02:50
@somiajagadish You need to insert the i inside your paranthesis
Anthony Mitchell
@Drantho
Jan 02 2017 02:51
has anyone done Arguments Optional? Im close but have one last little confusing bit
zyj12345
@zyj12345
Jan 02 2017 02:52
@htko89 tanks
Diego Mayer
@Chrono79
Jan 02 2017 02:52
@I-Am-Booger you have to use 2 methods: push is one of them, but check again how it's used
Don't use testArr inside your function, you only need to use the function params: arr and item
Tony Ko
@htkoca
Jan 02 2017 02:53
np :)
anyone done Smallest Common Multiple?
Anthony Mitchell
@Drantho
Jan 02 2017 02:54
@htko89 yeah just did it yesterday
Tony Ko
@htkoca
Jan 02 2017 02:55
I'm stumped waht does it means by " evenly divided by both, as well as by all sequential numbers in the range between these parameters "
so smallestCommons([1,5]);would have to find a "smallest common multiple" that can be evenly divided by 1,2,3,4and 5?
Anthony Mitchell
@Drantho
Jan 02 2017 02:56
so if you are given 1,3 you need the smallest number that 1,2and3 all evenly divide
Tony Ko
@htkoca
Jan 02 2017 02:56
oh damn lol
Anthony Mitchell
@Drantho
Jan 02 2017 02:57
yeah it was a pain
llamatarianism
@llamatarianism
Jan 02 2017 02:57
it's not that complicated
finding the highest common factor of 2 numbers is pretty simple
if you can find the HCF of 2 numbers, you can find the LCM of 2 numbers pretty easily
and if you can find the LCM of 2 numbers, you can find the LCM of any number of numbers
Tony Ko
@htkoca
Jan 02 2017 02:57
its multiples not factors :p
oh true
llamatarianism
@llamatarianism
Jan 02 2017 02:58
lcm(a,b)=abgcd(a,b)lcm(a, b) = \frac{ab}{gcd(a, b)}
Margaret
@Margaret2
Jan 02 2017 02:58
oooh LaTeX
Tony Ko
@htkoca
Jan 02 2017 02:58
whoa
Anthony Mitchell
@Drantho
Jan 02 2017 02:59
@llamatarianism I thought that method got kinda sticky when you did more than 2 numbers
llamatarianism
@llamatarianism
Jan 02 2017 02:59
lcm(a,b,c)=lcm(lcm(a,b),c)lcm(a, b, c) = lcm(lcm(a, b), c)
Anthony Mitchell
@Drantho
Jan 02 2017 03:00
i compared prime factors for mine
Andre Goh
@Andreweijie
Jan 02 2017 03:00
@htko89 damn it didn't work
Tony Ko
@htkoca
Jan 02 2017 03:00
tbh I'm still trying to wrap my head around it, not saying you're not helping !
@llamatarianism
whats up @Andreweijie
Andre Goh
@Andreweijie
Jan 02 2017 03:01
@htko89 tried nesting the if statements in the for loop but doesn't work
Anthony Mitchell
@Drantho
Jan 02 2017 03:01
anyone know why isNaN() could be returning false negatives?
Tony Ko
@htkoca
Jan 02 2017 03:02
Post your code ?
llamatarianism
@llamatarianism
Jan 02 2017 03:03
lcm(3,4,5)=lcm(lcm(3,4),5)=lcm(12,5)=60lcm(3, 4, 5) = lcm(lcm(3, 4), 5) = lcm(12, 5) = 60
Anthony Mitchell
@Drantho
Jan 02 2017 03:04

```function addTogether() {
var num1 = arguments[0];
if(!isNaN(num1)){
if(arguments.length > 1){
var num2 = arguments[1];
if(isNaN(num1)){
return undefined;
}
else{
return num1+num2;
}
}
else{

  return function(num2){
    if(isNaN(num1) || isNaN(num2)){

       return undefined;
    }
    else{

      return num1+num2;
    }

  };
}

}
}

addTogether(2)(3);```

i also dont know why my code is posting funny
Ashish verma
@ashish1500616
Jan 02 2017 03:04

The isNaN() function determines whether a value is an illegal number (Not-a-Number).

This function returns true if the value equates to NaN. Otherwise it returns false.

This function is different from the Number specific Number.isNaN() method.

The global isNaN() function, converts the tested value to a Number, then tests it.

Number.isNaN() does not convert the values to a Number, and will not return true for any value that is not of the type Number.

Tony Ko
@htkoca
Jan 02 2017 03:04
``` needs to be on its own line
Ashish verma
@ashish1500616
Jan 02 2017 03:05
Tony Ko
@htkoca
Jan 02 2017 03:06
@llamatarianism so I suppose I need to solve for gcd(a,b)(greatest common factor?) and then use it to divide like a*b / gcd (a,b) ?
llamatarianism
@llamatarianism
Jan 02 2017 03:07
si
Anthony Mitchell
@Drantho
Jan 02 2017 03:08
oh well the relevant part came out in code so in my above example (2)("3") is returning 23...
Ming Lei
@dabeister
Jan 02 2017 03:08
Hi all, just a question on the filter() method and its requirement for a callback function to be used, why is this is the case for some functions, why can't I shove in a test within the filter method instead of first creating a callback function to then be called upon by the filter method?
Paul Vu
@shamwoox
Jan 02 2017 03:08
I'm still stuck on the Profile Lookup exercise
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < 4; i++) {
if(contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
} else if (contacts[i].firstName !== firstName) {
return "No such contact";
} else if (contacts[i].hasOwnProperty !== true) {
return "No such property";
}
}
}
Anthony Mitchell
@Drantho
Jan 02 2017 03:08
it catches (2)([3]) but not (2)("3")
Paul Vu
@shamwoox
Jan 02 2017 03:09
What's wrong with my code?
Margaret
@Margaret2
Jan 02 2017 03:09
@dabeister you can do
.filter( function(){ do something... });
if that's what you're asking
@dabeister but if it's a long function, it makes the code clearer to write it out separately
Ming Lei
@dabeister
Jan 02 2017 03:10
@Margaret2 ah ok, so it's more best practice than pure necessity?
ok awesome, that makes a lot more sense, I must've just messed up the syntax when i was trying to amalgamate everything
Margaret
@Margaret2
Jan 02 2017 03:10
@dabeister it just depends on how long the function is, if it's a really short function, it's fine to just put it right in
Ming Lei
@dabeister
Jan 02 2017 03:11
thanks @Margaret2
CamperBot
@camperbot
Jan 02 2017 03:11
dabeister sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:cookie: 951 | @margaret2 |http://www.freecodecamp.com/margaret2
Anthony Mitchell
@Drantho
Jan 02 2017 03:12
@bitian1506 thanks for the link but there is something deeper going on
CamperBot
@camperbot
Jan 02 2017 03:12
drantho sends brownie points to @bitian1506 :sparkles: :thumbsup: :sparkles:
:cookie: 285 | @bitian1506 |http://www.freecodecamp.com/bitian1506
Tony Ko
@htkoca
Jan 02 2017 03:12
@shamwoox
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";
      }
    }
}
I haven't tested this
Gant Allen
@I-Am-Booger
Jan 02 2017 03:12
So I looked up the solution but I don't understand everything that is part of it. ```
Tony Ko
@htkoca
Jan 02 2017 03:13

Here it is much cleaner

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

@shamwoox @Andreweijie

Margaret
@Margaret2
Jan 02 2017 03:14
@Drantho when you try to add a number and a string, it will convert the whole thing to a string, so 2 + 3 = 5 but 2 + "3" = "23"
Ashish verma
@ashish1500616
Jan 02 2017 03:15
@Drantho name of the challenge??
Anthony Mitchell
@Drantho
Jan 02 2017 03:16
@Margaret2 I understand that but somehow "3" is getting past
if(isNaN(num1) || isNaN(num2)){

           return undefined;
        }
        else{

          return num1+num2;
        }
@bitian1506 Arguments Optional
<
i think i have my or messed up...
Andre Goh
@Andreweijie
Jan 02 2017 03:17
@htko89 its not returning the value
Tony Ko
@htkoca
Jan 02 2017 03:17
yeah I just tested it , I'm looking to see what I did wrong lol
llamatarianism
@llamatarianism
Jan 02 2017 03:19
@Drantho isNaN is stupid
Ashish verma
@ashish1500616
Jan 02 2017 03:19
@Drantho give a try to typeOf
llamatarianism
@llamatarianism
Jan 02 2017 03:19
isNaN doesn't check if something is NaN
it converts it to a number, then checks if it's NaN
+"3" is 3, not NaN
Andre Goh
@Andreweijie
Jan 02 2017 03:20
@htko89 I think I know the problem
llamatarianism
@llamatarianism
Jan 02 2017 03:20
if you want to check if x is literally NaN, do this: if (x !== x)
Tony Ko
@htkoca
Jan 02 2017 03:20
We are returning the result before it can loop
Andre Goh
@Andreweijie
Jan 02 2017 03:20
if on the first check the name doesnt correspond
Tony Ko
@htkoca
Jan 02 2017 03:20
yes
llamatarianism
@llamatarianism
Jan 02 2017 03:20
NaN !== NaN is true. NaN is the only thing for which this is true.
Andre Goh
@Andreweijie
Jan 02 2017 03:21
it returns and goes out
yeap
llamatarianism
@llamatarianism
Jan 02 2017 03:21
if you want to check if x isn't a number, do this: if (typeof x !== "number")
Dylan Carlone
@dylancarlone
Jan 02 2017 03:24
Is it ok to use abstract classes in JS?
Anthony Mitchell
@Drantho
Jan 02 2017 03:24
@llamatarianism thanks for the tip. typeof fixed that bug now just need to track down the next bug... lol
CamperBot
@camperbot
Jan 02 2017 03:24
drantho sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1442 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Ppstah
@Ppstah
Jan 02 2017 03:25
var Car = function() {
  // this is a private variable
  var speed = 10;

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

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

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

var Bike = function() {

  // Only change code below this line.
  var gear = 0;
  this.setGear = function(set) {
    gear += set;
  };
  this.getGear = function() {
    return gear;
  };

};

var myCar = new Car();

var myBike = new Bike();
It works perfectly fine when i test it manually
but it doesnt allow me to move forward for some reasor
reason*
Andre Goh
@Andreweijie
Jan 02 2017 03:26
@htko89 I got it to work
Tony Ko
@htkoca
Jan 02 2017 03:26
Lol woot
I revised my own challenge so thats good too haha
Andre Goh
@Andreweijie
Jan 02 2017 03:27
@htko89 but it's cheap. I just created a variable noContact outside of the for loop
Tony Ko
@htkoca
Jan 02 2017 03:27
:D
Andre Goh
@Andreweijie
Jan 02 2017 03:27
then instead of returning "No such contact" I assign it to the variable
Sujeevan
@sujeevan81
Jan 02 2017 03:27

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

switch (val){
case 1:
case 2:
case 3:
case "1,2, or 3": answer = "Low";
break;
case 4:
case 5:
case 6:
case "4, 5, or 6": answer = "Mid";
break;
case 7:
case 8:
case 9:
case "7,8, or 9" : answer = "High";
break;

}

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

// Change this value to test
sequentialSizes(9);

Tony Ko
@htkoca
Jan 02 2017 03:27
sometimes its better if its simplier :p
Andre Goh
@Andreweijie
Jan 02 2017 03:27
then outside of the forloop I return the variable
Sujeevan
@sujeevan81
Jan 02 2017 03:28
I'm getting an error "should have 9 case statemets
Andre Goh
@Andreweijie
Jan 02 2017 03:28
var nocont = ""
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 {
nocont = "No such contact";
}
}
return nocont;
Tony Ko
@htkoca
Jan 02 2017 03:28
There should be a high five emoji haha
Andre Goh
@Andreweijie
Jan 02 2017 03:28
don't think it was meant to be solved like this tho -_-
Sujeevan
@sujeevan81
Jan 02 2017 03:28
Guys Pls help !
Tony Ko
@htkoca
Jan 02 2017 03:29
Im sure theres another way to iterate with .map or something but thats got its own set of problems
Andre Goh
@Andreweijie
Jan 02 2017 03:30
but judging from the content that was taught, we should be able to solve with just the things we've learnt
and idk what .map is haha
Ppstah
@Ppstah
Jan 02 2017 03:30
var Car = function() {
  // this is a private variable
  var speed = 10;

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

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

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

var Bike = function() {

  // Only change code below this line.
  var gear = 0;
  this.setGear = function(set) {
    gear += set;
  };
  this.getGear = function() {
    return gear;
  };

};

var myCar = new Car();

var myBike = new Bike();
Could somebody help me with that one, please?
Tony Ko
@htkoca
Jan 02 2017 03:31
lol its another way to loop thru an array or object (mostly used with objects though)
Ppstah
@Ppstah
Jan 02 2017 03:31
It seems to work when I try to test it, but it is not letting me to move forward
Andre Goh
@Andreweijie
Jan 02 2017 03:31
@htko89 btw how do you post code here? instead of copy/paste
Coy Sanders
@coymeetsworld
Jan 02 2017 03:31
@Ppstah you need to check your Bike.setGear function, that part isn't right
Tony Ko
@htkoca
Jan 02 2017 03:31
i did this:
function lookUpProfile(firstName, prop) {
    // Only change code below this line
    var nameExists = true;
    var propExists = true;
    for ( var i = 0; i < contacts.length; i++ ) {
      if ( contacts[i]["firstName"] == firstName ) {
        if ( contacts[i].hasOwnProperty(prop) ) {
          return contacts[i][prop];
        } else {
          console.log("no prop: "+firstName);
          console.log(prop);
          propExists = false;
        }
      } else {
        console.log("no name: "+firstName);
        nameExists = false;
      }
    }
    if( !propExists ){
      return "No such property";
    } else if ( !nameExists ) {
      return "No such contact";
    }
}
oh
uhh
well i just copy and past actually
Ppstah
@Ppstah
Jan 02 2017 03:32
@coymeetsworld thank you
CamperBot
@camperbot
Jan 02 2017 03:32
ppstah sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1712 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Tony Ko
@htkoca
Jan 02 2017 03:32
but i use this markdown code blocks to surround my code
''' '''
CamperBot
@camperbot
Jan 02 2017 03:32
:bulb: to format code use backticks! ``` more info
Coy Sanders
@coymeetsworld
Jan 02 2017 03:32
@Andreweijie I think the issue is with your nocont variable, why use it?
Anthony Mitchell
@Drantho
Jan 02 2017 03:33
Does a blank output box === undefined?
Coy Sanders
@coymeetsworld
Jan 02 2017 03:33
and that's not how you determine if the contact is not in t he contacts array
Andre Goh
@Andreweijie
Jan 02 2017 03:33
@htko89 actually if you see mine you don't need 2 variables because its either returning the value or "no such property"
Tony Ko
@htkoca
Jan 02 2017 03:33
They may be nested @coymeetsworld
Coy Sanders
@coymeetsworld
Jan 02 2017 03:33
hard to tell i guess without it being formatted
Ppstah
@Ppstah
Jan 02 2017 03:34
@coymeetsworld hmmm. It works when I call it
Coy Sanders
@coymeetsworld
Jan 02 2017 03:34
yeah you shouldn't need any variables for that challenge
Tony Ko
@htkoca
Jan 02 2017 03:34
@Andreweijie true you are just returning the value after the loop
Ppstah
@Ppstah
Jan 02 2017 03:34
It returns me the right value
Coy Sanders
@coymeetsworld
Jan 02 2017 03:34
@Ppstah if you call it once yeah
but if you call it a second time its wrong
Andre Goh
@Andreweijie
Jan 02 2017 03:34
@coymeetsworld Care to enlighten me? I don't think it should be this much work as well
Coy Sanders
@coymeetsworld
Jan 02 2017 03:34
check the instructions again, setGear for Bike and accelerating for a car are different
Ppstah
@Ppstah
Jan 02 2017 03:35
@coymeetsworld ok
tech-tron
@tech-tron
Jan 02 2017 03:35
i have an array of a couple of strings and i need to access the first letter of those strings to make toUpperCase but im not familure witha dot function to get them. i seem to remember something of char At or something?? idk, HAAALP
Tony Ko
@htkoca
Jan 02 2017 03:35
@coymeetsworld we had a problem where it would return "no such contact" on the first loop of the for loop, so we had to find a way to return after
Coy Sanders
@coymeetsworld
Jan 02 2017 03:35
just remove nocont, when you determine there's no such contact, just return that. Just like you did no such property
Andre Goh
@Andreweijie
Jan 02 2017 03:35
if i remove the code doesn't work
Coy Sanders
@coymeetsworld
Jan 02 2017 03:35
Sorry i'm going to format it just so i can see what's going on
var nocont = ""
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 {
          nocont = "No such contact";
      }
    }
return nocont;
oh ok
Andre Goh
@Andreweijie
Jan 02 2017 03:36
this code works
Coy Sanders
@coymeetsworld
Jan 02 2017 03:36
no that's not right
Andre Goh
@Andreweijie
Jan 02 2017 03:36
but I just don't think its so much work
what do you think it should be?
Coy Sanders
@coymeetsworld
Jan 02 2017 03:36
basically, if the first contact isn't what you're looking for its saying there is no such contact
Greg Duncan
@GregatGit
Jan 02 2017 03:36
@Andreweijie lose the the last else condition and at the very end instead of return nocont have return "No such contact"
Coy Sanders
@coymeetsworld
Jan 02 2017 03:36
what if the contact you're looking for is the 2nd item in the contacts array? or 3rd?
Tony Ko
@htkoca
Jan 02 2017 03:36
Im gonna tag the other guy in case hes still stuck lol @shamwoox
Coy Sanders
@coymeetsworld
Jan 02 2017 03:36
you need to go through all contacts first
Andre Goh
@Andreweijie
Jan 02 2017 03:37
ya thats why i made the variable
Coy Sanders
@coymeetsworld
Jan 02 2017 03:37
then if you don't find one with that name, then you can determine the contacts don't exist
Andre Goh
@Andreweijie
Jan 02 2017 03:37
so the loop wouldn't cut
Tony Ko
@htkoca
Jan 02 2017 03:37
I think the return for nocont is after the loop
Coy Sanders
@coymeetsworld
Jan 02 2017 03:37
you don't need that
Andre Goh
@Andreweijie
Jan 02 2017 03:37
i don't understand how to do that?
Ppstah
@Ppstah
Jan 02 2017 03:37
@coymeetsworld I got it. Thank you. It was so simple, that I am ashamed of myself.
CamperBot
@camperbot
Jan 02 2017 03:37
ppstah sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: ppstah already gave coymeetsworld points
Coy Sanders
@coymeetsworld
Jan 02 2017 03:37
remove the variable and that else statement
if you iterate through the entire array, and dont return something
that means the contact isn't there
you don't need a variable to track that
so just return No Such Contact after your for loop, the only way that would get returned is if the contact doesn't exist
Tony Ko
@htkoca
Jan 02 2017 03:38
whoa

what i think @coymeetsworld he means is

var nocont = ""
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";

An I right?

Coy Sanders
@coymeetsworld
Jan 02 2017 03:39
yeah that looks right, minus the variable up top you don't need
Tony Ko
@htkoca
Jan 02 2017 03:39
it didnt format the code for a sec, weird error
true
Coy Sanders
@coymeetsworld
Jan 02 2017 03:39
if that doesn't work i'd need to take a look at the challenge, been a while since i did that one
Tony Ko
@htkoca
Jan 02 2017 03:39
it works :)
I did mine a few months ago and it was bloooooaated, so nice to see how far one's come in code
Coy Sanders
@coymeetsworld
Jan 02 2017 03:40
:thumbsup:
Andre Goh
@Andreweijie
Jan 02 2017 03:40
um it doesn't work????
oh
wait
Tony Ko
@htkoca
Jan 02 2017 03:40
@Andreweijie
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";
}
Coy Sanders
@coymeetsworld
Jan 02 2017 03:41
@htko89 also in the future it would be better not to give out the code when helping someone else out
Tony Ko
@htkoca
Jan 02 2017 03:41
true
Andre Goh
@Andreweijie
Jan 02 2017 03:41
ah yes I see
Coy Sanders
@coymeetsworld
Jan 02 2017 03:41
unless they have also completed the challenge and you want to compare things
like how to make it better
Tony Ko
@htkoca
Jan 02 2017 03:41
We're both kinda going at it haha but yes you make a good point
Andre Goh
@Andreweijie
Jan 02 2017 03:41
Yeah I did complete it just now no worries
Coy Sanders
@coymeetsworld
Jan 02 2017 03:41
you mightve needed to refresh the browser @Andreweijie
sometimes if you work on a challenge enough you need to refresh it I'm not exactly sure why
Anthony Mitchell
@Drantho
Jan 02 2017 03:42

I'd really appreciate some help with this code

function addTogether() {
  var num1 = arguments[0];
  if(typeof num1 === 'number'){
    if(arguments.length > 1){
      var num2 = arguments[1];
      if(isNaN(num1)){
        return undefined;
      }
      else{
        return num1+num2;
      }
    }
    else{

      return function(num2){
        if(typeof num2 === 'number'){
          return num1+num2;

        }
        else{

          return undefined;

        }

      };

    }

  }

}

addTogether(2, "3");

the output for this is 23

Coy Sanders
@coymeetsworld
Jan 02 2017 03:42
probably has some variables cached up with values messing up the tests
challenge name @Drantho ?
Anthony Mitchell
@Drantho
Jan 02 2017 03:43
Arguments Optional it should be catching "3" and returning undefined
Coy Sanders
@coymeetsworld
Jan 02 2017 03:44
you shouldn't use isNaN @Drantho
isNaN("3") will coerce the value to the number 3
which is a number
Palmer Joseph
@palmerjoseph
Jan 02 2017 03:45

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

return item; // Change this line
}

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

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

can anyone explain this exercise to me?
i have no clue what it is asking...
Coy Sanders
@coymeetsworld
Jan 02 2017 03:45
@palmerjoseph the nextInLine function takes in an array and a number
Palmer Joseph
@palmerjoseph
Jan 02 2017 03:46
@coymeetsworld I don't really understand how to solve this...
Coy Sanders
@coymeetsworld
Jan 02 2017 03:46
you need to modify the array so that the number is added to it to the end, and the first number in the array is pulled off and returned from the function
you need to use the Array functions you learned in previous exercises
Anthony Mitchell
@Drantho
Jan 02 2017 03:46
@coymeetsworld i switched isNaN to typeof but missed that one. typeof is still failing at the end
Palmer Joseph
@palmerjoseph
Jan 02 2017 03:46
so i have to use the push and shift?
Coy Sanders
@coymeetsworld
Jan 02 2017 03:47
basically when you have [1,2,3,4,5] as your array and 6 as your item and you run it through nextInLine, the array should now be [2,3,4,5,6] and the function should return 1
if you ran it again and put 7 in, the array would be [3,4,5,6,7] and it would return 2
so its basically acting as a queue
yeah
Palmer Joseph
@palmerjoseph
Jan 02 2017 03:47
hmmm ok umm lemme try to figure this out... thanks for the advice @coymeetsworld
CamperBot
@camperbot
Jan 02 2017 03:47
palmerjoseph sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1713 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jan 02 2017 03:47
np
@Drantho what does the code look like now?
Palmer Joseph
@palmerjoseph
Jan 02 2017 03:50
@coymeetsworld hey what does the JSON.stringify mean?
is it something i should be aware of?
i think thats what is throwing me off right now..
babajide odusola
@cesarecaravaggio
Jan 02 2017 03:50

i'm struggling with escaping sequences.
var myStr ="FirstLine \n
SecondLine \r
ThirdLine ";

What am i doing wrong?/

Coy Sanders
@coymeetsworld
Jan 02 2017 03:51
@palmerjoseph no you don't need to worry about that, it's just to format an array into a string to print out to the console
Palmer Joseph
@palmerjoseph
Jan 02 2017 03:51
@cesarecaravaggio yeah i got stuck with that one too... try reading it again carefully but DO NOT use spaces
@coymeetsworld OK cool thx
CamperBot
@camperbot
Jan 02 2017 03:51
palmerjoseph sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: palmerjoseph already gave coymeetsworld points
Coy Sanders
@coymeetsworld
Jan 02 2017 03:51
np
@cesarecaravaggio the String should be on one line, and you should remove the spaces inside of it
Prahalad Belavadi
@prahaladbelavadi
Jan 02 2017 04:03
I'm kinda stuck
Sujeevan
@sujeevan81
Jan 02 2017 04:03

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

switch (val){
case 1:
case 2:
case 3:
case "1,2, or 3": answer = "Low";
break;
case 4:
case 5:
case 6:
case "4, 5, or 6": answer = "Mid";
break;
case 7:
case 8:
case 9:
case "7,8, or 9" : answer = "High";
break;

}

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

// Change this value to test
sequentialSizes(9);

Guys ! Can anyone help? The error is " You should have 9 case statements"
Ken Haduch
@khaduch
Jan 02 2017 04:04
@sujeevan81 - you have some incorrect statements, the case "1,2, or 3" format that you have is not correct. Those lines should just be assigning the value to answer - remove those, and you will eliminate three case statements. And probably have the remainder of the code correct.
CamperBot
@camperbot
Jan 02 2017 04:07
:bulb: to format code use backticks! ``` more info
Ryan Steen
@Rsteen76
Jan 02 2017 04:08
function lookUpProfile(firstName, prop){
// Only change code below this line
  var i = 0;
  while(i < contacts.length || contacts[i].firstName !== firstName)
    {
      i++;
    }
  if (contacts[i].firstName == firstName) 
    {
      for( var j = 0; j<3; j++) 
        {
          if(contacts.getOwnPropertyDescriptor(i, prop))
            {
              return contacts.getOwnPropertyDescriptor(i, prop);
            }
          else 
            {
              return "No such property";
            }
        }
     }
  else 
    {
      return "No such contact";
    }
}
Can someone give me some input on this one. I keep getting the error that firstName is undefined.
Sujeevan
@sujeevan81
Jan 02 2017 04:10
@khaduch Evern this is not working

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

switch (val){

  case "1,2, or 3": answer =  "Low";
  break;


  case "4, 5, or 6": answer = "Mid";
  break;


  case "7,8, or 9" : answer = "High";
  break;

}

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

// Change this value to test
sequentialSizes(9);

Ken Haduch
@khaduch
Jan 02 2017 04:16
@sujeevan81 - you should have removed those lines, at least the case "1,2, or 3": part, and kept the single case 1:, case 2:, etc. for each range. After each group of three case statements, you should assign the appropriate value to answer, as you are doing, it should just be on a line all by itself, followed by the break
Sujeevan
@sujeevan81
Jan 02 2017 04:18
can u give me one example?
llamatarianism
@llamatarianism
Jan 02 2017 04:20
@sujeevan81 case "1,2, or 3": doesn't match 1, 2, or 3
it matches this string: "1,2 or 3"
if you want a case that matches 1, 2 or 3, do this:
case 1:
case 2:
case 3:
  answer = "Low";
  break;
Ken Haduch
@khaduch
Jan 02 2017 04:21

@sujeevan81 - like this:

switch (val){
case 1:
case 2:
case 3:
     answer = "Low";
break;

The "1, 2, or 3" is not a valid operation - if you had a string that matches that string, it would select that, but it is not what this exercise is asking you for.

Sujeevan
@sujeevan81
Jan 02 2017 04:22
@llamatarianism Thanks dude I got it!
CamperBot
@camperbot
Jan 02 2017 04:22
:star2: 1444 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
sujeevan81 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
Sujeevan
@sujeevan81
Jan 02 2017 04:23
@khaduch Thanks a lot!
CamperBot
@camperbot
Jan 02 2017 04:23
sujeevan81 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2196 | @khaduch |http://www.freecodecamp.com/khaduch
babajide odusola
@cesarecaravaggio
Jan 02 2017 04:23

@coyohti @palmerjoseph

var myStr='FirstLine\n\SecondLine\rThirdLine';

I can't get this to run. What's wrong with it now?

Ken Haduch
@khaduch
Jan 02 2017 04:29
@cesarecaravaggio = make sure that you exactly match the sequence of escape sequences - there should be some \\ in there (although unless you post the code using the markdown syntax, it will not show up correctly in the chatroom.) You can read about the code posting method here: https://github.com/freecodecamp/freecodecamp/wiki/code-formatting
yongjaeya
@yongjaeya
Jan 02 2017 04:29
how would you assign a number to a variable using (function)
Mark Colombus
@bouncingnrg
Jan 02 2017 04:29
hi all, i'm defiantly struggling with Java when compared to html & css. I can follow the instructions all fine, but when it comes to writing arguments this is where i fall down - any suggestions? prob worth resetting all challenges and going through it again?
yongjaeya
@yongjaeya
Jan 02 2017 04:31
for example fun 1 () {}
Mark Colombus
@bouncingnrg
Jan 02 2017 04:32
Also after the Golf challenge things really seem to step up and there are alot of things that are asked of us that haven't been mention in the previous
yongjaeya
@yongjaeya
Jan 02 2017 04:32
fun1*
without using var
Ken Haduch
@khaduch
Jan 02 2017 04:32
@bouncingnrg - there is some helpful information (I think) about functions and how they work on this link: https://cs.wellesley.edu/~cs110/lectures/L16/images/function-anatomy.png if that is what you are struggling with.
@bouncingnrg - well, things tend to build on things that have been taught (or at least "gone over") - sometimes they take bigger leaps. If you're stuck on a particular challenge, you can post your code and ask questions and see if you can get through it with a little bit of directed help.
yongjaeya
@yongjaeya
Jan 02 2017 04:35
could someone help me with global scope functions (Inside function fun1, assign 5 to oopsGlobal without using the var keyword.)
and var myGlobal = 10
babajide odusola
@cesarecaravaggio
Jan 02 2017 04:37
oh @khaduch
var myStr='FirstLine\n\SecondLine\\rThirdLine';
@khaduch thx for that info actually i was thinking about how to post codes earlier haha. It was a Nice little read.
CamperBot
@camperbot
Jan 02 2017 04:38
cesarecaravaggio sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2197 | @khaduch |http://www.freecodecamp.com/khaduch
Sahil Sunny
@sahilsunny
Jan 02 2017 04:39
Why split function converts my location data to integer?
$(document).ready(function() {
  $.getJSON("http://ipinfo.io/json", function(result) {
    var location = result.loc;
    location.split(",");
    var latitude = location[0];
    var longitude = location[1];
    $("body").html(latitude+","+longitude);
  });
});
babajide odusola
@cesarecaravaggio
Jan 02 2017 04:40
@khaduch are you saying the code needs backlashes before the first quotation mark and then before the last one?
Sujeevan
@sujeevan81
Jan 02 2017 04:41
Guys, help! Hw can I do:
1.nextInLine([5,6,7,8,9], 1) should return 5
2.After nextInLine(testArr, 10), testArr[4] should be 10

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

return arr.push(1); // Change this line

}

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

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

Ken Haduch
@khaduch
Jan 02 2017 04:41
@cesarecaravaggio - no, there should be backslashes (two of them, like this: \\) in the places within the string where the word "backslash" it shown in the explanation of the lesson.
@cesarecaravaggio - the words that are highlighted in red in the sentence should be translated to the codes that match those words within the table of escape sequences. And there should be no spaces at all in the string after you are done - they are just there in the original string for clarity, to keep the words separate. L ooks like you are almost there.
Mark Colombus
@bouncingnrg
Jan 02 2017 04:43
@khaduch thanks, all of a sudden i seem to be very very lost, i think i'm best to go back over a few of the lessons.
CamperBot
@camperbot
Jan 02 2017 04:43
bouncingnrg sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2198 | @khaduch |http://www.freecodecamp.com/khaduch
babajide odusola
@cesarecaravaggio
Jan 02 2017 04:45
@khaduch
'var myStr='FirstLine\n\SecondLine\\rThirdLine';'
got it thanks
CamperBot
@camperbot
Jan 02 2017 04:45
cesarecaravaggio sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: cesarecaravaggio already gave khaduch points
khaduch @khaduch - going offline for the night... have fun coding everyone!
Sahil Sunny
@sahilsunny
Jan 02 2017 04:46
Why split function converts my location data to integer?
$(document).ready(function() {
  $.getJSON("http://ipinfo.io/json", function(result) {
    var location = result.loc;
    location.split(",");
    var latitude = location[0];
    var longitude = location[1];
    $("body").html(latitude+","+longitude);
  });
});
Christopher Bennett
@drbilo
Jan 02 2017 04:47

Hello all,

Attempting the Random Quote Generator on CodePen. Trying the following API call but getting no luck. Any ideas? Thank you so much

$(document).ready(function() {
  $("#getQuote").on("click", function() {
    $.getJSON("http://api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=json&lang=en", function(json) {
      $(".quote").html(JSON.stringify(json));
    });
  });
});
Conor Heena
@heenslice
Jan 02 2017 04:48

Hi everyone. Can anyone help me with the 'Profile Lookup' challenge. The function keeps returning "No such contact and I'm not sure why"

'''
//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

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

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

// Only change code above this line
}
}
// Change these values to test your function
lookUpProfile("Harry", "lastname");

'''

Ian
@toianw
Jan 02 2017 04:49
@sahilsunny maybe you meant location = location.split(","); split will return the array.
hcmlopes
@hcmlopes
Jan 02 2017 04:51
A
Ratheesh K
@stepprogg
Jan 02 2017 04:51
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\". "; // Change this line
hcmlopes
@hcmlopes
Jan 02 2017 04:52
@heenslice you are passing "lastname" and not "lastName" the N must be capital is it is to === the value
yongjaeya
@yongjaeya
Jan 02 2017 04:52
@yongjaeya
could someone help me with global scope functions (Inside function fun1, assign 5 to oopsGlobal without using the var keyword.)
and var myGlobal = 10
Sahil Sunny
@sahilsunny
Jan 02 2017 04:53
@toianw split function returns an array after splitting string from the specified character in my case its ','. My location data was something like "72.3394043,28.34234". but after splitting and joining it became "72,28" instead of "72.3394043,28.34234"
Ratheesh K
@stepprogg
Jan 02 2017 04:53
Can someone help me with this piece of Code?
var myStr = "I am a \"double quoted\" string inside \"double quotes\". "; // Change this line
Variable myStr should contain the string: I am a "double quoted" string inside "double quotes".
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".
hcmlopes
@hcmlopes
Jan 02 2017 04:55
@heenslice also there is no contact with lastName Harry that is firstName
Ian
@toianw
Jan 02 2017 04:55
@sahilsunny just change this line: location.split(","); to this: location = location.split(",");. So now location will contain the returned array.
Ratheesh K
@stepprogg
Jan 02 2017 04:56
@stepprogg
Can someone help me with this piece of Code?
var myStr = "I am a \"double quoted\" string inside \"double quotes\". "; // Change this line
Variable myStr should contain the string: I am a "double quoted" string inside "double quotes".
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".
Umm anyone D:
Christopher Bennett
@drbilo
Jan 02 2017 04:58
Ahhh.. think I fixed it. I don't think CodePen allows requests from non https sources.
Ratheesh K
@stepprogg
Jan 02 2017 04:59
I think i am invisible...
yongjaeya
@yongjaeya
Jan 02 2017 05:00
@stepprogg I had trouble with that too and a clue is that a double quote is \
\
two backspaces
Sahil Sunny
@sahilsunny
Jan 02 2017 05:00
@toianw thank you
CamperBot
@camperbot
Jan 02 2017 05:00
sahilsunny sends brownie points to @toianw :sparkles: :thumbsup: :sparkles:
:cookie: 477 | @toianw |http://www.freecodecamp.com/toianw
Ratheesh K
@stepprogg
Jan 02 2017 05:02
@yongjaeya This is what i typed. var myStr = "I am a \"double quoted\" string inside \"double quotes\". ";
@yongjaeya Is it wrong o.O?
yongjaeya
@yongjaeya
Jan 02 2017 05:04
@stepprogg Sorry i got confused with a different question. sorry
Manish Giri
@Manish-Giri
Jan 02 2017 05:04
@stepprogg can you post your challenge URL here? click "run tests" first.
Manish Giri
@Manish-Giri
Jan 02 2017 05:06
@stepprogg remove the space after the last .
Ken Haduch
@khaduch
Jan 02 2017 05:07
@stepprogg - try reloading your page.
Or that...
Ratheesh K
@stepprogg
Jan 02 2017 05:07
@Manish-Giri Ty very much. Damn a space lol
CamperBot
@camperbot
Jan 02 2017 05:07
stepprogg sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3455 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jan 02 2017 05:08
:+1:
Ratheesh K
@stepprogg
Jan 02 2017 05:08
How do i send brownie points :O?
yongjaeya
@yongjaeya
Jan 02 2017 05:11
how do I assign a number to a function in my case "Inside function fun1, assign 5 to oopsGlobal without using the var keyword." when var myGlobal=10
Greg Duncan
@GregatGit
Jan 02 2017 05:12
@yongjaeya don't use the var just myGlobal = 10;
yongjaeya
@yongjaeya
Jan 02 2017 05:13
@greg but the instructions state that myGlobal should be declared using var
Greg Duncan
@GregatGit
Jan 02 2017 05:13
@yongjaeya declare it outside the function
then change the value inside
yongjaeya
@yongjaeya
Jan 02 2017 05:15
@GregatGit Thanks
CamperBot
@camperbot
Jan 02 2017 05:15
yongjaeya sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 810 | @gregatgit |http://www.freecodecamp.com/gregatgit
Greg Duncan
@GregatGit
Jan 02 2017 05:15
so
var myVar = 1;
function add21(){
   myVar = 21;
}
add21();
Brian Mayrose
@intoro
Jan 02 2017 05:29
Thanks @leftynaut for your help with Checkpoint: Profile Lookup
CamperBot
@camperbot
Jan 02 2017 05:29
intoro sends brownie points to @leftynaut :sparkles: :thumbsup: :sparkles:
:cookie: 593 | @leftynaut |http://www.freecodecamp.com/leftynaut
kingsleychino
@kingsleychino
Jan 02 2017 05:40
please can any one help me now please
@camperbot please check this code
Dennis
@dennisorina
Jan 02 2017 05:42

Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.

ReferenceError: invalid assignment left-hand side

// Only change code below this line

var remainder;

11 % 3 = 3;

​Instructions

Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.

who can help? I am stuck
Ratheesh K
@stepprogg
Jan 02 2017 05:43
@dennisorina It should be remainder = 11%3;
David Sroka
@donswavey
Jan 02 2017 05:43
is freecodecamp litteraly made to ask questions? i try to avoid to ask them lol
Ratheesh K
@stepprogg
Jan 02 2017 05:44
@dennisorina var remainder = 11 % 3;
Dennis
@dennisorina
Jan 02 2017 05:45
Thanks @stepprogg Ratheesh K. @donswavey nobody is an island. What should one do if stuck?
CamperBot
@camperbot
Jan 02 2017 05:45
dennisorina sends brownie points to @stepprogg and @donswavey :sparkles: :thumbsup: :sparkles:
:cookie: 66 | @stepprogg |http://www.freecodecamp.com/stepprogg
:cookie: 176 | @donswavey |http://www.freecodecamp.com/donswavey
Ratheesh K
@stepprogg
Jan 02 2017 05:46
@dennisorina Always glad to help :)
Ppstah
@Ppstah
Jan 02 2017 05:55
var result;
var array = [];

function factorialize(num) {
  if (num === 0){
    return 1;
  }
     else for (var i = 1; i <= num; i++)
      array.push(i);
      result = array;
      result = array.reduce(function(n,m){
        return n*m;
      });

  return result;
}

factorialize(10);
so the code works perfectly fine, but for some reason it does not satisfy the task conditions
Ppstah
@Ppstah
Jan 02 2017 05:56
any ideas why this could be happening?
Rakheem Dewji
@raksdewji
Jan 02 2017 05:56
just dont know how to print it out
Ghulam Shabir
@ghulamshabir
Jan 02 2017 05:56
@raksdewji you need a space in the strings Hold/Bet
Ppstah
@Ppstah
Jan 02 2017 05:57
var result;
var array = [];

function factorialize(num) {
  if (num === 0){
    return 1;
  }
     else for (var i = 1; i <= num; i++)
      array.push(i);
      result = array;
      result = array.reduce(function(n,m){
        return n*m;
      });

  return result;
}

factorialize(10);
Ghulam Shabir
@ghulamshabir
Jan 02 2017 05:58
@Ppstah move result and array inside the function
Rakheem Dewji
@raksdewji
Jan 02 2017 05:58
@ghulamshabir how would i print the count before the bet/hold
Ppstah
@Ppstah
Jan 02 2017 05:58
@ghulamshabir thank you!
CamperBot
@camperbot
Jan 02 2017 05:58
ppstah sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1575 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Tyler Langan
@TylerL-uxai
Jan 02 2017 05:59
import 'sequelize';
import { expect, should } from 'chai';
import { Customer } from '../../data/models';

/* eslint-env mocha */

describe('Customers Server', () => {
  it('Begins with zero customers...', async () => {
    const allCustomers = await Customer.findAll();
    expect(allCustomers.length).to.eq(0);
  });
  it('Create a customer', async () => {
    const createCustomer = await Customer.create({ email: 'test@gmail.com' });
    createCustomer.should.exist;
  });
  it('Read the customer...', async () => {
    const readCustomer = await Customer.findAll({ where: { email: 'test@gmail.com' } });
    readCustomer.should.exist;
  });
  it('Delete customer', async () => {
    const deleteCustomer = await Customer.destroy({ where: { email: 'test@gmail.com' } });
    should.not.exist(deleteCustomer);
  });
});
  1) Customers Server Create a customer:
     TypeError: Cannot read property 'exist' of undefined
      at Context.<anonymous> (src/core/customers/customers.test.js:16:5)
      at Generator.next (<anonymous>)
      at step (node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
      at node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13

  2) Customers Server Read the customer...:
     TypeError: Cannot read property 'exist' of undefined
      at Context.<anonymous> (src/core/customers/customers.test.js:20:5)
      at Generator.next (<anonymous>)
      at step (node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
      at node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13

  3) Customers Server Delete customer:
     TypeError: Cannot read property 'exist' of undefined
      at Context.<anonymous> (src/core/customers/customers.test.js:24:5)
      at Generator.next (<anonymous>)
      at step (node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
      at node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13
Ghulam Shabir
@ghulamshabir
Jan 02 2017 06:00
@raksdewji return count plus Hold/Bet. make sure you give a space between them so if count five then output should be 5 Bet not 5Bet
Rakheem Dewji
@raksdewji
Jan 02 2017 06:00
thanks @ghulamshabir
CamperBot
@camperbot
Jan 02 2017 06:00
raksdewji sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1576 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Rakheem Dewji
@raksdewji
Jan 02 2017 06:00
that worked, thanks again man
Ghulam Shabir
@ghulamshabir
Jan 02 2017 06:00
@raksdewji :smile:
Ogundele Olumide
@Lumexralph
Jan 02 2017 06:01
@TylerL-uxai is it for this group? :worried:
@ghulamshabir good morning bro
Tyler Langan
@TylerL-uxai
Jan 02 2017 06:01
lol
Ghulam Shabir
@ghulamshabir
Jan 02 2017 06:02
@Lumexralph Good Morning :D
Ogundele Olumide
@Lumexralph
Jan 02 2017 06:02
@TylerL-uxai :laughing:
Tyler Langan
@TylerL-uxai
Jan 02 2017 06:02
I have no idea where else to go :\
stack overflow would probably down-vote the question to oblivion
Ogundele Olumide
@Lumexralph
Jan 02 2017 06:02
@TylerL-uxai you didn't say anything though, what's the code about?
Tyler Langan
@TylerL-uxai
Jan 02 2017 06:03
it's for testing on the server
using react-starter-kit
I plan to create a PR to share the test with 100s of other people, hopefully
I think createCustomer works
  Customers Server
Executing (default): SELECT `id`, `email`, `createdAt`, `updatedAt` FROM `Customer` AS `Customer`;
    ✓ Begins with zero customers...
Executing (default): INSERT INTO `Customer` (`id`,`email`,`createdAt`,`updatedAt`) VALUES ('1d499950-d0a6-11e6-9f86-c7381a7c847f','test@gmail.com','2017-01-02 04:44:15.591 +00:00','2017-01-02 04:44:15.591 +00:00');
    1) Create a customer
Executing (default): SELECT `id`, `email`, `createdAt`, `updatedAt` FROM `Customer` AS `Customer` WHERE `Customer`.`email` = 'test@gmail.com';
    2) Read the customer...
Executing (default): DELETE FROM `Customer` WHERE `email` = 'test@gmail.com'
    3) Delete customer
I think the commands work... just not the "should" or "expect" stuff from chai/mocha
zyj12345
@zyj12345
Jan 02 2017 06:08

function reverseString(str) {
return str.split(" ").reverse().join(' ');
}

reverseString("hello");

h1tag
@h1tag
Jan 02 2017 06:13
Hey, I'm on the Chunky Monkey challenge, can anybody explain to me why my code isn't working as it supposed to do:

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var arr2 =[];
  for(var i = 0; i < arr.size; i + size){
      arr2.push(arr.slice(i, i + size));
  }
  return arr2;
}
or give me hints
Ghulam Shabir
@ghulamshabir
Jan 02 2017 06:14
@zyj12345 do not put space in split and join
@fortMaximus you are not incrementing i
h1tag
@h1tag
Jan 02 2017 06:16
@ghulamshabir I'm doing it i + sizeon line 4
Ghulam Shabir
@ghulamshabir
Jan 02 2017 06:17
@fortMaximus that'ts not incrementing i
h1tag
@h1tag
Jan 02 2017 06:17
t