These are chat archives for FreeCodeCamp/HelpJavaScript

1st
Jun 2017
Ellyria
@Ellyria
Jun 01 2017 00:00
Did you check out the link in the instructions, @ShaimaTheBlueberry?
zippy
@ShaimaTheBlueberry
Jun 01 2017 00:01
yeah it didn't hel
help
sorry
john94
@lpy1994
Jun 01 2017 00:02
@frederickalcantara whats the problem?
I see one
zippy
@ShaimaTheBlueberry
Jun 01 2017 00:02
@Ellyria nevermind I think I got it
Ellyria
@Ellyria
Jun 01 2017 00:03
It wants you to do different things depending on how long each string is, @ShaimaTheBlueberry, so you'll need an ... oh, okay. Good for you!
frederickalcantara
@frederickalcantara
Jun 01 2017 00:03
All of the items on sections (title, allegiances, alias, and seasons) are not displaying entirely
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 01 2017 00:03
@frederickalcantara not about the content but it's showing Bran Stark is played by Emilia Clarke :)
Ellyria
@Ellyria
Jun 01 2017 00:03
I had a tough time with that one, @ShaimaTheBlueberry.
frederickalcantara
@frederickalcantara
Jun 01 2017 00:03
@reddy-bharathkumar I am also having a problem with that for some reason
Idk why its doing that when that object has an actor
@reddy-bharathkumar Thats another problem I am having as well. I feel like that is a problem with the API idk.
maybe @lpy1994 would know
john94
@lpy1994
Jun 01 2017 00:12
@frederickalcantara you might wanna ask it later, I gotta go, sorry about that
frederickalcantara
@frederickalcantara
Jun 01 2017 00:12
ok no worries
Dovydas Stirpeika
@Giveback007
Jun 01 2017 00:17
anyone here has a job in software?
Stephen James
@sjames1958gm
Jun 01 2017 00:21
@Giveback007 Yes. I am likely atypical in that I have been doing software for a long time.
Dovydas Stirpeika
@Giveback007
Jun 01 2017 00:22
@sjames1958gm could you say how hireable somone is if they have finished the front end certification in FCC
Trying2Grow
@Trying2Grow
Jun 01 2017 00:24
So there is no link involved in using flex box, it's just a part of the CSS3 syntax?
Dovydas Stirpeika
@Giveback007
Jun 01 2017 00:24
do you mean like is it or is it not a library?
it is not
(im not an expert) it is usable out of the box, but browsers might have wearying compatibility issues probably only for older versions
Trying2Grow
@Trying2Grow
Jun 01 2017 00:25
It's confusing how it's talked about, like it's it's own thing but I cant get a straight answer on how to get it working on my machine
Dovydas Stirpeika
@Giveback007
Jun 01 2017 00:26
@Trying2Grow do you know what is a parent element?
Ellyria
@Ellyria
Jun 01 2017 00:26
The https://gitter.im/FreeCodeCamp/CodingJobs channel might interest you, @Giveback007.
A parent element is the element the current element is inside of, @Giveback007.
Trying2Grow
@Trying2Grow
Jun 01 2017 00:26
Yes I do
Dovydas Stirpeika
@Giveback007
Jun 01 2017 00:27
ok if you do, all you need to do is give the parent element display: flex;
Ellyria
@Ellyria
Jun 01 2017 00:27
Oh, sorry.
Dovydas Stirpeika
@Giveback007
Jun 01 2017 00:27
and now the children will respond to flex things
Trying2Grow
@Trying2Grow
Jun 01 2017 00:28
Ok great! That's what I was starting to come to the conclusion of but i thought id ask here to make sure. Thank you!
Dovydas Stirpeika
@Giveback007
Jun 01 2017 00:28
no problem
Alexander
@asg5704
Jun 01 2017 00:30
I'm not sure I understand the Profile Lookup if/else statement. I am iterating through with a while loop.
Aizaz Shahid
@aizazshahid
Jun 01 2017 00:31
@asg5704 any code ?
Alexander
@asg5704
Jun 01 2017 00:31
But I can't get the valid property to show up with that contact.
Aizaz Shahid
@aizazshahid
Jun 01 2017 00:31
```
paste your code between those backticks
```
Alexander
@asg5704
Jun 01 2017 00:32
function lookUpProfile(firstName, prop){
// Only change code below this line
var i = 0;
while(i < contacts.length) {
  if(firstName === contacts[i].firstName && contacts.hasOwnProperty(prop)) {
    return contacts[i].prop;   
  }
  i++;
  }//end while

// Only change code above this line
}
@forwebtech Thank you by the way.
CamperBot
@camperbot
Jun 01 2017 00:32
asg5704 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 636 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
Jun 01 2017 00:33
@asg5704 if the property will not find, what message should be print ?
answer me in general way, as instructions said ?
Alexander
@asg5704
Jun 01 2017 00:34
If it can't find prop should return "No such property"
Aizaz Shahid
@aizazshahid
Jun 01 2017 00:34
@asg5704 right but with your condition, if the name will match, but the property is not, then ? as you are using && operator both should be match, so you need to nest your conditions.
Alexander
@asg5704
Jun 01 2017 00:35
Ahhh.. gotcha
I thought that if both are true, to return the value of the property. That makes a bit more sense
Aizaz Shahid
@aizazshahid
Jun 01 2017 00:37
@asg5704 :+1: and also use bracket notation to return the property because as you are using parameter prop so that will not work with . dot operator !
Alexander
@asg5704
Jun 01 2017 00:38
@forwebtech thanks :+1: . I'll give it a try
CamperBot
@camperbot
Jun 01 2017 00:38
asg5704 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:warning: asg5704 already gave forwebtech points
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 01 2017 00:39
var newstr = str.replace(/[0-9,\,,\,\/,\$,#,' ',.,_,\:,|]/gi,"");
can anyone check this
it's not ignoring the case
Aizaz Shahid
@aizazshahid
Jun 01 2017 00:40
@reddy-bharathkumar what are you trying to do ?
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 01 2017 00:40
replacing all those special chars with null
ohh got it..
Aizaz Shahid
@aizazshahid
Jun 01 2017 00:40
@reddy-bharathkumar for that you have \W character class which includes non alphanumeric and spaces (but not _ underscore included )
Stephen James
@sjames1958gm
Jun 01 2017 00:41
@reddy-bharathkumar Since you have no letters in there case is not relevant
@reddy-bharathkumar If this is for palindrome - you don't want to remove numbers
xyzruben
@xyzruben
Jun 01 2017 00:41
Guys PLEASE HELP with the celsius conversion to fahrenheit. I'm not sure how to begin!
Aizaz Shahid
@aizazshahid
Jun 01 2017 00:41
@xyzruben did you see the formula which is described ?
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 01 2017 00:42
@sjames1958gm yes, after copying the code here I got that point.. silly mistake..
Stephen James
@sjames1958gm
Jun 01 2017 00:42
@xyzruben The function provided has a parameter celsius - that will have the value to convert.
Use that parameter/variable and the formula to set the local variable (that is returned)
xyzruben
@xyzruben
Jun 01 2017 00:44
Will it look something like this?
fahrenheit = celsius*9/5+32
Stephen James
@sjames1958gm
Jun 01 2017 00:44
@xyzruben Yep
@xyzruben I can never remember how to spell fahrenheit
Aizaz Shahid
@aizazshahid
Jun 01 2017 00:45
@sjames1958gm dictionary checker is there :D
xyzruben
@xyzruben
Jun 01 2017 00:46
Thanks @sjames1958gm and @forwebtech !!! I appreciate it!
CamperBot
@camperbot
Jun 01 2017 00:46
xyzruben sends brownie points to @sjames1958gm and @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 637 | @forwebtech |http://www.freecodecamp.com/forwebtech
:star2: 7570 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
AnikBiswas4
@AnikBiswas4
Jun 01 2017 00:50

var myVar = 87;

// Only change code below this line
myVar= ++myVar;
myVar = myVar;

Aizaz Shahid
@aizazshahid
Jun 01 2017 00:52
@AnikBiswas4 when we increment / decrement our variables they actually change the variable value so no need to store it just use ++ with variable name.
@AnikBiswas4 but what are the instructions ?
Adam Bohannon
@abohannon
Jun 01 2017 01:07
This might be a stupid question, but am I able to use a JSON feed on github as my feed for a quote generator? It doesn't seem to be working for me.
Aizaz Shahid
@aizazshahid
Jun 01 2017 01:10
@abohannon why not :) i actually think that idea and implemented it, i have a link do you want to see ?!
Adam Bohannon
@abohannon
Jun 01 2017 01:11
yea that would be rad
Steve
@stephengvinci
Jun 01 2017 01:11
function isLess(a, b) {
return a === b;
}
isLess(15, 10);
Adam Bohannon
@abohannon
Jun 01 2017 01:11
i tried another JSON feed from a free site and it worked, but then when I try the feed i want, it doesnt work
Steve
@stephengvinci
Jun 01 2017 01:11
what am i missing to return a true or false
?
Aizaz Shahid
@aizazshahid
Jun 01 2017 01:12
@abohannon well i upload the text to gist and then copy the raw url, that will work fine
nothing is there just the api code !
Stephen James
@sjames1958gm
Jun 01 2017 01:13
@stephengvinci You were not supposed to change the comparison.
@stephengvinci does === match isLess ?
@AnikBiswas4 ++ includes the = so no assignment is required
Gulsvi
@gulsvi
Jun 01 2017 01:14
@forwebtech When you create the gist, give it an extension of .json
Aizaz Shahid
@aizazshahid
Jun 01 2017 01:16
@SkyC0der that is not the raw link ?
Gulsvi
@gulsvi
Jun 01 2017 01:16
@forwebtech The URL in your getJSON has no file extension
Dominic Jones
@dhjfoodstech
Jun 01 2017 01:16

I have a question about manipulating arrays with unshift. On line 13 the .unshift automatically replaces the first array but in the example it was shifted off.........................// Example
var ourArray = ["Stimpson", "J", "cat"];
ourArray.shift(); // ourArray now equals ["J", "cat"]
ourArray.unshift("Happy");
// ourArray now equals ["Happy", "J", "cat"]

// Setup
var myArray = [["John", 23], ["dog", 3]];
myArray.shift();

// Only change code below this line.
myArray.unshift(["Paul", 35]);

Aizaz Shahid
@aizazshahid
Jun 01 2017 01:17
@SkyC0der but that is working fine !
Gulsvi
@gulsvi
Jun 01 2017 01:17
@forwebtech I think it's just a standard .txt file if you don't give it an extension
Moisés Man
@moigithub
Jun 01 2017 01:18
@dhjfoodstech unshift dont replace anything.. it ADD an element to the beginnig of an array
and shift removes it
Gulsvi
@gulsvi
Jun 01 2017 01:19
@forwebtech Try to parse the JSON and only show the first property
Dominic Jones
@dhjfoodstech
Jun 01 2017 01:20
@moigithub I'm trying to figure out where did ["John", 23] go its not in the console.
ha nvm I see they have myArray.shift()
Moisés Man
@moigithub
Jun 01 2017 01:21

```js
var myArray = [["John", 23], ["dog", 3]];

myArray.shift(); /// removes John,23
myArray.unshift(["Paul", 35]); // add Paul,35

soo it ends up like this ["Paul", 35],["dog", 3]];

Joel Korcsmaros
@lossness
Jun 01 2017 01:21
Can someone explain to me why after .map they have (function(val)? var oldArray = [1, 2, 3];
var timesFour = oldArray.map(function(val){
return val * 4;
});
Dominic Jones
@dhjfoodstech
Jun 01 2017 01:21
@moigithub Thanks
CamperBot
@camperbot
Jun 01 2017 01:21
dhjfoodstech sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3294 | @moigithub |http://www.freecodecamp.com/moigithub
Manish Giri
@Manish-Giri
Jun 01 2017 01:22
@lossness it's a callback
Joel Korcsmaros
@lossness
Jun 01 2017 01:22
im going to read up on callbacks
Manish Giri
@Manish-Giri
Jun 01 2017 01:22
it's executed for every element in oldArray
Aizaz Shahid
@aizazshahid
Jun 01 2017 01:22
@SkyC0der i did that as you suggested ? check it
Joel Korcsmaros
@lossness
Jun 01 2017 01:22
@Manish-Giri thank you
CamperBot
@camperbot
Jun 01 2017 01:22
lossness sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5762 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jun 01 2017 01:23
:+1:
yourGeekGoddess
@yourGeekGoddess
Jun 01 2017 01:24
Hey guys! Quick js question if you don't mind?

/* 1. asking my first name and checking if it is correct.

  1. If it is correct add to players points
  2. Tells the player if they are correct and how many points they
    have so far
    */

var myNameInput = prompt("What is my first name");
var myName = "my first name";
var playerScore = 1
if (myNameInput.toUpperCase === myName.toUpperCase) {
alert ("You are correct!");
playerscore =+ 1;
} else {
alert ("You are incorrect.");
}
alert ("Your current score is " + playerScore + " out of possible 1 point. ");

------------------------------------- is returning that the answer is correct even when it is not.

Aizaz Shahid
@aizazshahid
Jun 01 2017 01:25
@SkyC0der but why did you said that ?
Jason Yamada-Hanff
@yamad
Jun 01 2017 01:27
@lossness @Manish-Giri it’s not really a callback, that terminology is likely to confuse you. map takes a function as its first argument. that function is run for every element of the array.
Joel Korcsmaros
@lossness
Jun 01 2017 01:28
ok and the code starts at val * 4 when it runs right?
Manish Giri
@Manish-Giri
Jun 01 2017 01:28
it is a callback.
callback
Function that produces an element of the new Array, taking three arguments:
Joel Korcsmaros
@lossness
Jun 01 2017 01:28
and goes backwards? or am i thinking of something else
Manish Giri
@Manish-Giri
Jun 01 2017 01:28
@lossness when it first runs, oldArray[0] is 1
so val becomes 1
and 1 * 4 is returned
Moisés Man
@moigithub
Jun 01 2017 01:29
@yourGeekGoddess toUpperCase is a method.. so u need to add () at the end
.toUpperCase()
Manish Giri
@Manish-Giri
Jun 01 2017 01:29
next iteration, val is 2
and 2 * 4 is returned
Jason Yamada-Hanff
@yamad
Jun 01 2017 01:29
@Manish-Giri @lossness ok, fair. I think it’s confusing to call every functional argument a callback… but mdn wins I guess
Manish Giri
@Manish-Giri
Jun 01 2017 01:29
and so on
@lossness
Joel Korcsmaros
@lossness
Jun 01 2017 01:29
how does it know val is those numbers? @Manish-Giri
because its connected to oldArray with map?
yourGeekGoddess
@yourGeekGoddess
Jun 01 2017 01:31
@moigithub thank you! I knew it was something tiny like that. lol
CamperBot
@camperbot
Jun 01 2017 01:31
yourgeekgoddess sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3295 | @moigithub |http://www.freecodecamp.com/moigithub
Manish Giri
@Manish-Giri
Jun 01 2017 01:31
yeah, kind of
Tony Brackins
@mrbrackins
Jun 01 2017 01:39
@nikkilr88 looks like you need to run an npm install and npm start
Proconsul
@proconsu1
Jun 01 2017 01:44

i think i may be misusing the .split method here. and possibly the join as well, though i have tried to conform to my reading of their use on MDN. or my control flow is upsetting their proper functioning. getting a headache though trying to think through to the problem. I have another version of the code without the comments if that would be easier to read. i only added them to try to clarify my own thought process in figuring where i messed up.

function titleCase(str) {
  var arr = str.split(' '); //trying to break the string into an array everywhere there is a space in the string
  for (var i=0 ; i < arr.length ; i++){  
    arr[i] = arr[i].split(''); //trying to break the individual elements within the array one by one into nested arrays of individual characters
    arr[i][0].toUpperCase(); //trying to force the first element of each nested array to become upper case
    arr[i].join(''); //trying to put each nested arrays back together as a now-capitalized string
  }
  str = arr.join(' '); //putting the outer arrary back together into a single string, with spaces added back in, and passing it to the str variable
  return str; //this was provided code, so i left it alone and conformed my code to accomodate it, or tried to anyway
}

my output ends up being an array instead of a string, and mostly of single characters, but with a couple of elements being strings with spaces in the middle

Christopher McCormack
@cmccormack
Jun 01 2017 01:44
@proconsu1 you can't mutate a string in place, strings are immutable
Joel Korcsmaros
@lossness
Jun 01 2017 01:45
this is getting fun i like javascript
Christopher McCormack
@cmccormack
Jun 01 2017 01:45
@proconsu1 need to assign the result of your uppercase function to that array position
@proconsu1 Or use slice instead of splitting the word and combine pieces to make a new word
Proconsul
@proconsu1
Jun 01 2017 01:46
@cmccormack okay, that one soared over my head. :worried: i thought i was sidestepping that by breaking the strings into arrays first
Christopher McCormack
@cmccormack
Jun 01 2017 01:46
@proconsu1 you're still trying to change a string in place with arr[i][0].toUpperCase();
@proconsu1 try arr[i][0] = arr[i][0].toUpperCase(); but note I didn't fully examine all your code
Proconsul
@proconsu1
Jun 01 2017 01:46
@cmccormack ahh, because the element in the array is a string, and it is that string i am trying to alter. i see
Christopher McCormack
@cmccormack
Jun 01 2017 01:47
@proconsu1 yup you got it
@lossness it is pretty fun :) Played with canvas yet?
Joel Korcsmaros
@lossness
Jun 01 2017 01:47
@cmccormack dont know what canvas is!
Proconsul
@proconsu1
Jun 01 2017 01:48
@cmccormack thanks. now to get back to it and see where my code breaks down next :smile:
CamperBot
@camperbot
Jun 01 2017 01:48
proconsu1 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 707 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Jun 01 2017 01:49
@proconsu1 I highly recommend when you're running into issues like that and don't quite know what's going on to add console.log(var) statements so you can see the current state of a variable in the browser console.
@lossness for drawing - I started playing with it a few days ago and i've had a lot of fun :D
Proconsul
@proconsu1
Jun 01 2017 01:49
@cmccormack ahh. excellent tip. thanks again
CamperBot
@camperbot
Jun 01 2017 01:49
proconsu1 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:warning: proconsu1 already gave cmccormack points
Gulsvi
@gulsvi
Jun 01 2017 01:58
@forwebtech Because you are requesting JSON from a file that does not have a .json extension. It may "work" for you, but a valid, language-independent JSON file has the extension .json
Nikki L.R.
@nikkilr88
Jun 01 2017 02:01
Could anyone tell my why fetch() isn't working here? https://ide.c9.io/nicolesattler/react-test

Could anyone tell my why fetch() isn't working here? https://ide.c9.io/nicolesattler/react-test

I have it working on CodePen just fine.

Christopher McCormack
@cmccormack
Jun 01 2017 02:06
@nikkilr88 you're getting this error: Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
Nikki L.R.
@nikkilr88
Jun 01 2017 02:08
@cmccormack I don't know what that is or how to fix it. :/
Christopher McCormack
@cmccormack
Jun 01 2017 02:08
@nikkilr88 some other things I see - you have a display function that modifies the DOM, but with react you should really be creating JSX elements and passing state to those - once the state is updated React should update those elements
Nikki L.R.
@nikkilr88
Jun 01 2017 02:09
@cmccormack I had that project running in another workspace, and I tried to redo it with create-react-app
Christopher McCormack
@cmccormack
Jun 01 2017 02:10
@nikkilr88 create-react-app is nice, keep using it
Nikki L.R.
@nikkilr88
Jun 01 2017 02:10
@cmccormack I will keep that in mind, thanks! And yeah, it seems nice, but now I can't get fetch to work like in the other one. :D
CamperBot
@camperbot
Jun 01 2017 02:10
nikkilr88 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 708 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Jun 01 2017 02:11
@nikkilr88 it looks like your first fetch does work, so I would look into why that one works but the button click doesn't
seazaz
@seazaz
Jun 01 2017 02:11
Don't know how to destructure this array and assign its contents to a new array while omitting the first 2 elements https://beta.freecodecamp.com/en/challenges/es6/use-destructuring-assignment-with-the-rest-operator-to-reassign-array-elements
Christopher McCormack
@cmccormack
Jun 01 2017 02:12
@nikkilr88 oh I didn't see you automatically fill in a quote
Josephine WilesWarner
@wileswarner
Jun 01 2017 02:14
Hi everyone. I am stuck, someone please help me. Iniyializing variables. Var a; var b; var c; a = 6. B= 15 c = "I am a String!"; that's what i have coded an i am not able to pass. Plese tell me what i am doing wrong. Thanks
Proconsul
@proconsu1
Jun 01 2017 02:14
@cmccormack got the challenge. turns out i got more mileage out of the tip you gave me. it was also breaking the .join method where i tried to reassemble the broken strings back into complete strings. a simple reassignment sorted it right out. that was a good challenge. really made me learn quite a bit
Christopher McCormack
@cmccormack
Jun 01 2017 02:14
@nikkilr88 I'm not sure how this worked at all before - you're not passing a URL to your App Component so how will fetch(this.props.src + now) work?
Nikki L.R.
@nikkilr88
Jun 01 2017 02:14
Ohhhhhhh!
@cmccormack I forgot to add it into this one!
Christopher McCormack
@cmccormack
Jun 01 2017 02:15
@nikkilr88 haha wellllll then
@proconsu1 That's great, once you work out these little things the bigger things are easier
Nikki L.R.
@nikkilr88
Jun 01 2017 02:16
@cmccormack Well... Hahaha... Thank you very much! I did that last time too... :D
CamperBot
@camperbot
Jun 01 2017 02:16
:warning: nikkilr88 already gave cmccormack points
nikkilr88 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
Nikki L.R.
@nikkilr88
Jun 01 2017 02:16
@cmccormack I think I may have overworked my brain today. :D
Christopher McCormack
@cmccormack
Jun 01 2017 02:16
@nikkilr88 I would suggest while you're correcting that you also look at how your state is used with your QuoteBox. You should be sending the quote and author info you get from your api call to your QuoteBox then using them as properties. If you do it that way, when you pull a new quote React will update the elements automatically
@nikkilr88 haha take a break
@nikkilr88 I'd recommend getting rid of the display() function altogether
Nikki L.R.
@nikkilr88
Jun 01 2017 02:18
@cmccormack I will try that tomorrow... Thanks again! I am pretty new at this, but I think I'm slowly catching on.
CamperBot
@camperbot
Jun 01 2017 02:18
nikkilr88 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:warning: nikkilr88 already gave cmccormack points
Christopher McCormack
@cmccormack
Jun 01 2017 02:18
@nikkilr88 I'm on the second to last React project right now and I still don't feel I have a great grasp on it :D just when I think I do, something doesn't update like I would expect
Nikki L.R.
@nikkilr88
Jun 01 2017 02:19
@cmccormack This is my second week! :D
Christopher McCormack
@cmccormack
Jun 01 2017 02:20
@nikkilr88 looks pretty good so far. Take your break!
seazaz
@seazaz
Jun 01 2017 02:20
do you guys recommend the beta or just regular FCC?
Nikki L.R.
@nikkilr88
Jun 01 2017 02:21
@cmccormack I will.... I am going to look into what you said about props and state tomorrow and then take my break. :D
Tony Brackins
@mrbrackins
Jun 01 2017 02:22
@nikkilr88 this is only your 2nd week!?
crazy. Your projects are really nice @nikkilr88
Nikki L.R.
@nikkilr88
Jun 01 2017 02:23
@mrbrackins With React... I stated coding in Jan of this year. :)

crazy. Your projects are really nice @nikkilr88

Thank you!!!

CamperBot
@camperbot
Jun 01 2017 02:24
sorry nikkilr88, you can't send brownie points to yourself! :sparkles: :sparkles:
Tony Brackins
@mrbrackins
Jun 01 2017 02:25
oh nice! are you good at art/design? I’m trying to figure out how to make my creations more pleasing to the eye lol @nikkilr88
Nikki L.R.
@nikkilr88
Jun 01 2017 02:26
@mrbrackins I don't think so... Haha... I just look at a lot of different pages for inspiration.
Tony Brackins
@mrbrackins
Jun 01 2017 02:27
nice!
looks good!
Nikki L.R.
@nikkilr88
Jun 01 2017 02:27
@mrbrackins I also like to recreate webpages when I have extra time. It's good practice.
Tony Brackins
@mrbrackins
Jun 01 2017 02:28
gotcha. maybe I’ll try that! thx
Christopher McCormack
@cmccormack
Jun 01 2017 02:28
I'll often spend an exorbitant amount of time trying to make my projects look really good, then just as I"m going to post it I see someone else's with a bit less functionality but looks 10x as good :D
Nikki L.R.
@nikkilr88
Jun 01 2017 02:29
:D
Christopher McCormack
@cmccormack
Jun 01 2017 02:29
I"m thinking ugly and functional is the way to go for me haha
Tony Brackins
@mrbrackins
Jun 01 2017 02:29
hahah yea everyti
*everything I have at this point is pretty ugly lol
tolu5455
@tolu5455
Jun 01 2017 02:34
help me
Ogundele Olumide
@Lumexralph
Jun 01 2017 02:36
@tolu5455 with?
Lanitta
@DivaWeb
Jun 01 2017 02:39
Help!!!! I am working on Arguments Optional

~~~function addTogether(num) {
var object1 = arguments[0];
var object2 = arguments[1];

if(typeof num === "number"){
return object1 + object2;
}

else{
var secondArg = function (arg2){

   return num + arg2;

};
return secondArg;

}

}

addTogether(2)(3);~~~

Ivan Leo
@yaaaas
Jun 01 2017 02:40
Hey guys, need some help w the caesar cipher

var decoded = "";
var letter = " ";

function rot13(str) { // LBH QVQ VG!

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

if(number == 32) {
decoded += " ";
}
letter = String.fromCharCode((number - 39 - 13) %26 + 65);
decoded += letter;

}

return decoded;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

I'm trying to convert each letter of the string to a number, evaluate if it is a space
Nikki L.R.
@nikkilr88
Jun 01 2017 02:41
@cmccormack I decided to do it now. I passed the app state into the quotebox props, but the quotes all have <p> tags and they show up with the quote. :/
Ivan Leo
@yaaaas
Jun 01 2017 02:41
and then decode it by moving it back 13 spaces
the decoding works but I keep getting unwarranted dashes
Nikki L.R.
@nikkilr88
Jun 01 2017 02:41
I guess I'll mess around with it more tomorrow.
Christopher McCormack
@cmccormack
Jun 01 2017 02:41
@nikkilr88 you could maybe make them elements then grab the children
Proconsul
@proconsu1
Jun 01 2017 02:42
dangit! i know my logic is good on this one. this was an easy one. it has to be a typo, but my tired eyes refuse to see it. anyone got fresher eyes?
function largestOfFour(arr) {
  var arrBuilder = [];
  var z = 0;
  for ( i = 0 ; i < arr.length ; i++ ){
    z = 0;
    for ( j = 0 ; j < arr[i].length ; j++ ){
      if (arr[i][j] > z){
        z = arr[i][j];
      }
    }
    arrBuilder.push(z);
  }
  arr = arrrBuilder;


  // You can do this!
  return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Nikki L.R.
@nikkilr88
Jun 01 2017 02:43
@cmccormack I wouldn't know how to do that... :D I might just look for a better quote API.
tolu5455
@tolu5455
Jun 01 2017 02:44
@Lumexralph I got stuck at Counting Cards lesson
Lanitta
@DivaWeb
Jun 01 2017 02:44
@nikkilr88 If you are working with API's check out The Coding Train on YouTube he has great videos on explaining them
Christopher McCormack
@cmccormack
Jun 01 2017 02:44
@proconsu1 what are the arguments?
Ogundele Olumide
@Lumexralph
Jun 01 2017 02:45
@tolu5455 show your code
Proconsul
@proconsu1
Jun 01 2017 02:45
@cmccormack it is passing in an array consisting of 4 sub arrays, each of which has an unspeficied number of elements, the elements being numbers
i am supposed to isolate the highest number in each sub-array and return them as an array
Christopher McCormack
@cmccormack
Jun 01 2017 02:46
@DivaWeb if I remember that one correctly you need to store the first argument call and return your inner function, then call the innerfunction with the number you want to add to it. You shouldn't be using arguments
@proconsu1 can you edit your post to show an example, I mean
@DivaWeb oops yeah you should use arguments, sorry just looked at exercise. However you can't know how many you may have so it shouldn't be explicitly defined
Proconsul
@proconsu1
Jun 01 2017 02:48
@cmccormack edited to add in the sample case
Ogundele Olumide
@Lumexralph
Jun 01 2017 02:48
@proconsu1 arr = arrrBuilder what's arrrBuilder ?
@proconsu1 you have a typo I think, arrrBuilder => arr = arrBuilder
Proconsul
@proconsu1
Jun 01 2017 02:50
@Lumexralph @cmccormack garr!! i knew it hadda be a durned typo! thanks! think it's time to turn my eyes elsewhere for a bit. maybe get some sushi and sake before i come back to it
CamperBot
@camperbot
Jun 01 2017 02:50
proconsu1 sends brownie points to @lumexralph and @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1852 | @lumexralph |http://www.freecodecamp.com/lumexralph
:cookie: 709 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Jun 01 2017 02:50
@proconsu1 sake isn't going to help :D
tolu5455
@tolu5455
Jun 01 2017 02:50
@Lumexralph oh I can fix it.. btw thank you
CamperBot
@camperbot
Jun 01 2017 02:50
tolu5455 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1853 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jun 01 2017 02:51
@tolu5455 :+1:
Proconsul
@proconsu1
Jun 01 2017 02:51
@cmccormack no, but it'll make me better able to take frustration in stride
ArchivalBoat50
@ArchivalBoat50
Jun 01 2017 02:52
Hey guys, I'm currently on the "Show the Weather project" and I'm stuck. As in, I don't know the kind of structure i would need to code to get my weather app to work.
Currently, this is all I know: "Get your current location, doing the geoposition thing," "Connect with a weather API", and do a Celsius to Fahrenheit convesion.
Ysaye
@thisisysaye
Jun 01 2017 02:52
Hi all, I have a (probably easy) question. I'm on the Switch Statement exercise but don't know what statement to execute. I am struggling.
SafetySt0p
@SafetySt0p
Jun 01 2017 02:53
is something wrong with my studlyCapVar?

// Declarations
var studlyCapVaR;
var properCamelCase;
var titleCaseOver;

// Assignments
studlyCapVaR = 10;
properCamelCase = "A String";
titleCaseOver = 9000;

Ogundele Olumide
@Lumexralph
Jun 01 2017 02:53
@thisisysaye i don't understand your question
@SafetySt0p yes
@SafetySt0p studlyCapVaR = 10;
Ysaye
@thisisysaye
Jun 01 2017 02:54
@Lumexralph on writing a switch statement, I have the line with the switch, and a line with the case, but I have no clue what to write as a statement...what actual code to execute
SafetySt0p
@SafetySt0p
Jun 01 2017 02:54
ah it was the R thanks XD
Ogundele Olumide
@Lumexralph
Jun 01 2017 02:55
@thisisysaye what are the instructions ?
@SafetySt0p :+1:
Ysaye
@thisisysaye
Jun 01 2017 02:55

@Lumexralph

Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"

Christopher McCormack
@cmccormack
Jun 01 2017 02:55
@thisisysaye after the case, you write your expression, followed by a break if you're finished. There should be an example that shows the syntax, or you can use documentation https://mdn.io/switch
Ogundele Olumide
@Lumexralph
Jun 01 2017 02:55
@ArchivalBoat50 that seems a good way to start, try it out
Christopher McCormack
@cmccormack
Jun 01 2017 02:56
@proconsu1 haha well enjoy :D
Ysaye
@thisisysaye
Jun 01 2017 02:56

@cmccormack this is the example:

switch (num) {
case value1:
statement1;
break;

Ogundele Olumide
@Lumexralph
Jun 01 2017 02:56
@thisisysaye your switch cases should check for values 1, 2, ...., then assign the respective string to the variable there is it answer ?
Christopher McCormack
@cmccormack
Jun 01 2017 02:57
@thisisysaye ok statement1 is a placeholder for where you would do your work
Claudio Restifo
@Marmiz
Jun 01 2017 03:08
@thisisysaye probably the challenge wants you to set some variables value as statement:
case 1:
someVar = someValue
break;
Ysaye
@thisisysaye
Jun 01 2017 03:08

@Marmiz this is what I am putting but it is not right

switch (answer) {
case 1:
answer="alpha";
break;

I've also tried switching out the "answer" and "val"
Christopher McCormack
@cmccormack
Jun 01 2017 03:09
@thisisysaye your switch should be taking the variable that you compare against
Ysaye
@thisisysaye
Jun 01 2017 03:09
I guess I don't understand the fundamental process happening so I don't know how to fix it
Christopher McCormack
@cmccormack
Jun 01 2017 03:09
@thisisysaye so val is your test, use switch(val)
Claudio Restifo
@Marmiz
Jun 01 2017 03:09
@thisisysaye is what you're passing to the switch : switch (answer)
You should pass the val to the function, and not the aswer
Ogundele Olumide
@Lumexralph
Jun 01 2017 03:09
@thisisysaye what's the parameter of your function holding the passed value?
@thisisysaye the switch(expression) expression will be evaluated then compared to the cases
Ysaye
@thisisysaye
Jun 01 2017 03:10

That was it! This worked:

switch (val) {
case 1:
answer="alpha";
break;

You were both right @Marmiz @cmccormack. Thank you! And @Lumexralph :)
CamperBot
@camperbot
Jun 01 2017 03:11
thisisysaye sends brownie points to @marmiz and @cmccormack and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 917 | @marmiz |http://www.freecodecamp.com/marmiz
:star2: 1854 | @lumexralph |http://www.freecodecamp.com/lumexralph
:cookie: 710 | @cmccormack |http://www.freecodecamp.com/cmccormack
Claudio Restifo
@Marmiz
Jun 01 2017 03:13
@thisisysaye try to understand the logic :)
especially what functions arguments are :)
Ysaye
@thisisysaye
Jun 01 2017 03:19
Thank you for the advice @marmiz. I'm watching the free Code Camp video on switch for the 3rd time now to try to understand!
CamperBot
@camperbot
Jun 01 2017 03:19
thisisysaye sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:warning: thisisysaye already gave marmiz points
Christopher McCormack
@cmccormack
Jun 01 2017 03:20
@thisisysaye best advice I can give you is go to a site like codepen.io and play with the examples, use tools like console.log() to output variables to the browser console and see what's currently stored in them. Once you get all that down it's much easier
Claudio Restifo
@Marmiz
Jun 01 2017 03:22
Probably something like
https://repl.it/languages/javascript
Is more suited to test functions than codepen :)
Ysaye
@thisisysaye
Jun 01 2017 03:22
Okay thanks @cmccormack. I started with codepen.io, but playing with the examples is a great suggestion.
CamperBot
@camperbot
Jun 01 2017 03:22
thisisysaye sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:warning: thisisysaye already gave cmccormack points
Ysaye
@thisisysaye
Jun 01 2017 03:23
@marmiz never heard of that; will check it out too!
Christopher McCormack
@cmccormack
Jun 01 2017 03:23
@Marmiz @thisisysaye that's a good one as well as you don't have to use the browser console to use console.log(). I would still recommend learning how to use the browser console over all others, however.
Claudio Restifo
@Marmiz
Jun 01 2017 03:24
@cmccormack that's for sure. But sometimes even the browser is verbose so it happens that I just test out functions on other platforms :)
Alex
@alextran1502
Jun 01 2017 03:28
Hello, can anyone help me with Javascript on this toggle button. I want to click and the box animate one time, opacity to 0 one time and after another click, the opacity back to 100. https://codepen.io/altran1502/pen/zwgXJX
danghv
@danghv
Jun 01 2017 03:30
guys, what is this mean:"What is the new fad diet for ghost developers? The Boolean."?
Ken Haduch
@khaduch
Jun 01 2017 03:30
@alextran1502 - I think that the key would be one click handler, and a state variable to indicate that you should fade in or fade out. The way you have that written, I think that both handlers are being triggered with a single click.
Pamela guy
@219tenderlips
Jun 01 2017 03:33

var myVar = 87;

// Only change code below this line
myVar = myVar + 1;
Please help I don't understand?

Change the code to use the ++ operator on myVar.
Christopher McCormack
@cmccormack
Jun 01 2017 03:33
@alextran1502 git rid of that second one and use "opacity": $('div').css('opacity') === '0' ? '1' : '0'
Ogundele Olumide
@Lumexralph
Jun 01 2017 03:33
@219tenderlips you need to use ++ with myVar
Ken Haduch
@khaduch
Jun 01 2017 03:33
@219tenderlips - use myVar++; instead of myVar = myVar + 1;
Pamela guy
@219tenderlips
Jun 01 2017 03:34
ok thanks
Ken Haduch
@khaduch
Jun 01 2017 03:35

@alextran1502 - this would work:

$(document).ready(function () {
  var fade = true;
    $("#btn").on("click", function() {
      var opacity = 1;
      if (fade) {
        opacity = 0;
        fade = false;
      } else fade = true;
        $("div").animate({
           "opacity":opacity
       },1000);
    });
});

Only one click handler, and change the value each time. @cmccormack had a nice elegant way to do the same.

Pamela guy
@219tenderlips
Jun 01 2017 03:36
myVar should equal 88
Alex
@alextran1502
Jun 01 2017 03:36
@cmccormack @khaduch thank you!!
CamperBot
@camperbot
Jun 01 2017 03:36
alextran1502 sends brownie points to @cmccormack and @khaduch :sparkles: :thumbsup: :sparkles:
:cookie: 711 | @cmccormack |http://www.freecodecamp.com/cmccormack
:star2: 2930 | @khaduch |http://www.freecodecamp.com/khaduch
Pamela guy
@219tenderlips
Jun 01 2017 03:36
myvar++ ; didn't work?
Ken Haduch
@khaduch
Jun 01 2017 03:37
@219tenderlips - check your spelling - the same capitalization is required.
Ogundele Olumide
@Lumexralph
Jun 01 2017 03:37
@219tenderlips myVar++;
Claudio Restifo
@Marmiz
Jun 01 2017 03:37
@alextran1502 since you're using jQuery you can see with the css property he value of opacity, then if it's 1 fade to 0 and opposite:
$("#btn").on("click", function() {
      let x = $('div').css('opacity')
      x == 1 ? $("div").animate({
           "opacity":0
       },1000) : $("div").animate({
           "opacity":1
       },1000) 
    });
Alex
@alextran1502
Jun 01 2017 03:37
@Marmiz thanks!
CamperBot
@camperbot
Jun 01 2017 03:37
alextran1502 sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 920 | @marmiz |http://www.freecodecamp.com/marmiz
Pamela guy
@219tenderlips
Jun 01 2017 03:37
@Lumexralph it didn't work .

var myVar = 87;

// Only change code below this line
myVar = myVar++;

Ogundele Olumide
@Lumexralph
Jun 01 2017 03:38
@219tenderlips show your code
@219tenderlips don't assign it to myVar
Pamela guy
@219tenderlips
Jun 01 2017 03:38
my Var should equal 88
Ken Haduch
@khaduch
Jun 01 2017 03:39
@219tenderlips - myVar starts out with a value of 87. myVar++ would increment it, and it will then equal 88. No further assignment is required.
Mukul Agrawal
@mukul09
Jun 01 2017 03:39

@219tenderlips you do not have to assign to myVar,

myVar++;

means

myVar=myVar+1;
Ogundele Olumide
@Lumexralph
Jun 01 2017 03:39
@219tenderlips ++ post-increment operator returns the initial value before it's incremented, the side-effect of the operator is it increases the value by 1
Alex
@alextran1502
Jun 01 2017 03:40
what is the ? in Jquery?
Pamela guy
@219tenderlips
Jun 01 2017 03:40
ok
thank you
Ogundele Olumide
@Lumexralph
Jun 01 2017 03:40
@alextran1502 or JS ?
Alex
@alextran1502
Jun 01 2017 03:40
@Lumexralph yes
Ogundele Olumide
@Lumexralph
Jun 01 2017 03:41
@alextran1502 it's ternary operator ? :
Pamela guy
@219tenderlips
Jun 01 2017 03:41
thank you!
Ogundele Olumide
@Lumexralph
Jun 01 2017 03:41
@alextran1502 more like an if/else statement simplified
@219tenderlips :+1:
Alex
@alextran1502
Jun 01 2017 03:42
@Lumexralph Thank you!!! I just jumped into jquery to do the weather apps
CamperBot
@camperbot
Jun 01 2017 03:42
alextran1502 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1855 | @lumexralph |http://www.freecodecamp.com/lumexralph
@alextran1502 jQuery was built using JS, so any VanillaJS code will work in jQuery
Alex
@alextran1502
Jun 01 2017 03:45
@Lumexralph good info! mercy
Claudio Restifo
@Marmiz
Jun 01 2017 03:46

@alextran1502 that's a conditional (often called ternary)

condition ? expr1 : expr2

Just good 'ol JS

Abhay pratap singh
@abh4265
Jun 01 2017 03:46

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

largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
What I have done wrong in finding largest no. in each subarray.

Ogundele Olumide
@Lumexralph
Jun 01 2017 03:47
@abh4265 longest is not an array
Rob
@water007
Jun 01 2017 03:47
code camp is some bull it doesn't take all day to do a variable i quit see you later
Abhay pratap singh
@abh4265
Jun 01 2017 03:47
how to make it an array
Ken Haduch
@khaduch
Jun 01 2017 03:48
@abh4265 - easiest thing is to keep longest as you have it, not an array, and after you find the largest value in the current subarray, push it into your find result array. You don't need a third for loop - just two nested loops to iterate through the arrays.
Ogundele Olumide
@Lumexralph
Jun 01 2017 03:48
@abh4265 why don't you do
if(longest < arr[i][j]){
longest = arr[i][j];
}
@abh4265 in addition to what @khaduch said remember to reset the value of longest for iteration of each sub-array in the outer loop
Ken Haduch
@khaduch
Jun 01 2017 03:50
@Lumexralph - good point!
Abhay pratap singh
@abh4265
Jun 01 2017 03:50
if(longest < arr[i][j]){
longest = arr[i][j];
}this gives the largest in the whole pattern while we want largest in a subarray @Lumexralph
Ogundele Olumide
@Lumexralph
Jun 01 2017 03:51
@abh4265 read what @khaduch said carefully
Makopa
@makopa
Jun 01 2017 03:51
anyone have experience in react.js? i cant understand what children is for
class Search extends Component {
  render() {
    const { value, onChange, children } = this.props;
    return (
      <form>
        {children} <input
          type='text'
          value={value}
          onChange={onChange}
        />
      </form>
    );
  }
}
Ken Haduch
@khaduch
Jun 01 2017 03:52
@abh4265 - when you complete the iteration of each sub-array, use .push() to push the result for that array onto a final result array. And then initialize your longest variable so that it picks up a new value for the next loop of the inner loop. THen at the end you return the result array, which should contain all of the largest values of each sub-array.
Christopher McCormack
@cmccormack
Jun 01 2017 03:53
@makopa children is a property that was passed down from a parent. You're using destructuring to declare and assign a new variable from the values in this.props
Ken Haduch
@khaduch
Jun 01 2017 03:53
@abh4265 - you might find it interesting to take your code to http://pythontutor.com/javascript.html#mode=edit and examine the execution of it step by step. It's a helpful learning tool.
Christopher McCormack
@cmccormack
Jun 01 2017 03:54
@makopa so if the parent that passed down children (something like <Search children={this.state.something} />) changed state of something, it would be changed in your form when React updates
Abhay pratap singh
@abh4265
Jun 01 2017 03:55
Yah, I am trying,contact you all later if got stuck,Thanks a lot.
Ken Haduch
@khaduch
Jun 01 2017 03:59
@abh4265 - okay. It's a good exercise for understanding how to iterate and manipulate array values and return the proper form of information. It is best to take your time with it and understand it in the greatest detail. Good luck with that task!
Joseph
@revisualize
Jun 01 2017 04:12
@abh4265 Did you solve your challenge?
@khaduch Thanks.
CamperBot
@camperbot
Jun 01 2017 04:12
revisualize sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2931 | @khaduch |http://www.freecodecamp.com/khaduch
Prabhat
@Prabhat98
Jun 01 2017 04:52
Can someone help me with "Word Blank" challenge in javascript ? . please help
Netrunner21
@Netrunner21
Jun 01 2017 04:55
Yes
@Prabhat98 can you paste what you have so far?
or do you need help getting started
Prabhat
@Prabhat98
Jun 01 2017 04:56
Anyone?
Netrunner21
@Netrunner21
Jun 01 2017 04:56
@Prabhat98 I can help
Prabhat
@Prabhat98
Jun 01 2017 04:57
@Netrunner21 I don't understand how to begin
Netrunner21
@Netrunner21
Jun 01 2017 04:57
@Prabhat98 they are wanting you to make a sentence out of the arguments
Prabhat
@Prabhat98
Jun 01 2017 04:58
@Netrunner21 can you tell me an example
Netrunner21
@Netrunner21
Jun 01 2017 04:58
@Prabhat98 to be more clear, you'll make a sentence out of the parameters such as myAdjective. The arguments such as dog and big will get passed through.
Prabhat
@Prabhat98
Jun 01 2017 04:59
@Netrunner21 let me try , thanks
CamperBot
@camperbot
Jun 01 2017 04:59
prabhat98 sends brownie points to @netrunner21 :sparkles: :thumbsup: :sparkles:
:cookie: 325 | @netrunner21 |http://www.freecodecamp.com/netrunner21
Netrunner21
@Netrunner21
Jun 01 2017 04:59
@Prabhat98 you're returning result, so you'll need to set result to equal your sentence
Prabhat
@Prabhat98
Jun 01 2017 05:00
@Netrunner21 can you do a sentence for me ?
Netrunner21
@Netrunner21
Jun 01 2017 05:01
I can. But let me ask you. Do you know the difference between parameters and arguments? This will help you.
Prabhat
@Prabhat98
Jun 01 2017 05:01
@Netrunner21 yes I know
Netrunner21
@Netrunner21
Jun 01 2017 05:02
Ok. Good. So you're taking your paramaters and making a string.
Here's an example
sentence = param1 + " " + param2 + " " + param3 + ".";
this way you have spaces between the words
a period to cap it off and a semicolon to end the statement.
Rob
@water007
Jun 01 2017 05:04
how do you uninstall this fake as shit
Proconsul
@proconsu1
Jun 01 2017 05:08

OK, this code works. what i am wondering is if, short of using the .endsWith() method, is there a better or tighter way of coding this? I feel like my solution here was a bit rudimentary, and I'm trying to also learn how to write tighter, cleaner code as I go so I don't have to break as many bad habits later.

function confirmEnding(str, target) {
  var k = target.length;
  k = k - (k*2);
  var z = str.substr(k);
  str = (z === target);

  return str;
}

confirmEnding("Bastian", "n");

Or am I just getting ahead of myself and should stick to the basics and leave the finer points for later?
Forgot to mention. The instructions were to make this function compare the argument target to the end of the string str and report true if they matched, false if they don't.

Netrunner21
@Netrunner21
Jun 01 2017 05:11
@proconsu1 lol let me check mine. I bet it's way shorter than mine
looks good. not much more you can do with that. good work.
@proconsu1 I take that back. Ours are about the same.
I'll post mine real quick.
function confirmEnding(str, target) {
  if (str.substr(str.length - target.length, str.length) === target) {
    return true;
  }
  return false;
}
confirmEnding("Bastian", "n");
Proconsul
@proconsu1
Jun 01 2017 05:12
@Netrunner21 cool. i like to see other approaches, steal other people's tricks :P
Netrunner21
@Netrunner21
Jun 01 2017 05:14
@proconsu1 then you understand the secret of efficient programming. You don't have to a one man show or a superhero. A famous trumpet player used to say "you have to imitate before you innovate".
Proconsul
@proconsu1
Jun 01 2017 05:14
@Netrunner21 ahh, i didn't realize you could pass an operation as an argument to .substr - nice. thanks
CamperBot
@camperbot
Jun 01 2017 05:14
proconsu1 sends brownie points to @netrunner21 :sparkles: :thumbsup: :sparkles:
:cookie: 326 | @netrunner21 |http://www.freecodecamp.com/netrunner21
Netrunner21
@Netrunner21
Jun 01 2017 05:15
Yeah man. So how are you getting a true false on your code? Just curious.
Proconsul
@proconsu1
Jun 01 2017 05:16
@Netrunner21 just realized i could've tightened mine up by doing as you did in eliminating the provided return line, and put my own in:
return (z === target);
Netrunner21
@Netrunner21
Jun 01 2017 05:16
I see
So, those operators will return true or false without having to specify. I remember that now. Thanks @proconsu1
CamperBot
@camperbot
Jun 01 2017 05:17
netrunner21 sends brownie points to @proconsu1 :sparkles: :thumbsup: :sparkles:
:cookie: 146 | @proconsu1 |http://www.freecodecamp.com/proconsu1
Proconsul
@proconsu1
Jun 01 2017 05:17
so that's two things i learned. i'd thank you again but the bot would complain
Netrunner21
@Netrunner21
Jun 01 2017 05:18
CamperBot wants all the cookies for himself
I could probably make mine shorter too now that I think about it.
I can remove the if statement I believe
Proconsul
@proconsu1
Jun 01 2017 05:19
yeah, i think a return would work there instead
and yours would then be much tighter than mine
Netrunner21
@Netrunner21
Jun 01 2017 05:20
function confirmEnding(str, target) {
  return (str.substr(str.length - target.length, str.length) === target); 
}
confirmEnding("Bastian", "n");
That's awesome man. Thanks for that.
I can also remove the outer parentheses.
Proconsul
@proconsu1
Jun 01 2017 05:21
good catch. i coulda done that on my return line,too
Joseph
@revisualize
Jun 01 2017 05:22
@Netrunner21 You could really shorten that.
Netrunner21
@Netrunner21
Jun 01 2017 05:22
@revisualize let me try and figure it out first, and then you can tell me
Proconsul
@proconsu1
Jun 01 2017 05:22
@revisualize do tell
Joseph
@revisualize
Jun 01 2017 05:22
@Netrunner21
var str = 'abcdefghij';

console.log('(1, 2): '   + str.substr(1, 2));   // '(1, 2): bc'
console.log('(-3, 2): '  + str.substr(-3, 2));  // '(-3, 2): hi'
console.log('(-3): '     + str.substr(-3));     // '(-3): hij' // <---------------------
Proconsul
@proconsu1
Jun 01 2017 05:22
ok, i'll wait
oh, not passing the length argument. i was already leaving that one off. it's a good one tho, since without the length defaults to end of string
@revisualize thanks for sharing. always good to pick up more good methods
CamperBot
@camperbot
Jun 01 2017 05:25
proconsu1 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4073 | @revisualize |http://www.freecodecamp.com/revisualize
Netrunner21
@Netrunner21
Jun 01 2017 05:28
function confirmEnding(str, target) {
  return str.substr(-target.length) === target; 
}
confirmEnding("Bastian", "n");
Thanks @revisualize I had over thought it.
CamperBot
@camperbot
Jun 01 2017 05:28
netrunner21 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4074 | @revisualize |http://www.freecodecamp.com/revisualize
Rob
@water007
Jun 01 2017 05:29
netrunner12 are you fucking with me
@Netrunner21 are you fucking with i dont play man
Netrunner21
@Netrunner21
Jun 01 2017 05:31
@ergumayagay can I see an example?
Emilio Gumayagay
@ergumayagay
Jun 01 2017 05:32
nevermind i found the answer, thanks anyway
Netrunner21
@Netrunner21
Jun 01 2017 05:33
Alright
Joseph
@revisualize
Jun 01 2017 05:34
Anyone else need assistance?
Anshul Adlakha
@anshuladlakha
Jun 01 2017 05:35
@revisualize i do
Joseph
@revisualize
Jun 01 2017 05:35
@anshuladlakha With?
Anshul Adlakha
@anshuladlakha
Jun 01 2017 05:35
@revisualize intermediate algorithm challenges
Joseph
@revisualize
Jun 01 2017 05:35
@anshuladlakha Which?
Rob
@water007
Jun 01 2017 05:36
ok i see
Markus Kiili
@Masd925
Jun 01 2017 05:36
@revisualize Why does this log 15?
var name = {};
console.log(name.length);
Joseph
@revisualize
Jun 01 2017 05:36
@anshuladlakha What have you done? What is your thought process?
Rob
@water007
Jun 01 2017 05:36
puck as sucker on computers
Joseph
@revisualize
Jun 01 2017 05:37
@Masd925 That would be the cross between an Elephant and a Rhino.
Anshul Adlakha
@anshuladlakha
Jun 01 2017 05:37
for(var i =0; i < arr1.length; i++){
    for (var j =0; j<arr2.length;j++){
      if(arr1[i]!==arr2[j]){
        newArr.push(arr2[j]);
      }
    }
  }
  return newArr;
@revisualize
Markus Kiili
@Masd925
Jun 01 2017 05:38
@revisualize 5 does look like an elephant, but don't really see the rhino there.
Proconsul
@proconsu1
Jun 01 2017 05:40
@anshuladlakha looks like that code is only going to return elements from arr2, when the instructions say you need to return from both arrays
Adam Faraj
@adamfaraj
Jun 01 2017 05:41
why does this keep throwing an error. i'm trying to assign, not compare
```
document.getElementById('celsius') = cTemp;
Joseph
@revisualize
Jun 01 2017 05:41
@Masd925 elephino. Hell if I know...
@Masd925 It's a joke. Not a good one at that.
Anshul Adlakha
@anshuladlakha
Jun 01 2017 05:41
document.getElementById('celsius').innerHTML= cTemp;
@adamfaraj try this
Adam Faraj
@adamfaraj
Jun 01 2017 05:43
thanks @anshuladlakha
CamperBot
@camperbot
Jun 01 2017 05:43
adamfaraj sends brownie points to @anshuladlakha :sparkles: :thumbsup: :sparkles:
:cookie: 271 | @anshuladlakha |http://www.freecodecamp.com/anshuladlakha
Anshul Adlakha
@anshuladlakha
Jun 01 2017 05:43
@adamfaraj is it working?
Adam Faraj
@adamfaraj
Jun 01 2017 05:43
but my code still isn't working even with that fixed
haha
<input type="text" name="temp" placeholder = "Enter Temperature" id="temp"/> F
<button onclick="calc()">
Convert
</button>
<br />
<input type="text" name="answer" placeholder = "Result" id="celsius" /> C



function calc() {
          var fTemp = document.getElementById('temp').value;
          var cTemp = ((fTemp - 32) / 1.8);
          document.getElementById('celsius').innerHTML = cTemp;
}
Joseph
@revisualize
Jun 01 2017 05:44
@anshuladlakha Umm.. So, that's a tough challenge. Because you have to think about two different arrays and values.
Markus Kiili
@Masd925
Jun 01 2017 05:44
@revisualize Yeah, magic that happens when you assign to some properties of the window object. That name is the name of the window, and if you assign into it, it is always coerced to string and that object becomes "[object Object]" and its length is 15.
Rick Willcox
@willcoxDev
Jun 01 2017 05:45
hey guys I am struggling with wherefore art thou
I know I want to check if it has a property and then use filter
to create the new array
Joseph
@revisualize
Jun 01 2017 05:45
@anshuladlakha When I first solved that challenge I used two different for loops.
Markus Kiili
@Masd925
Jun 01 2017 05:46
@willcoxDev You need filter and then a loop or iteration through source's keys.
Rick Willcox
@willcoxDev
Jun 01 2017 05:46
but if an object has { last: "Capulet" } how do use that like object[0] or w/e
Anshul Adlakha
@anshuladlakha
Jun 01 2017 05:46
@revisualize i was thinking about using a for loop inside a filter array funtion
Markus Kiili
@Masd925
Jun 01 2017 05:47
@willcoxDev You just loop source's keys and then access the filtered object and source with that key.
Joseph
@revisualize
Jun 01 2017 05:47
@anshuladlakha There's another way to use multiple .filter() calls as well.
@anshuladlakha It's been a long time since I worked that challenge. I've kind of forgotten how to do it.
Anshul Adlakha
@anshuladlakha
Jun 01 2017 05:48
@revisualize i think i need a filter to go through each element and compare it to the all the elemens of the second array right?
Netrunner21
@Netrunner21
Jun 01 2017 05:48
Just throwing this out there. My honest advice is to always try to first use the helpful links provided. Sometimes there are better ways to do it, but its easy to get into a pattern of trying to solve everything with for loops, which can hold you back. Not saying that's you're doing, but that was one of my habits I had to break. Just my two cents.
I'm preaching to the choir, I know, haha
Rick Willcox
@willcoxDev
Jun 01 2017 05:49
// getFoo is property which isn't enumerable
var myObj = Object.create({}, {
  getFoo: {
    value: function () { return this.foo; }
  } 
});
myObj.foo = 1;
console.log(Object.keys(myObj)); // console: ['foo']
I assume I need to use something similar to this
tommy
@tommygebru
Jun 01 2017 05:50
Im not able to get a bar:hover to work in d3.....
another thing Im struggling with also is setting a color to a bar...
Proconsul
@proconsu1
Jun 01 2017 05:51
@Netrunner21 "a pattern of trying to solve everything with for loops" -- Not so!! I use while loops and ifs, too :P
Makopa
@makopa
Jun 01 2017 05:51
@cmccormack its simply giving a values from the parent component going to the child? can I use any variable name on it/? instead of using children?
David Kang
@d-kang
Jun 01 2017 05:52
i just read the whereforart thou question. i forgot how poorly written some of these algorithms are
wonder
@wonder2991
Jun 01 2017 05:52
@adamfaraj you cannot print output on the input tag. Change it to a p tag. it should work
Markus Kiili
@Masd925
Jun 01 2017 05:53
@willcoxDev You can loop or iterate Object.keys(source) and then check if property values of the looped object and source match for all the source's keys.
Makopa
@makopa
Jun 01 2017 05:53
@cmccormack thanks chris!
CamperBot
@camperbot
Jun 01 2017 05:53
makopa sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 712 | @cmccormack |http://www.freecodecamp.com/cmccormack
Markus Kiili
@Masd925
Jun 01 2017 05:53
@willcoxDev You can use a loop and a flag variable, or a suitable array iterator method.
Rick Willcox
@willcoxDev
Jun 01 2017 05:54
ok ill give it a crack
Adam Faraj
@adamfaraj
Jun 01 2017 05:55
@wonder2991 that worked
@wonder2991 thank you
CamperBot
@camperbot
Jun 01 2017 05:55
adamfaraj sends brownie points to @wonder2991 :sparkles: :thumbsup: :sparkles:
:cookie: 290 | @wonder2991 |http://www.freecodecamp.com/wonder2991
Adam Faraj
@adamfaraj
Jun 01 2017 05:55
but how does this guy do it: http://jsfiddle.net/j08691/Qbssd/
wonder
@wonder2991
Jun 01 2017 05:58
Adam Faraj
@adamfaraj
Jun 01 2017 05:59
@wonder2991 that worked! thanks
CamperBot
@camperbot
Jun 01 2017 05:59
adamfaraj sends brownie points to @wonder2991 :sparkles: :thumbsup: :sparkles:
:warning: adamfaraj already gave wonder2991 points
tommy
@tommygebru
Jun 01 2017 06:00
Can anyone tell me why my text disappeared?
https://codepen.io/gebrutommy/pen/MmdwGp?editors=0110
From my d3 project... there is supposed to be blue labels everywhere for each bar...
h1tag
@h1tag
Jun 01 2017 06:04

Hey, why in this code snippet:

var myObject = { };

myObject[true] = "foo";
myObject[3] = "bar";
myObject[myObject] = "baz";

myObject["true"];                // "foo"
myObject["3"];                    // "bar"
myObject["[object Object]"];     // "baz"

the value of myObject["[object Object]"]; is baz?

john94
@lpy1994
Jun 01 2017 06:09
@h1tag cuz its a object itself.
kumar
@BSkumar2017
Jun 01 2017 06:09
myStr should have encoded text with the proper escape sequences and no spacing. How to fix this Error.var myStr= "FirstLine\n \SecondLIne\ \rThirdLine";
h1tag
@h1tag
Jun 01 2017 06:10
@lpy1994 hmm. Can you clarify more?
Adilzhan Izat
@JaxAdam
Jun 01 2017 06:10
@h1tag last stroke:
@h1tag last stroke:
myObject["myObject"];
h1tag
@h1tag
Jun 01 2017 06:12
@JaxAdam stroke?
john94
@lpy1994
Jun 01 2017 06:12
FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine @BSkumar2017
@BSkumar2017 ignore that,
you are missing something
kumar
@BSkumar2017
Jun 01 2017 06:13
@lpy1994 what i am missing
john94
@lpy1994
Jun 01 2017 06:13
just do as the instruction says
it has already written out there.
kumar
@BSkumar2017
Jun 01 2017 06:15
@lpy1994 I am done but i was showing same thing .
myStr should have encoded text with the proper escape sequences and no spacing.
h1tag
@h1tag
Jun 01 2017 06:15
@BSkumar2017 you're not using the right escape sequence for the backslash, check the table in the challenge
john94
@lpy1994
Jun 01 2017 06:15
FirstLine newline backslash SecondLinebackslash carriage-returnThirdLine
Adilzhan Izat
@JaxAdam
Jun 01 2017 06:16

can anyone help me?
Instructions
Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"
function caseInSwitch(val) {
var answer = "";
// Only change code below this line
case 1:
answer = "alpha";
break;
case 2:
answer = "beta";
break;
case 3:
answer = "gamma";
break;
case 4:
answer = "delta";
// Only change code above this line
return answer;
}

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

john94
@lpy1994
Jun 01 2017 06:16
check each one by one according to the table above @BSkumar2017
@JaxAdam what is the problem
Manish Giri
@Manish-Giri
Jun 01 2017 06:16
@JaxAdam where's the switch?
Adilzhan Izat
@JaxAdam
Jun 01 2017 06:17
@lpy1994 not working :\
Manish Giri
@Manish-Giri
Jun 01 2017 06:17
@JaxAdam where's the switch?
??
Rick Willcox
@willcoxDev
Jun 01 2017 06:18
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  //console.log(Object.keys(source));
  var hasAll = false;
   for (var i=0; i<collection.length; i++){
      if(collection[i].hasOwnProperty(Object.keys(source))){
        if(collection[i].last === source.last){
           arr.push(collection[i]);
        }    
      }
   }


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

whatIsInAName([{ "a": 1 }, { "a": 1 }, { "a": 1, "b": 2 }], { "a": 1 });
Adilzhan Izat
@JaxAdam
Jun 01 2017 06:18
@Manish-Giri argh, sorry! Thanks!
CamperBot
@camperbot
Jun 01 2017 06:18
jaxadam sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5770 | @manish-giri |http://www.freecodecamp.com/manish-giri
kumar
@BSkumar2017
Jun 01 2017 06:19
@lpy1994 can you show me the code I am getting the same thing.
var myStr="FirstLine\n\SecondLine\\rThirdLine";
"FirstName\n\SecondLine\\rThirdLine";
john94
@lpy1994
Jun 01 2017 06:20
@BSkumar2017 what is a backslash
Pieter Stokkink
@forkerino
Jun 01 2017 06:21
@willcoxDev any property that doesn't exist is undefined. So maybe you check undefined === undefined in you last if?
Adilzhan Izat
@JaxAdam
Jun 01 2017 06:23
@lpy1994 Thanks, man!
CamperBot
@camperbot
Jun 01 2017 06:23
jaxadam sends brownie points to @lpy1994 :sparkles: :thumbsup: :sparkles:
:cookie: 310 | @lpy1994 |http://www.freecodecamp.com/lpy1994
Pieter Stokkink
@forkerino
Jun 01 2017 06:23
@willcoxDev You will need to somehow loop over all keys of the source object and check if each one is on the current object from the collection you are inspecting. The .hasOwnProperty you have there doesn't work properly, because you are passing in an array of property names.
john94
@lpy1994
Jun 01 2017 06:23
@BSkumar2017 type this out for me newline backslash backslash carriage-return
Rick Willcox
@willcoxDev
Jun 01 2017 06:23
hmm
this is confusing af
Adam Faraj
@adamfaraj
Jun 01 2017 06:24
i feel like i'm close, but not
Title Case a Sentence
Return the provided string with the first letter of each word capitalized. Make sure the rest of the word is in lower case.
// jshint esversion:6

function titleCase(str) {
  var x = str.split(' ');
  var y = x.map(str => str.split(' '));
//   return x;
  return y;


}

titleCase("I'm a little tea pot");
return y =
// jshint esversion:6

function titleCase(str) {
  var x = str.split(' ');
  var y = x.map(str => str.split(' '));
//   return x;
  return y;


}

titleCase("I'm a little tea pot");
Adilzhan Izat
@JaxAdam
Jun 01 2017 06:25
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch(answer) {
  case 1:
  answer = "alpha";
  break;
  case 2:
  answer = "beta";
  break;
  case 3:
  answer = "gamma";
  break;
  case 4:
  answer = "delta";
        }
  // Only change code above this line  
  return answer;  
}

// Change this value to test
caseInSwitch(1);
`Problems:
caseInSwitch(1) should have a value of "alpha"
caseInSwitch(2) should have a value of "beta"
caseInSwitch(3) should have a value of "gamma"
caseInSwitch(4) should have a value of "delta"
`
Rick Willcox
@willcoxDev
Jun 01 2017 06:25
maybe use something like x[i].charAt(0);
Pieter Stokkink
@forkerino
Jun 01 2017 06:25
@adamfaraj that function inside your .map doesn't make sense. You split each word (which doesn't have a space in it by definition) on a space...
kumar
@BSkumar2017
Jun 01 2017 06:26
@lpy1994 thanks
CamperBot
@camperbot
Jun 01 2017 06:26
bskumar2017 sends brownie points to @lpy1994 :sparkles: :thumbsup: :sparkles:
:cookie: 311 | @lpy1994 |http://www.freecodecamp.com/lpy1994
Pieter Stokkink
@forkerino
Jun 01 2017 06:26
@JaxAdam you have to switch on the right thing. answer is where the result should come, but at the time of your switch it is just an empty string. Use the function parameter instead
Adam Faraj
@adamfaraj
Jun 01 2017 06:26
@forkerino it returns this [["I'am"], ["a"], ["little"],["tea"],["pot"]]
john94
@lpy1994
Jun 01 2017 06:27
@adamfaraj then it should be easy to capitalized each element in the arrau.
Pieter Stokkink
@forkerino
Jun 01 2017 06:27
@adamfaraj yes, because if you split a word on an empty space, it will just find one thing and puts it into an array. Hint: there is no need to split a second time. Just use bracket notation to access the first letter and concatenate the rest of the string with +
Adilzhan Izat
@JaxAdam
Jun 01 2017 06:30

@forkerino

switch(answer) {
  case "alpha":
  console.log(1);
  break;
  case "betta":
  console.log(2);
  break;
  case "gamma":
  console.log(3);
  break;
  case "delta":
  console.log(4);
        }

right?

Pieter Stokkink
@forkerino
Jun 01 2017 06:31
@JaxAdam the last one was closer. Just the thing inside the parentheses of your switch needed to change.
john94
@lpy1994
Jun 01 2017 06:31
@JaxAdam is this the first time doing switch statement?
Proconsul
@proconsu1
Jun 01 2017 06:32
@JaxAdam the switch line parameter should be the name of the variable you are testing against, not what you are doing if the test is true; and the case parameters should be possible values for that test variable
Adilzhan Izat
@JaxAdam
Jun 01 2017 06:32
@lpy1994 yes, of course
Farmerwan
@muntanui
Jun 01 2017 06:32
Hi all, really stuck on Stand In Line challenge, should I be using pop and push?
john94
@lpy1994
Jun 01 2017 06:33
@muntanui just push
Farmerwan
@muntanui
Jun 01 2017 06:33
OK, I'll give it a try, thank you
Adam Faraj
@adamfaraj
Jun 01 2017 06:33
@forkerino so this is what i have
// jshint esversion:6

function titleCase(str) {
  var x = str.split(' ');
  return (x[2].substring(0,1));


}

titleCase("I'm a little tea pot");
john94
@lpy1994
Jun 01 2017 06:33
@muntanui read the instruction buddy
Adam Faraj
@adamfaraj
Jun 01 2017 06:33
i really want to avoid a for loop
how do i access all the items of the array rather than using a random number like I have (2)
john94
@lpy1994
Jun 01 2017 06:34
@adamfaraj using map method is correct tho, just modify the side
Adam Faraj
@adamfaraj
Jun 01 2017 06:34
@lpy1994 the side?
john94
@lpy1994
Jun 01 2017 06:35
sorry inside
think about what does map method do.
Adam Faraj
@adamfaraj
Jun 01 2017 06:35
ohhhh
// jshint esversion:6

function titleCase(str) {
  var x = str.split(' ');
  var y = x.map(str => str.substring(0,1));
  return y;


}

titleCase("I'm a little tea pot");
john94
@lpy1994
Jun 01 2017 06:36
what do you need to do to just Capitalized the first word of each element
Adam Faraj
@adamfaraj
Jun 01 2017 06:36
holy shit. i got the first letter of each word
["I", "a", "l", "t", "p"]
that was the result
i got an array of strings
john94
@lpy1994
Jun 01 2017 06:38
@adamfaraj how to capitalized a string in code?
Adam Faraj
@adamfaraj
Jun 01 2017 06:38
toUpperCase()
Proconsul
@proconsu1
Jun 01 2017 06:38
@adamfaraj you specified in the substring arguments that you only wanted the first character of the string, or i think that is what that would do
Adam Faraj
@adamfaraj
Jun 01 2017 06:38
but how do I use the string method on an array
Sulaiman
@suli-g
Jun 01 2017 06:39
Good Morning everyone
Proconsul
@proconsu1
Jun 01 2017 06:39
@suli-g g'morning
john94
@lpy1994
Jun 01 2017 06:39
@adamfaraj each element in the array is string
Adam Faraj
@adamfaraj
Jun 01 2017 06:39
right
Proconsul
@proconsu1
Jun 01 2017 06:40
@adamfaraj you cannot mutate a string, so you will have to change them by some kind of assignment function
Adam Faraj
@adamfaraj
Jun 01 2017 06:40
@lpy1994 i really want to avoid a for loop. i really want to get into functional programming. not use a for loop for everything
john94
@lpy1994
Jun 01 2017 06:40
@adamfaraj map method is all you need, and something else
or you could use replace
Adam Faraj
@adamfaraj
Jun 01 2017 06:42
how about forEach()
i'm avoiding a for loop
but still iterating through each element of the array
Pieter Stokkink
@forkerino
Jun 01 2017 06:42
@adamfaraj .map is better in this case
Adam Faraj
@adamfaraj
Jun 01 2017 06:43
// jshint esversion:6

function titleCase(str) {
  var x = str.split(' ');
  var y = x.map(str => str.substring(0,1));
  var z = y.map(y => y.toUpperCase());


}

titleCase("I'm a little tea pot");
Adilzhan Izat
@JaxAdam
Jun 01 2017 06:44
function caseInSwitch(val) {
  var answer = "";
  switch(answer) {
  case 1:
  console.log("alpha");
  break;
  case 2:
  console.log("beta");
  break;
  case 3:
  console.log("gamma");
  break;
  case 4:
  console.log("delta");  
  return answer;  
}
}

caseInSwitch(1);
Where's my mistake?!
caseInSwitch(1) should have a value of "alpha"
caseInSwitch(2) should have a value of "beta"
caseInSwitch(3) should have a value of "gamma"
caseInSwitch(4) should have a value of "delta"
john94
@lpy1994
Jun 01 2017 06:44
@JaxAdam you need to use val
Adilzhan Izat
@JaxAdam
Jun 01 2017 06:44
@lpy1994 where?
@lpy1994 answer=val;?
john94
@lpy1994
Jun 01 2017 06:45
@lpy1994 you don't another variable
@JaxAdam
Sulaiman
@suli-g
Jun 01 2017 06:45

So I'm busy with the React RecipeBox project and I've been trying to work with the localStorage stuff but I can't seem to figure out how to use it.

Using the following method to store it:

let x = [{"a": [1,2]}, {"b": [2,3]}]
localStorage.setItem("SuliJee_recipes", JSON.stringify(x));

and this method to retrieve it:

let x = localStorage.getItem("SuliJee_recipes");
y = JSON.parse(y);

however, I'm met with the following error in Mozilla Firefox:

SyntaxError: JSON.parse: expected property name or '}' at line 1 column 2 of the JSON data
john94
@lpy1994
Jun 01 2017 06:46
@adamfaraj inside the map method, use replace method
@adamfaraj familiar with reg exp?
Sulaiman
@suli-g
Jun 01 2017 06:46
@JaxAdam you should use return instead of console.log for each case
Adilzhan Izat
@JaxAdam
Jun 01 2017 06:47
@lpy1994 I can't understand u. My eng is not ideal. Can u explain me how I need use val variable?
Adam Faraj
@adamfaraj
Jun 01 2017 06:47
@lpy1994 i am not
Pieter Stokkink
@forkerino
Jun 01 2017 06:47
@adamfaraj Just use one .map inside it return the first letter of the string capitalized concatenated (+) with a slice of the rest of the string
@JaxAdam switch(val)
Rick Willcox
@willcoxDev
Jun 01 2017 06:47

function telephoneCheck(str) {
  var regex = ["/\\d{3}-\\d{3}-\\d{4}/"];
  found = regex[0].test(str);
  console.log(found);

}

telephoneCheck("555-555-5555");
Cant figure out how to make a list of regex to match and then call one from that list before .test()
If I just put the rex before like this found = /\d{3}-\d{3}-\d{4}/.test(str); it works
Pieter Stokkink
@forkerino
Jun 01 2017 06:48
@willcoxDev Regexps are not strings, so they cannot have quotes around it.
Proconsul
@proconsu1
Jun 01 2017 06:48
@JaxAdam you are supposed to set the switch to test against the possible values of the 'val' variable. for each case, i.e. each potential value of 'val' you should be setting the answer variable equal to the assigned word, not logging that word to console
Rick Willcox
@willcoxDev
Jun 01 2017 06:48
so I just need to remove teh quotes
Adilzhan Izat
@JaxAdam
Jun 01 2017 06:48
@forkerino nothing changed
Rick Willcox
@willcoxDev
Jun 01 2017 06:49
before I pass it to the .test()
john94
@lpy1994
Jun 01 2017 06:49
@JaxAdam read the instruction plz
Adam Faraj
@adamfaraj
Jun 01 2017 06:49
@forkerino how do i access the first letter of the string in my array of strings
Pieter Stokkink
@forkerino
Jun 01 2017 06:49
@willcoxDev in your array, there should be no quotes around them.
Adilzhan Izat
@JaxAdam
Jun 01 2017 06:49
@lpy1994 Instructions
Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"
Pieter Stokkink
@forkerino
Jun 01 2017 06:50
@adamfaraj how about [0] on whatever parameter name you choose for the word?
word => word[0]....
@JaxAdam You changed answer = ... to console.log(...) change it back
wonder
@wonder2991
Jun 01 2017 06:51
answer = val @JaxAdam
Anshul Adlakha
@anshuladlakha
Jun 01 2017 06:52

function convertToRoman(num) {
var numbers=[1,5,10,50,100,500,1000];
var roman = ['I','V','X','L','C','D','M'];
  for(i=0;i<numbers.length;i++){
    if(num===numbers[i]){
      num = roman[i];
    }
  }
  return num;
}
Can anyone tell me what should i do next.
https://www.freecodecamp.com/challenges/roman-numeral-converter
Adilzhan Izat
@JaxAdam
Jun 01 2017 06:53
@forkerino caseInSwitch(4) should have a value of "delta" corrected! Thanks! But I need do next things:
caseInSwitch(1) should have a value of "alpha"
caseInSwitch(2) should have a value of "beta"
caseInSwitch(3) should have a value of "gamma"
CamperBot
@camperbot
Jun 01 2017 06:53
jaxadam sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2398 | @forkerino |http://www.freecodecamp.com/forkerino
Adilzhan Izat
@JaxAdam
Jun 01 2017 06:53
@wonder2991 not working.
function caseInSwitch(val) {
  var answer = "";
  switch(val) {
  case 1:
  answer = "alpha";
  break;
  case 2:
  answer = "beta";
  break;
  case 3:
  answer = "gamma";
  break;
  case 4:
  answer = "delta";  
  return answer;  
}
}

caseInSwitch(1);
Pieter Stokkink
@forkerino
Jun 01 2017 06:54
@JaxAdam the return should be outside the switch block
john94
@lpy1994
Jun 01 2017 06:54
@anshuladlakha what if num = 6
Anshul Adlakha
@anshuladlakha
Jun 01 2017 06:55
thats what i need help with, dont know where to go from here
Adilzhan Izat
@JaxAdam
Jun 01 2017 06:55
@forkerino omg!
30 minutes of pain and suffering! Thank you again!;D
CamperBot
@camperbot
Jun 01 2017 06:55
jaxadam sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:warning: jaxadam already gave forkerino points
Proconsul
@proconsu1
Jun 01 2017 06:55
@JaxAdam you appear to have accidentally changed code outside the exercise area. you might want to copy the code you wrote to the clipboard, reset the exercise, then paste your code back in
john94
@lpy1994
Jun 01 2017 06:57
@JaxAdam that is the process of learning how to code brother.
Adilzhan Izat
@JaxAdam
Jun 01 2017 06:57
@proconsu1 maybe..
I apologize if I'm in the way//..
Anshul Adlakha
@anshuladlakha
Jun 01 2017 06:58
Is it just me or are intermediate algorithm challenges actually tough?
Proconsul
@proconsu1
Jun 01 2017 06:58

@JaxAdam look at this: Before:

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

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

and now:

```
function caseInSwitch(val) {
  var answer = "";
  switch(val) {
  case 1:
  answer = "alpha";
  break;
  case 2:
  answer = "beta";
  break;
  case 3:
  answer = "gamma";
  break;
  case 4:
  answer = "delta";  
  return answer;  
}
}

caseInSwitch(1);

```
See how the exercise boundaries are now gone, mixing the prewritten code into your code. nothing to apologize for. happy to help.

Jerry5 Chang
@jerry5chang
Jun 01 2017 06:58
any idea for quiz#216
john94
@lpy1994
Jun 01 2017 06:59
@anshuladlakha are you new to js?
@anshuladlakha then yes.
Anshul Adlakha
@anshuladlakha
Jun 01 2017 06:59
@lpy1994 yeah i guess
Jerry5 Chang
@jerry5chang
Jun 01 2017 06:59
I have a dirty solution, could anyone can share your answer?
Markus Kiili
@Masd925
Jun 01 2017 07:00
@jerry5chang Tell the challenge name.
Jerry5 Chang
@jerry5chang
Jun 01 2017 07:00
function lookUpProfile(firstName, prop){
// Only change code below this line
  var index = 0;
  while(contacts[index].firstName !== firstName){
    index++;
    if(index >= contacts.length) break;
  }

  if(!contacts[index])
    return "No such contact";
  else
    return contacts[index][prop] ? contacts[index][prop] : "No such property";
// Only change code above this line
}
Profile Lookup
Markus Kiili
@Masd925
Jun 01 2017 07:01
@jerry5chang This is pretty standard:
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];
      }
      return "No such property";
    }
  }
  return "No such contact";
// Only change code above this line
}
john94
@lpy1994
Jun 01 2017 07:01
@anshuladlakha ```
 var lookup = {M:1000,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1}
this one is better for you to do.
Proconsul
@proconsu1
Jun 01 2017 07:02
that looks much like what i did on that lookup challenge
Anshul Adlakha
@anshuladlakha
Jun 01 2017 07:03
@lpy1994 shouldn't it be the other way around , i mean
1000:M?
Jerry5 Chang
@jerry5chang
Jun 01 2017 07:03
@Masd925 great! thanks!
CamperBot
@camperbot
Jun 01 2017 07:03
jerry5chang sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4175 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jun 01 2017 07:04
@lpy1994 I think two arrays is fine.
Proconsul
@proconsu1
Jun 01 2017 07:04
@jerry5chang
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i=0;i<contacts.length;i++){
  if (contacts[i].firstName==firstName){
    if (contacts[i].hasOwnProperty(prop)){
      return contacts[i][prop];
    } else {
      return "No such property";
    }
  }  
} return "No such contact";
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
john94
@lpy1994
Jun 01 2017 07:04
@Masd925 I like this one, much easier and clean
Jerry5 Chang
@jerry5chang
Jun 01 2017 07:04
how many quiz in this camp?
Markus Kiili
@Masd925
Jun 01 2017 07:04
@anshuladlakha You should put the largest number first.
zhouzhizhi
@zhouzhizhi
Jun 01 2017 07:05
wo te me kan bu dong ying wen zen me ban
john94
@lpy1994
Jun 01 2017 07:05
@zhouzhizhi na jiu qu freecodecamp zhong wen pin dao
Markus Kiili
@Masd925
Jun 01 2017 07:05
@lpy1994 Both ways store the information, but I think the solution becomes simpler with two arrays.
zhouzhizhi
@zhouzhizhi
Jun 01 2017 07:07
@lpy1994 daxiongdi wen de yi bi, guan jian wo jiu shi cong na li dian help dao zhe lai de
Markus Kiili
@Masd925
Jun 01 2017 07:07
@lpy1994 An object like that is also problematic, because object property iteration order is not guaranteed to be the insertion order.
john94
@lpy1994
Jun 01 2017 07:08
@zhouzhizhi 人家都说英文, 你来这没用呀
@Masd925 I thought less code is better
Grant Clark
@kwdzr3
Jun 01 2017 07:09
@DarrenfJ thanks for the helpful link https://watchandcode.com/p/practical-javascript
CamperBot
@camperbot
Jun 01 2017 07:09
kwdzr3 sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 1803 | @darrenfj |http://www.freecodecamp.com/darrenfj
zhouzhizhi
@zhouzhizhi
Jun 01 2017 07:09
@lpy1994 destroyer([1, 2, 3, 1, 2, 3], 2, 3) return [1, 1].
destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3) return [1, 5, 1].
destroyer([3, 5, 1, 2, 2], 2, 3, 5) return [1].
@lpy1994 大兄弟 不如你直接告诉我这道题怎么做吧
how can i do? everybody
Adam Faraj
@adamfaraj
Jun 01 2017 07:12
ugh
@forkerino
```
// jshint esversion:6

function titleCase(str) {
  var word = str.split(' ');
  var firstLetter = word.map((word) => word[0].toUpperCase());

}

titleCase("I'm a little tea pot");
john94
@lpy1994
Jun 01 2017 07:13
@zhouzhizhi 看给的链接
Adam Faraj
@adamfaraj
Jun 01 2017 07:13
@forkerino wait
haha, i forgot to return firstLetter
now i'm getting uppercases for all the first letters of the word
john94
@lpy1994
Jun 01 2017 07:14
arugment object filter 链接,
Adam Faraj
@adamfaraj
Jun 01 2017 07:14
cool
Markus Kiili
@Masd925
Jun 01 2017 07:15
@lpy1994 Clarity of the code is what matters the most. Code length also has some value. It is bad practice to rely on for...in loop to iterate properties in insertion order like you do there.
john94
@lpy1994
Jun 01 2017 07:15
@Masd925 thank you brother !
CamperBot
@camperbot
Jun 01 2017 07:15
lpy1994 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4176 | @masd925 |http://www.freecodecamp.com/masd925
Rick Willcox
@willcoxDev
Jun 01 2017 07:15
x
\(
Darren
@DarrenfJ
Jun 01 2017 07:16
@kwdzr3 thanks back atcha :D
CamperBot
@camperbot
Jun 01 2017 07:16
darrenfj sends brownie points to @kwdzr3 :sparkles: :thumbsup: :sparkles:
:cookie: 245 | @kwdzr3 |http://www.freecodecamp.com/kwdzr3
CapeTownCoder
@CapeTownCoder
Jun 01 2017 07:16

Hey guys, can anyone help me with the "Word Blanks" challange? I have no idea what i need to do. Curreently have: function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
myNoun="dog";
myAdjective="big";
myVerb="ran";
myAdverb="quickly";

// Your code above this line
return result;
}

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

Rick Willcox
@willcoxDev
Jun 01 2017 07:17
/```
Markus Kiili
@Masd925
Jun 01 2017 07:17
@CapeTownCoder You need to use the parameters myNoun, myAdjective, myVerb, myAdverb that hold the passed words, and some string operations and filler words to make a long sentence.
Alex
@Senius123
Jun 01 2017 07:18

hi all, help me plz
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));

nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
Rick Willcox
@willcoxDev
Jun 01 2017 07:18

you guys can format ur code with
/```

code here

/```

Markus Kiili
@Masd925
Jun 01 2017 07:18
@Senius123 Use two of the array methods you just learned and use them on arr and item as described.
Rick Willcox
@willcoxDev
Jun 01 2017 07:18
without the foward slash
Rosco verheij
@Jiehrev
Jun 01 2017 07:19
whats wrong with this ?
var myStr = "FirstLine\n\SecondLine\rThirdLine";
Revanth Kumar Reddy
@VoduruRevanth
Jun 01 2017 07:21
\ backslash
it should be \
"FirstLine\n\SecondLine\\rThirdLine"
Here it is showing only one backslash, actually it should be two @Jiehrev
Rick Willcox
@willcoxDev
Jun 01 2017 07:22
function telephoneCheck(str) {
  var regex = [/\d{3}[- ]\d{3}[- ]\d{4}/, /\(\d{3}\)\d{3}-\d{4}/, /\(\d{3}\) \d{3}-\d{4}/, /\d{10}/, /\d \d{3} \d{3} \d{4}/];


  for (var i=0; i< regex.length; i++){
    if (regex[0].test(str)){
      return true;
    }
  }

return false;
}

telephoneCheck("1 (555) 555-5555");

Ok so I have this returning true for some most things but it fails with this one even though I tested the expression in a regex thing online and it matched

I ahve tried both [(] and \(

Rosco verheij
@Jiehrev
Jun 01 2017 07:22
I put 2 backslashes its just not showing up in chat
and it still doesnt work
Proconsul
@proconsu1
Jun 01 2017 07:24
@Jiehrev try pasting your code using markdown, so it will faithfully show everything you did. (using triple backticks ```)
Rosco verheij
@Jiehrev
Jun 01 2017 07:24
okay
Alex
@Senius123
Jun 01 2017 07:25
@Masd925 I don`t understand :(((
Markus Kiili
@Masd925
Jun 01 2017 07:26
@Senius123 Which method Adds a number to the end of an array?
Rosco verheij
@Jiehrev
Jun 01 2017 07:26
"FirstLine\n\SecondLine\\rThirdLine";
Alex
@Senius123
Jun 01 2017 07:27
@Masd925 .push
Markus Kiili
@Masd925
Jun 01 2017 07:27
@Senius123 Use it to push item to arr.
Alex
@Senius123
Jun 01 2017 07:28
@Masd925 senks
Adam Faraj
@adamfaraj
Jun 01 2017 07:28
function titleCase(str) {
  var word = str.split(' ');
  var firstLetters = word.map((word) => word[0].toUpperCase());

}
how do take firstLetters and replace the old lowercase letters
Mark R. Baker
@mrbaker1917
Jun 01 2017 07:30

I am having trouble with one of only one of the tests for the Mutations CHallenge. Here is my code: function mutation(arr) {
var arrStr = arr[0].toLowerCase();
var array2 = arr[1].toLowerCase().split('');

for (var i = 0; i < arrStr.length; i++) {
return arrStr.indexOf(array2[i]) !== -1;
}
}
mutation(["hello", "hey"]);

Proconsul
@proconsu1
Jun 01 2017 07:30
@Jiehrev if you want a backslash to actually appear in a string, you need to escape it, so it becomes a double backslash. and remember, the instructions say you WANT backslashes to appear before and after SecondLine
Mark R. Baker
@mrbaker1917
Jun 01 2017 07:30
That test does not give a false return. I do not understand why.
Markus Kiili
@Masd925
Jun 01 2017 07:31
@adamfaraj Append the rest of the word lowercased to that uppercased first letter.
Rosco verheij
@Jiehrev
Jun 01 2017 07:32
@proconsu1 ah okay, thanks
CamperBot
@camperbot
Jun 01 2017 07:32
jiehrev sends brownie points to @proconsu1 :sparkles: :thumbsup: :sparkles:
:cookie: 150 | @proconsu1 |http://www.freecodecamp.com/proconsu1
Chris Juchtmans
@kjuchtmans
Jun 01 2017 07:34
good day coders :wave:
Proconsul
@proconsu1
Jun 01 2017 07:34
@kjuchtmans howdy ho
Adam Faraj
@adamfaraj
Jun 01 2017 07:34
how do I append @Masd925
Markus Kiili
@Masd925
Jun 01 2017 07:35
@adamfaraj You can use .concat() method or simpler + operator.
Adam Faraj
@adamfaraj
Jun 01 2017 07:36
i tried to concat. it returned the uppercase letters and the original string. not the replaced first letters with the new uppercase letters
Proconsul
@proconsu1
Jun 01 2017 07:36
trying to do chunky monkey, and trying really hard to find a solution that does not involve any for loops. is there a method or function that i can use to break the elements in a single array into subarrays of a specified length, without using a loop to iterate through the entire parent array?
Aizaz Shahid
@aizazshahid
Jun 01 2017 07:37
@adamfaraj strings are immutable, so you have to assign a new string to value or try to use .replace()
@Masd925 How are you ?
Adam Faraj
@adamfaraj
Jun 01 2017 07:38
i tried replace. i'm getting an error using replace @forwebtech
function titleCase(str) {
  var word = str.split(' ');
  var firstLetters = word.map((word) => word[0].toUpperCase());
  var newWords = word.replace(word[0], firstLetters);
  return newWords;

}
Markus Kiili
@Masd925
Jun 01 2017 07:38
@adamfaraj Just using + and slice is enough.
=> word[0].toUpperCase() + ...
Aizaz Shahid
@aizazshahid
Jun 01 2017 07:39
@adamfaraj word is not a string,
Markus Kiili
@Masd925
Jun 01 2017 07:39
@forwebtech It is.
Proconsul
@proconsu1
Jun 01 2017 07:39
@adamfaraj word is an array, but word[0] is a string
Aizaz Shahid
@aizazshahid
Jun 01 2017 07:39
@Masd925 it is an array !
Markus Kiili
@Masd925
Jun 01 2017 07:40
@forwebtech It is also the parameter of the map callback.
Aizaz Shahid
@aizazshahid
Jun 01 2017 07:40
@Masd925 @adamfaraj replace is bind with strings not arrays.
Markus Kiili
@Masd925
Jun 01 2017 07:40
@forwebtech Inside the map callback, word holds a string.
Aizaz Shahid
@aizazshahid
Jun 01 2017 07:40
@Masd925 he is using that outside the map:
var newWords = word.replace(word[0], firstLetters);
Proconsul
@proconsu1
Jun 01 2017 07:41
@adamfaraj remember, you are trying to change the elements inside the array, not the array itself. and in your case all the elements are strings
Markus Kiili
@Masd925
Jun 01 2017 07:41
@forwebtech Yeah, that is a problem.
Aizaz Shahid
@aizazshahid
Jun 01 2017 07:41
@proconsu1 sir, i know that ! i am telling him same
Revanth Kumar Reddy
@VoduruRevanth
Jun 01 2017 07:41
Guys I am getting error,
Proconsul
@proconsu1
Jun 01 2017 07:41
@forwebtech i know. just trying to put it in different words since he seemed not to understand yet
Revanth Kumar Reddy
@VoduruRevanth
Jun 01 2017 07:42
I assigned, myStr = "Hello World";
Markus Kiili
@Masd925
Jun 01 2017 07:42
@adamfaraj Using replace is a bad idea here.
ozimanik
@ozimanik
Jun 01 2017 07:42
Kopf schrott, Mon ami
Proconsul
@proconsu1
Jun 01 2017 07:42
@forwebtech sorry, just now noticed i mis addressed that earlier on. derp
Aizaz Shahid
@aizazshahid
Jun 01 2017 07:43
@proconsu1 its ok !
Revanth Kumar Reddy
@VoduruRevanth
Jun 01 2017 07:43
But still I am getting error ==> TypeError: Cannot assign to read only property '0' of string 'Hello World'
Aizaz Shahid
@aizazshahid
Jun 01 2017 07:43
@VoduruRevanth paste the complete code !
Revanth Kumar Reddy
@VoduruRevanth
Jun 01 2017 07:43

var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World";

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

Sandeep Roy
@sandeeproy
Jun 01 2017 07:43
Revanth Kumar Reddy
@VoduruRevanth
Jun 01 2017 07:43
@forwebtech
Adam Faraj
@adamfaraj
Jun 01 2017 07:44
@proconsu1 so how do i change the elements inside the array?
Aizaz Shahid
@aizazshahid
Jun 01 2017 07:44
@VoduruRevanth you need to change the line where // Fix me is commented, as strings are immutable that means their parts can't be change but whole string can. So remove the [0] notation and then check it.
Adam Faraj
@adamfaraj
Jun 01 2017 07:44
map again?
Markus Kiili
@Masd925
Jun 01 2017 07:45
@adamfaraj You are changing each array element (word) with that map. Just figure out what to do on the map callback.
Aizaz Shahid
@aizazshahid
Jun 01 2017 07:45
@adamfaraj you don't need double iterations it can be possible with one .
Revanth Kumar Reddy
@VoduruRevanth
Jun 01 2017 07:45
@forwebtech :ok:
Adam Faraj
@adamfaraj
Jun 01 2017 07:45
is that not what i'm doing here?
var firstLetters = word.map((word) => word[0].toUpperCase());
Markus Kiili
@Masd925
Jun 01 2017 07:46
@adamfaraj => word[0].toUpperCase() + ... <- stuff here
Chris Juchtmans
@kjuchtmans
Jun 01 2017 07:46

"Local Weather App"

are my variables latitude and longitude used out of scope, when I construct the query string ?
console is not logging anything for url, though lat and long log fine

my code :

$(function() {
    var latitude;
    var longitude;
    var key;
    var url;
    var html;
    var localWeather;

    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(function(position) {
        latitude = position.coords.latitude;
        longitude = position.coords.longitude;
            console.log(latitude, longitude);

            function loadWeather(latitude, longitude) {
            key = "db3b51064d81f6b3f34af03e9749f4df";
            url = "https://crossorigin.me/https://api.darksky.net/forecast/" + key + "/" + latitude + "," + longitude + "?exclude=[minutely,hourly,daily,alerts,flags]";    
                console.log(url);

            $.getJSON(url, function(json){});
            }            
        });
    };    
});
Aizaz Shahid
@aizazshahid
Jun 01 2017 07:46
@adamfaraj as strings are immutable, so you are changing the part of a string, that can't be possible directly, just concat it with the other letters as @Masd925 suggested.
Markus Kiili
@Masd925
Jun 01 2017 07:47
@adamfaraj You can use .slice() and .toLowerCase() to get the rest of the string lowercased.
That way you can form the titlecased word.
Proconsul
@proconsu1
Jun 01 2017 07:47
@kjuchtmans that is a bit beyond my skill level, but since you declared those var inside the function, should they not be invisible outside that function's scope?
(if they aren't then I am looking forward to learning why not! :-) )
Markus Kiili
@Masd925
Jun 01 2017 07:49
@adamfaraj word[0].toUpperCase() only gets the first character uppercased. So you are mapping "cat" -> "C" there.
Chris Juchtmans
@kjuchtmans
Jun 01 2017 07:49
@proconsu1 yeah, that why I attempt to declare them right at the start, so they're known throughout the code that follows. Doesnt that seem fair?
Aizaz Shahid
@aizazshahid
Jun 01 2017 07:50
@kjuchtmans you can use them inside the callback method but if you assign them with some value, that will only available in that callback scope.
Alex
@Senius123
Jun 01 2017 07:51

I`m stuck.... Help me please
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));

nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
Chris Juchtmans
@kjuchtmans
Jun 01 2017 07:51
@forwebtech So I am making an out of scope error here?
Aizaz Shahid
@aizazshahid
Jun 01 2017 07:51
@Senius123 you need to add the item to arr and then remove the first element with also returning it.
@kjuchtmans i don't think so, it should work in nested one.
@kjuchtmans
var str;
foo( callbackmethod({
    str = "testing";

 { 
   console.log(str);  // testing
}
}) );
   console.log(str);  // undefined
Markus Kiili
@Masd925
Jun 01 2017 07:54
@kjuchtmans Are you using the loadWeather function somewhere?
Alex
@Senius123
Jun 01 2017 07:54
@forwebtech how? (
Aizaz Shahid
@aizazshahid
Jun 01 2017 07:55
@Senius123 check mdn.io/push and mdn.io/shift
Proconsul
@proconsu1
Jun 01 2017 07:55
@Senius123 you might look in the .push and .shift methods
Chris Juchtmans
@kjuchtmans
Jun 01 2017 07:55
@Masd925 no I aren't. that the issue, right? it's been declared, but never called
Proconsul
@proconsu1
Jun 01 2017 07:55
emu'd
Adam Faraj
@adamfaraj
Jun 01 2017 07:55
@Masd925 how do i splice a string within the array? i thought splice was used to get rid of elements within the array
Markus Kiili
@Masd925
Jun 01 2017 07:55
@kjuchtmans Yes.
Aizaz Shahid
@aizazshahid
Jun 01 2017 07:55
@kjuchtmans remember that function can only be called in that callback.
Chris Juchtmans
@kjuchtmans
Jun 01 2017 07:56
@Masd925 fair enough. silly mistake thanks. @forwebtech indeed sir, will keep that in mind, thank you
CamperBot
@camperbot
Jun 01 2017 07:56
kjuchtmans sends brownie points to @masd925 and @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 638 | @forwebtech |http://www.freecodecamp.com/forwebtech
:star2: 4177 | @masd925 |http://www.freecodecamp.com/masd925
Alex
@Senius123
Jun 01 2017 07:56
@forwebtech senks
Will Waymel
@willwaymel
Jun 01 2017 07:56
hey all! am I crazy, or should this return false? I think there may be a bug in this challenge because it keeps returning the json collection for the Record Collection Alorithym challenge
// Only change code below this line
function updateRecords(id, prop, value) {


  return false;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Adam Faraj
@adamfaraj
Jun 01 2017 07:56
// jshint esversion:6

function titleCase(str) {
  var word = str.split(' ');

//   var firstLetters = word.map((word) => word[0].toUpperCase() + word);
  return word;

}

titleCase("I'm a little tea pot");
Aizaz Shahid
@aizazshahid
Jun 01 2017 07:56
:+1:
Markus Kiili
@Masd925
Jun 01 2017 07:56
@adamfaraj You need to do this to the map callback parameter word:
var str = "cat";
str[0].toUpperCase()+str.slice(1).toLowerCase(); // 'Cat'
Will Waymel
@willwaymel
Jun 01 2017 07:57
originally the code was
// Only change code below this line
function updateRecords(id, prop, value) {


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Markus Kiili
@Masd925
Jun 01 2017 07:57
@adamfaraj word.map((word) => word[0].toUpperCase()+...);
Aizaz Shahid
@aizazshahid
Jun 01 2017 07:58
@willwaymel that method will modify the new Copied collection which is already done for you, above of that function so do that as per the instructions and also check what to return.
Will Waymel
@willwaymel
Jun 01 2017 07:59
@forwebtech I'm confused... what do you mean?
Adam Faraj
@adamfaraj
Jun 01 2017 07:59
jesus
Will Waymel
@willwaymel
Jun 01 2017 07:59
@forwebtech I'm just saying that when I modify the function, for example, to return anything other than the collection, the output in the console is always the same collection
Adam Faraj
@adamfaraj
Jun 01 2017 07:59
slice vs splice
that makes that so much easier
thanks @Masd925
CamperBot
@camperbot
Jun 01 2017 08:00
adamfaraj sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4178 | @masd925 |http://www.freecodecamp.com/masd925
Adam Faraj
@adamfaraj
Jun 01 2017 08:01
worked!!
// jshint esversion:6

function titleCase(str) {
  var word = str.split(' ');
  var firstLetters = word.map((word) => word[0].toUpperCase() + word.slice(1).toLowerCase());
  var joined = firstLetters.join(' ');
  return joined;
}

titleCase("I'm a little tea pot");
Aizaz Shahid
@aizazshahid
Jun 01 2017 08:01
@willwaymel well check in the code there is console.log() their.
Proconsul
@proconsu1
Jun 01 2017 08:02
@adamfaraj nice one! :+1: mine was far cludgier when i did that exercise
Adam Faraj
@adamfaraj
Jun 01 2017 08:02
thanks @proconsu1
CamperBot
@camperbot
Jun 01 2017 08:02
adamfaraj sends brownie points to @proconsu1 :sparkles: :thumbsup: :sparkles:
:cookie: 151 | @proconsu1 |http://www.freecodecamp.com/proconsu1
Adam Faraj
@adamfaraj
Jun 01 2017 08:02
and @forwebtech thank you
Will Waymel
@willwaymel
Jun 01 2017 08:03

this

function updateRecords(id, prop, value) {
  //if exists function --
  console.log("falsy");
  return false;
}

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

still gives me entire collection in the console log

Rick Willcox
@willcoxDev
Jun 01 2017 08:03
can anyone give me some help here
I have got ti mostly working
just some cases are still returning true
Proconsul
@proconsu1
Jun 01 2017 08:05
@willwaymel what is the name of that exercise?
Mark R. Baker
@mrbaker1917
Jun 01 2017 08:05
@willwaymel Hello. What do you use to get that nice screen shot?
Will Waymel
@willwaymel
Jun 01 2017 08:05
@proconsu1 Record Collection
@mrbaker1917 type /then hit shift+enter , then paste your code, then shift+enter and /
sorry @mrbaker1917 , type ``` ... those got coded out
Mark R. Baker
@mrbaker1917
Jun 01 2017 08:08
Sorry, where would I type this?
Will Waymel
@willwaymel
Jun 01 2017 08:08
lol... damn .... can't get them to appear
where you are typing right now
your code needs to be encapsulated in the ``` @mrbaker1917
Aizaz Shahid
@aizazshahid
Jun 01 2017 08:09
@mrbaker1917
```
put your code here
```
Will Waymel
@willwaymel
Jun 01 2017 08:09
@forwebtech lol thank you
CamperBot
@camperbot
Jun 01 2017 08:09
willwaymel sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 639 | @forwebtech |http://www.freecodecamp.com/forwebtech
Rick Willcox
@willcoxDev
Jun 01 2017 08:10
alos 1 line of code can be done just by putting 1 backtick before and after the code
eg code in there
sanaullahhaifz
@sanaullahhaifz
Jun 01 2017 08:12
Hi Guys, can anyone help me out here .... I am stuck in the Golf Code challenge. can any one give me the answer ?
Chris Juchtmans
@kjuchtmans
Jun 01 2017 08:12

"Local weather app"
Something is still amiss with my loadWeather function, but what?

It will not contatenate the correct values of latitudeand longitude. Console logs them instead as undefined inside the query string.

    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(function(position) {
        var latitude = position.coords.latitude;
        var longitude = position.coords.longitude;
            console.log(latitude, longitude);

            function loadWeather(latitude, longitude) {
            var key = "db3b51064d81f6b3f34af03e9749f4df";
            var url = "https://crossorigin.me/https://api.darksky.net/forecast/" + key + "/" + latitude + "," + longitude + "?exclude=[minutely,hourly,daily,alerts,flags]";    
                $("#geodata").html("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);
                $.getJSON(url, function(json){});
            }            
            loadWeather();
            console.log(url);
        });
    }
Will Waymel
@willwaymel
Jun 01 2017 08:13
@willcoxDev which one is true that should be false?
Aizaz Shahid
@aizazshahid
Jun 01 2017 08:13
@kjuchtmans because you did not pass the latitude and longitude as arguments.
Proconsul
@proconsu1
Jun 01 2017 08:13
@willwaymel you stumped me there. it might be that the script for the exercise itself is off the rails. you might wanna copy your code out to an external editor then reset the exercise
Mark R. Baker
@mrbaker1917
Jun 01 2017 08:14
function mutation(arr) {
  var arrStr = arr[0].toLowerCase();
  var array2 = arr[1].toLowerCase().split('');

 for (var i = 0; i < array2.length; i++) {
  if (arrStr.indexOf(array2[i]) === -1) {
      return false;
   } else {
     return true;
   }
   }
}
mutation(["hello", "HeLlo"]);
Chris Juchtmans
@kjuchtmans
Jun 01 2017 08:14
@forwebtech you mean right here loadWeather(); ?
Aizaz Shahid
@aizazshahid
Jun 01 2017 08:14
@kjuchtmans yes !
Will Waymel
@willwaymel
Jun 01 2017 08:14
@proconsu1 ok thanks. I just did that... still didn't work
CamperBot
@camperbot
Jun 01 2017 08:14
willwaymel sends brownie points to @proconsu1 :sparkles: :thumbsup: :sparkles:
:cookie: 152 | @proconsu1 |http://www.freecodecamp.com/proconsu1
Aizaz Shahid
@aizazshahid
Jun 01 2017 08:15
@kjuchtmans as function loadWeather(latitude, longitude), parameters are used there, so you need to pass them when calling.
Mark R. Baker
@mrbaker1917
Jun 01 2017 08:15
Can any one help me figure this out? It passes all tests but the first one: mutation(["hello", "hey"]);
Ogundele Olumide
@Lumexralph
Jun 01 2017 08:15
@mrbaker1917 you should return true when the loop is done looking through the array2 elements
Proconsul
@proconsu1
Jun 01 2017 08:15
@willwaymel i have never noticed an exercise logging info to the console, but that is the only other possibility i can think of, since your code obviously shouldnt be doing it
Ogundele Olumide
@Lumexralph
Jun 01 2017 08:15
@mrbaker1917 meaning after the loop
Will Waymel
@willwaymel
Jun 01 2017 08:16
@proconsu1 I tried adding my own new function and calling it and nothing happens
Chris Juchtmans
@kjuchtmans
Jun 01 2017 08:16
@forwebtech that makes perfect sense sir
Mark R. Baker
@mrbaker1917
Jun 01 2017 08:17
@Lumexralph Thanks, but why true? I mean, it need it to return false when there is no match, which in indexOf is -1
CamperBot
@camperbot
Jun 01 2017 08:17
mrbaker1917 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1856 | @lumexralph |http://www.freecodecamp.com/lumexralph
Chris Juchtmans
@kjuchtmans
Jun 01 2017 08:19
@forwebtech آپ کا شکریہ (is as far as my Urdu reaches)
Aizaz Shahid
@aizazshahid
Jun 01 2017 08:20
@kjuchtmans

بہت اچھے اردو جانتے ہو ؟