2nd
Apr 2016
Novacane337
@Novacane337
Apr 02 2016 00:01
@tupelo87 So you di d something like that for (i=0; i < arr.length; i++) { for (j=0; j < arr[1].length; j++) { product= product * arr[i][j]; } }
tupelo87
@tupelo87
Apr 02 2016 00:01
yes
Matthew Fricker
@mattfricker
Apr 02 2016 00:02
@ManBearPigg I think it is worth considering whether it needs to be in string form in the first place. eval could be harmful if you are evaluating a string input by a user - because what if that string was malicious code?
@swimrr Any time
tupelo87
@tupelo87
Apr 02 2016 00:04
ahh sorry you need arr[i] i can barely read the text that this chat is using the
you have arr[1] just change the 1 to i and you should be fine
Novacane337
@Novacane337
Apr 02 2016 00:06
oooh ook that's why I'm stuck
tupelo87
@tupelo87
Apr 02 2016 00:06
the i just tells it where to look in the array from the first loop i think as j is another array someone can correct that if i am wrong
Novacane337
@Novacane337
Apr 02 2016 00:07
Yes i think you're right, i was focus on the last part but my mistakes was here
thanks @tupelo87
CamperBot
@camperbot
Apr 02 2016 00:07
novacane337 sends brownie points to @tupelo87 :sparkles: :thumbsup: :sparkles:
:star: 229 | @tupelo87 | http://www.freecodecamp.com/tupelo87
tupelo87
@tupelo87
Apr 02 2016 00:08
yw and now i need to go sleep its 1 am here
Novacane337
@Novacane337
Apr 02 2016 00:09
2 am here haha
bitgrower
@bitgrower
Apr 02 2016 00:15

thanks again @mattfricker @mattxgreen !!! I've got some of my crushed self esteem back...

awesome ... I love that when that happens ... congrats, @swimrr

CamperBot
@camperbot
Apr 02 2016 00:15
bitgrower sends brownie points to @mattfricker and @mattxgreen and @swimrr :sparkles: :thumbsup: :sparkles:
:star: 441 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
:star: 76 | @mattfricker | http://www.freecodecamp.com/mattfricker
:star: 187 | @swimrr | http://www.freecodecamp.com/swimrr
Apr 02 2016 00:19
@BKinahan Thanks! I just solved the challenge you helped me with this afternoon
CamperBot
@camperbot
Apr 02 2016 00:19
yadesesan sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1220 | @bkinahan | http://www.freecodecamp.com/bkinahan
Arnaud Casamé
@arnaudcasame
Apr 02 2016 00:24
Help sorted union
CamperBot
@camperbot
Apr 02 2016 00:24
no wiki entry for: sorted union
Ghost
@ghost~56c29796e610378809c19d77
Apr 02 2016 00:28
Hey Guys, Can Anyone please help me here. I want use javaScript to open links with window.loaction. how do I add This "target='_blank"??
Brandon Lee
@brandonlee781
Apr 02 2016 00:31
@MajorTank If you're using jQuery you can use the .attr() function: http://api.jquery.com/attr/

So I just completed the Smallest Common Multiple algorithm, I used the following code:

// noprotect
function sortArr(arr) {
arr.sort(function(a,b){
return a-b;
});
}
function smallestCommons(arr) {
sortArr(arr);
var range = [];
var multiples = [];
var x = 0;
//use the array to create a range of numbers
for (var i = arr[0];i<=arr[1];i++) {
range.push(i);
}
//create a new array with all the multiples of all the numbers in the range
for (var j = 1;j < range.length;j++) {
for (var k = 1;k < 190000;k++) {
multiples.push(range[j] * k);
}
}
sortArr(multiples);
//filter out all values that don't repeat
multiples = multiples.filter(function(item, pos, ary) {
if (item == ary[pos - 1]){x += 1;} else {x=0;}
if (x == range.length-2) {return item;}
});
return multiples[0];
}
smallestCommons([1,13]);

There has to be a smarter way than calculating out almost 3 million values and then searching for the correct one? Does anyone know of a better, simpler, less resource intensive way?

Diego Mayer
@Chrono79
Apr 02 2016 00:37
@brandonlee781 check this:
function smallestCommons(arr) {
if (arr[1]-arr[0] === 1 || arr[1]-arr[0] === -1) return arr[1]*arr[0]; // trivial case, 2 consecutive numbers
else {
arr.sort(function(a,b){  // sort the array, arr[0]<arr[1]
return a - b;
});
var loop = true;
var candidateSCM = arr[1]*(arr[1]-1); // first candidate is the maximum*(maximum - 1)
var count = 0; // a counter value
while (loop) {
for (var i = arr[1]-2; i>= arr[0]; i--) {
if (candidateSCM % i === 0) count++;
else break;
}
if (count === arr[1]-arr[0]-1) { // is a SCM
loop = false;
return candidateSCM;
} else {
count = 0; // reset counter
candidateSCM += arr[1]*(arr[1]-1); // the SCM is a multiple of this, so we try with the next one
}
}
}
}

smallestCommons([5,1]);
Ramana Venkata
@vramana
Apr 02 2016 00:37
@brandonlee781 PM me.
Jose Reyna
@Jer1986
Apr 02 2016 00:39
I am trying to find the longest word in a string. I have split the string but I am stuck on how to sort the string from largest to smallest word. Below is my code

function findLongestWord(str) {
var newStr = str.split(" ");
var astring = newStr.sort(function(a,b){
return b-a;
});
return bstring[0].length;
}

findLongestWord("The quick brown fox jumped over the lazy dog");

Ghost
@ghost~56c29796e610378809c19d77
Apr 02 2016 00:39
Thanks @brandonlee781 !!
CamperBot
@camperbot
Apr 02 2016 00:39
majortank sends brownie points to @brandonlee781 :sparkles: :thumbsup: :sparkles:
:star: 305 | @brandonlee781 | http://www.freecodecamp.com/brandonlee781
Moisés Man
@moigithub
Apr 02 2016 00:46
@Jer1986 do u know how to use console.log() ??
what values have a,b
Jose Reyna
@Jer1986
Apr 02 2016 00:48
@moigithub yes, I am using console.log() however it's only sorting my strings alphabetically.
Moisés Man
@moigithub
Apr 02 2016 00:48
sooo what values have a,b ?
Clare Dickerson
@claredickerson
Apr 02 2016 00:48

HEY! For this exercise:
if (condition1) {
statement1
} else if (condition2) {
statement2
} else if (condition3) {
statement3
. . .
} else {
statementN
}

...how am I supposed to format the statements?

I've tried a number of ways but they all feel (and are) incorrect.
Jose Reyna
@Jer1986
Apr 02 2016 00:50
That's a good question I thought that I could use that function to sort my strings in ascending order.
Moisés Man
@moigithub
Apr 02 2016 00:50
u can... but u should know whats a,b :P
n only way to know is using console.log... if u add it to ur code u will know ... probably
Jose Reyna
@Jer1986
Apr 02 2016 00:53
It's returning the first two words of each sentence
Moisés Man
@moigithub
Apr 02 2016 00:54
so... u doing
"word1" - "word2"
if u put that.. on console.. it will return NaN
cuz u cant minus strings
but.. if u use .length... on a,b
Jose Reyna
@Jer1986
Apr 02 2016 00:55
True! oh boy!
Jose Reyna
@Jer1986
Apr 02 2016 01:00
@moigithub Thank you! I feel like I am a little closer
CamperBot
@camperbot
Apr 02 2016 01:00
jer1986 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 811 | @moigithub | http://www.freecodecamp.com/moigithub
Josh Bivens
@joshbivens
Apr 02 2016 01:11
I have a question about new Dates.
After I subtract 24 from my ...getHours() it's showing that it's 5, however it's actually 7 here. Are new Dates in a timezone?
ManBearPigg
@ManBearPigg
Apr 02 2016 01:16
@mattfricker Thanks for bringing that up. I have never had to think about malicious code before. That’s very interesting. It is user input, but fortunately, it’s from a button click on a calculator. They don’t have enough tools I don’t think to input anything problematic
CamperBot
@camperbot
Apr 02 2016 01:16
manbearpigg sends brownie points to @mattfricker :sparkles: :thumbsup: :sparkles:
:star: 78 | @mattfricker | http://www.freecodecamp.com/mattfricker
Paul Borawski
@iAmNawa
Apr 02 2016 01:20
It’s a @ManBearPigg
Ramana Venkata
@vramana
Apr 02 2016 01:22
@joshbivens Can you repharse your question??
Paul Borawski
@iAmNawa
Apr 02 2016 01:26
@joshbivens That means your computer thinks it’s a different time
@joshbivens go to your terminal and type in date
Josh Bivens
@joshbivens
Apr 02 2016 01:36
@iAmNawa Yep, 19:35. So five, but again it's 7 here.
Paul Borawski
@iAmNawa
Apr 02 2016 01:38
19:35 is 7
it’s 7:35
12 + 7 = 19
@joshbivens
Josh Bivens
@joshbivens
Apr 02 2016 01:39
@iAmNawa Oh jesus! Thank you @iAmNawa
CamperBot
@camperbot
Apr 02 2016 01:39
joshbivens sends brownie points to @iamnawa :sparkles: :thumbsup: :sparkles:
:star: 311 | @iamnawa | http://www.freecodecamp.com/iamnawa
Paul Borawski
@iAmNawa
Apr 02 2016 01:41
no problem @joshbivens
parvinder30
@parvinder30
Apr 02 2016 01:45
Hey Guzz.
I want to know that for a beginner what kind of a book is Head first JavaScript.
Should I go For it or for Eloquent Javascript...??
Juho Karenko
@jkarenko
Apr 02 2016 01:47
@parvinder30 I've read the Java version of Head first... It was entertaining and kind of trying to hammer the info in your head by repetition and simplification. Not totally sure it was worth it or if I even learned very much from it as a complete beginner.
Then again, I probably wouldn't fared any better with any other book either.
parvinder30
@parvinder30
Apr 02 2016 01:48
And what about Eloquent JavaScript
Juho Karenko
@jkarenko
Apr 02 2016 01:50
no idea... it's free to read online, so I'd probably start with that. :)
parvinder30
@parvinder30
Apr 02 2016 01:50
Fine :D
Josh Bivens
@joshbivens
Apr 02 2016 02:02
Hey guys
If given a number that ticks down(1500, 1499, 1498, and so on), how can I find what percent is and recalculate it every tick?
Matthew Fricker
@mattfricker
Apr 02 2016 02:05
@joshbivens Do you mean the percent as in 150 would be 10% of 1500?
Josh Bivens
@joshbivens
Apr 02 2016 02:05
I'm trying to effect the width of a div based on the time value of a countdown timer.
AhmedHamid11
@AhmedHamid11
Apr 02 2016 02:06
I am stuck on record collection. How do I update or set a value in a json object?
Josh Bivens
@joshbivens
Apr 02 2016 02:06
With brackets [] @AhmedHamid11
Matthew Fricker
@mattfricker
Apr 02 2016 02:06

@joshbivens so if the startNumber is 1500, store that in var startNumber and store the counter in curNumber.

Get the percent from curNumber / startNumber * 100

Josh Bivens
@joshbivens
Apr 02 2016 02:07
Ah ok...lemme try it @mattfricker
Or literally with . notation @AhmedHamid11
AhmedHamid11
@AhmedHamid11
Apr 02 2016 02:08
literal notion does not seem to work for setting. I changed it to bracket notation and it totally worked. Thank you Josh
@joshbivens THANKS!
CamperBot
@camperbot
Apr 02 2016 02:08
ahmedhamid11 sends brownie points to @joshbivens :sparkles: :thumbsup: :sparkles:
:star: 334 | @joshbivens | http://www.freecodecamp.com/joshbivens
Josh Bivens
@joshbivens
Apr 02 2016 02:10
@AhmedHamid11 :thumbsup:
@mattfricker Thank you so much. I don't math so good.
CamperBot
@camperbot
Apr 02 2016 02:11
joshbivens sends brownie points to @mattfricker :sparkles: :thumbsup: :sparkles:
:star: 79 | @mattfricker | http://www.freecodecamp.com/mattfricker
Matthew Fricker
@mattfricker
Apr 02 2016 02:11
@joshbivens any time - did it work?
Paul Borawski
@iAmNawa
Apr 02 2016 02:13
if you link to jquery from google’s library, it would be much faster than if you upload it to your own site?
I thought putting it on your own server is the fastest
Matthew Fricker
@mattfricker
Apr 02 2016 02:15
@iAmNawa It depends - if the server hosting your site is in California, but the user is in Australia - it is better to use a CDN (Content Delivery Network) that has servers all over the world.
Paul Borawski
@iAmNawa
Apr 02 2016 02:16
Ok that makes sense @mattfricker thanks!
CamperBot
@camperbot
Apr 02 2016 02:16
iamnawa sends brownie points to @mattfricker :sparkles: :thumbsup: :sparkles:
:star: 80 | @mattfricker | http://www.freecodecamp.com/mattfricker
Matthew Fricker
@mattfricker
Apr 02 2016 02:16
@iAmNawa sure, no problem
Josh Bivens
@joshbivens
Apr 02 2016 02:16
@mattfricker Yep totally
joshuaakulp
@joshuaakulp
Apr 02 2016 02:17
Hi all, working on "Introducing JSON", first one is to add a second album to the current JSON object. My code is not working, can someone take a look? I'm not sure how to get my code here other than copy/paste.
Josh Bivens
@joshbivens
Apr 02 2016 02:17
@mattfricker I'm doing the Pomodoro thing again for fun in Vue, but this time I'm adding a progress bar...well, time left bar.
Paul Borawski
@iAmNawa
Apr 02 2016 02:18
@josh type three back ticks and press enter, then paste the code inbetween them. then press command enter to send
@joshuaakulp
joshuaakulp
@joshuaakulp
Apr 02 2016 02:18
\\
Paul Borawski
@iAmNawa
Apr 02 2016 02:18

those ones
joshuaakulp
@joshuaakulp
Apr 02 2016 02:18
woops
Paul Borawski
@iAmNawa
Apr 02 2016 02:18
three of them
Matthew Fricker
@mattfricker
Apr 02 2016 02:19
@joshbivens That is cool - I have never used Vue but I listened to JavaScript Air from this week and it was all about it
Paul Borawski
@iAmNawa
Apr 02 2016 02:19
@mattfricker I like JavaScript Jabber a little more
Josh Bivens
@joshbivens
Apr 02 2016 02:19
This message was deleted
joshuaakulp
@joshuaakulp
Apr 02 2016 02:19
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];
myMusic[1] = [
{
"title": "Material Girl",
"release year": 1981,
"formats": [
"CS",
"8T",
"LP" ],
"gold": false
}
];
Josh Bivens
@joshbivens
Apr 02 2016 02:19
@mattfricker It's so cool!
joshuaakulp
@joshuaakulp
Apr 02 2016 02:20
Thanks @joshbivens & @iAmNawa
CamperBot
@camperbot
Apr 02 2016 02:20
joshuaakulp sends brownie points to @joshbivens and @iamnawa :sparkles: :thumbsup: :sparkles:
:star: 335 | @joshbivens | http://www.freecodecamp.com/joshbivens
:star: 314 | @iamnawa | http://www.freecodecamp.com/iamnawa
Josh Bivens
@joshbivens
Apr 02 2016 02:20
@joshuaakulp :thumbsup:
Paul Borawski
@iAmNawa
Apr 02 2016 02:20
@joshuaakulp declare a new variable
Matthew Fricker
@mattfricker
Apr 02 2016 02:20
@iAmNawa I listen to them both, not really a huge fan of the episodes all about specific frameworks though
Paul Borawski
@iAmNawa
Apr 02 2016 02:21
you are trying to over write the 2nd part of the first array
like type var myMusic2 = [
joshuaakulp
@joshuaakulp
Apr 02 2016 02:22
I believe I am supposed to be adding the second object to be in the same array.
Maybe not
Paul Borawski
@iAmNawa
Apr 02 2016 02:23
What;s the exercise called? I can look back on my answer to that one @joshuaakulp
joshuaakulp
@joshuaakulp
Apr 02 2016 02:23
Introducing JavaScript Object Notation JSON
Arjun Narayanan
@anarayanan86
Apr 02 2016 02:23
hey guys, i just wanted to know if im using the arguments object correctly here
this is part of the "seek and destroy" challenge
function destroyer(arr) {
// Remove all the values
var destroyed = [];
var a = arr[0];
for (i = 1; i < arguments.length; i++) {
for (j = 0; j < a.length; j++) {
if (arguments[i] == a[j]) {
destroyed.push(a[j]);
}
}
}
return destroyed;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Paul Borawski
@iAmNawa
Apr 02 2016 02:25
@joshuaakulp
Arjun Narayanan
@anarayanan86
Apr 02 2016 02:25
im guessing the numbers 2 and 3 in the array below would be arguments[1] and arguments[2]
Paul Borawski
@iAmNawa
Apr 02 2016 02:25
"gold": true
},
{
"artist": "Flume",
just a comma and then start the next object
joshuaakulp
@joshuaakulp
Apr 02 2016 02:26
@iAmNawa So the comma is separating the two objects.
Paul Borawski
@iAmNawa
Apr 02 2016 02:27
correct
I didn’t knnow what to say before because I didn’t know what you were trying to accomplish
ManBearPigg
@ManBearPigg
Apr 02 2016 02:27
@anarayanan86 Try this var args = Array.prototype.slice.call(arguments);
joshuaakulp
@joshuaakulp
Apr 02 2016 02:28
The Note they have in the exercise makes more sense now as well. Thanks @iAmNawa !
CamperBot
@camperbot
Apr 02 2016 02:28
joshuaakulp sends brownie points to @iamnawa :sparkles: :thumbsup: :sparkles:
:warning: joshuaakulp already gave iamnawa points
Arjun Narayanan
@anarayanan86
Apr 02 2016 02:29
@ManBearPigg thanks
CamperBot
@camperbot
Apr 02 2016 02:29
anarayanan86 sends brownie points to @manbearpigg :sparkles: :thumbsup: :sparkles:
:star: 309 | @manbearpigg | http://www.freecodecamp.com/manbearpigg
ManBearPigg
@ManBearPigg
Apr 02 2016 02:30
@anarayanan86 No problem!
Baker
@bakerameen
Apr 02 2016 02:32
Hi can any one help on this
welcomeToBooleans() should return true.
Carl W Gainer
@cgainer
Apr 02 2016 02:33
Is there a way to "trace" the script between data sets?
Matthew Fricker
@mattfricker
Apr 02 2016 02:36

@bakerameen So when you execute a function in JavaScript, it is going to run until either the end of the function or until it comes across a return. Whatever the function returns will be the value of executing the function.

In this case, they want that return value to be the boolean true.

If on the other hand, I wanted to return false from a function, I would do

function myFunction() {
return false;
}
Baker
@bakerameen
Apr 02 2016 02:37
@mattfricker thanks for help
CamperBot
@camperbot
Apr 02 2016 02:37
bakerameen sends brownie points to @mattfricker :sparkles: :thumbsup: :sparkles:
:star: 81 | @mattfricker | http://www.freecodecamp.com/mattfricker
Baker
@bakerameen
Apr 02 2016 02:38
but i need to return true
Matthew Fricker
@mattfricker
Apr 02 2016 02:39
@bakerameen Yes. I did not want to give you the exact answer, but instead the recipe. Instead of returning true, which you need. I returned false. How might you return true instead?
Baker
@bakerameen
Apr 02 2016 02:39

function welcomeToBooleans() {

// Only change code below this line.

return false; // Change this line

// Only change code above this line.
}

welcomeToBooleans() should return true.
Matthew Fricker
@mattfricker
Apr 02 2016 02:40
@bakerameen Yes, that code will return false - now you just need to return true instead of false.
Baker
@bakerameen
Apr 02 2016 02:40
I tried but not work
I have replaced false with true
is it right?
Matthew Fricker
@mattfricker
Apr 02 2016 02:41
@bakerameen Very good - yes.
Apr 02 2016 02:51
hi, I have a problem with the step 253. My code return the results fine, but the site doesn't says the same
Paul Borawski
@iAmNawa
Apr 02 2016 03:08
@adrielzarate post the code you are having an issue with
Jackson Bates
@JacksonBates
Apr 02 2016 03:09
@adrielzarate what's the name of challenge 253?
andreyorlov33
@andreyorlov33
Apr 02 2016 03:10

Hello Campers! I am working on the Seek and Destroy challenge from Basic Algorithmic scripting.

I spliced my original argument into two arrays. Tested both of them to make sure they return the right values, and they do.
Then i ran a double loop in order to sort through the arrays.
the loop works correctly, but my output is [[1, null,null,1,null,null]]
for some reason my .filter function is not working. I would greatly appreciate it if some one could explain to me why... here is my code...

function destroyer(arr) {
var a = Array.prototype.slice.call(arguments);
a.splice(0,1);
var b=  Array.prototype.slice.call(arguments);
b.splice(1);

for(var x=0; x<arr.length; x++){
for(var y=0; y<a.length; y++){
if(arr[x]==a[y]){
delete arr[x];
}
}
}

var c =b.filter(falseValue);
return c;

function falseValue(value){
return Boolean(value);
}

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Apr 02 2016 03:11
hi, yes, sorry. The title is Title Case a Sentence
my code is
    function titleCase(str) {

str = str.split(' ');
var aux = [];

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

aux.push(str[i][0].toUpperCase());

for ( var j = 1; j < str[i].length; j++ ) {
aux.push(str[i][j].toLowerCase());
}
aux.push(' ');
}

aux = aux.join();
str = aux.replace(/,/g,'');
return str;
}

titleCase("sHoRt AnD sToUt");
Jackson Bates
@JacksonBates
Apr 02 2016 03:13
@adrielzarate what does it return when you run that?
Apr 02 2016 03:14
its return Short And Stout
Jackson Bates
@JacksonBates
Apr 02 2016 03:16
@adrielzarate ok, isn't that what you want? Are you getting an error message somewhere?
Apr 02 2016 03:17
yes! i can see that my result is that the string needed, but the site says that is wrong
Jackson Bates
@JacksonBates
Apr 02 2016 03:17
@adrielzarate i think there might be a small problem in your aux = aux.join();
Apr 02 2016 03:18
why do you think that ?
Jackson Bates
@JacksonBates
Apr 02 2016 03:19
@adrielzarate I had .join(" ") in mine...just reading yours more closely to see if we took the same approach...they look pretty identical except for variable names :)
Apr 02 2016 03:19
cool
Jackson Bates
@JacksonBates
Apr 02 2016 03:20
@adrielzarate did you pass the other three tests?
Apr 02 2016 03:20
@JacksonBates no, just the first, but all the tests return the strings that the problem says are the fine
Jackson Bates
@JacksonBates
Apr 02 2016 03:22
@adrielzarate gimme a sec, I'll paste it into my browser to test it and read it more closely...
Apr 02 2016 03:22
@JacksonBates i will use other name var for aux... may be that is the problem. I was using 'aux' in other old test in this exercises
@JacksonBates thanks!
CamperBot
@camperbot
Apr 02 2016 03:22
adrielzarate sends brownie points to @jacksonbates :sparkles: :thumbsup: :sparkles:
:star: 270 | @jacksonbates | http://www.freecodecamp.com/jacksonbates
Jackson Bates
@JacksonBates
Apr 02 2016 03:25
@adrielzarate ok, I see the problem - you are passing an extra space at the end into the final string with this line: aux.push('');
@adrielzarate The space is invisible in the browser, but I think that might be what is failing the test
Apr 02 2016 03:26
aaaaahhhh
you are right !!!!
hahahaha
thanks !!!
Jackson Bates
@JacksonBates
Apr 02 2016 03:27
@adrielzarate no problem :)
Apr 02 2016 03:28
@JacksonBates I owe you a beer
Jackson Bates
@JacksonBates
Apr 02 2016 03:34
seasons
@seasonscao
Apr 02 2016 03:44
Hello, i have a issue. I don’t know how to continue this code.
function truncateString(str, num) {
// Clear out that junk in your trunk
if(str.length>num){
if(num-3>0){
str = str.slice(0,num-3);
return  str += '...';
}else if(num-3<0){

}
return str;
}}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
I don’t know how to > truncateString("A-", 1) should return "A...".
truncateString("A-", 1) should return "A...".
Ramana Venkata
@vramana
Apr 02 2016 03:46
@seasonscao I think you should return A- in that case. Let me check
seasons
@seasonscao
Apr 02 2016 03:48
@vramana return A- ? what’s mean?
Ramana Venkata
@vramana
Apr 02 2016 03:49
@seasonscao When the str.length < 3 you have return str itself
samnesdahl
@samnesdahl
Apr 02 2016 03:50
Can someone post the solution to introducing javascript object notation JSON please
Ramana Venkata
@vramana
Apr 02 2016 03:51
@samnesdahl Where did you get struck? May be give it a try once more. I'll help
samnesdahl
@samnesdahl
Apr 02 2016 03:52
ive tried and googled it, but I don't know how to write the syntax for a new element. Also do I make a new var?
seasons
@seasonscao
Apr 02 2016 03:52
@vramana Truncate a string. I have tried your method, it’ not right :worried:
Lavie Ruan
@LavieMaru
Apr 02 2016 03:53
find Find the Longest Word in a String
CamperBot
@camperbot
Apr 02 2016 03:53

find find the longest word in a string

Ramana Venkata
@vramana
Apr 02 2016 03:54
@seasonscao Sorry. Let me solve the question once again and get back to you.
Hsin Chih Wang
@hsinwang5
Apr 02 2016 03:55
@seasonscao You have the code right...all you need in the else-if statement is to use (0, num) instead of (0, num-3)
@seasonscao then add "..." like usual
Zach
@Moose1551
Apr 02 2016 03:56
When I run this for loop, it returns "total = 9." Can someone explain how it gets this total?
var myArr = [ 2, 3, 4, 5, 6];
var total = 0;
for (total = 0; total < myArr.length; total++) {
total += myArr[total];
}
Alex Rose
@thelyricalrose
Apr 02 2016 04:00
@Moose1551 Because you are using total as your counter and main variable
Zach
@Moose1551
Apr 02 2016 04:00
Nevermind. I just changed "total" in the for loop to "i."
lol
Thanks, @thelyricalrose . So, i always has to be the counter and main variable in a for loop?
CamperBot
@camperbot
Apr 02 2016 04:01
moose1551 sends brownie points to @thelyricalrose :sparkles: :thumbsup: :sparkles:
:star: 278 | @thelyricalrose | http://www.freecodecamp.com/thelyricalrose
Alex Rose
@thelyricalrose
Apr 02 2016 04:01
@Moose1551 Yeah, 2+3+4 = 9 which is greater than the arr length. Good job catching it
seasons
@seasonscao
Apr 02 2016 04:01
@hsinwang5 okay, i get it. Thank you
CamperBot
@camperbot
Apr 02 2016 04:01
seasonscao sends brownie points to @hsinwang5 :sparkles: :thumbsup: :sparkles:
:star: 149 | @hsinwang5 | http://www.freecodecamp.com/hsinwang5
Alex Rose
@thelyricalrose
Apr 02 2016 04:02
@Moose1551 You can make the counter whatever variable you like, but for ones where you just want to use it to filter through an array its better to use a new variable
V Arun Kumar
@arunvkumr
Apr 02 2016 04:03
@Moose1551 that's because your loop is working with the value of total and inside loop you are changing the value of total..
1st iteration..
total = 0, total < myArr.length ( 0 < 5 ) - which is true..
now total += myArr[total] ( total = 2 ).
2nd Iteration.. missed because total is now 2
3rd iteration..
total = 2, total < myArr.length (2 < 5 ) - which s true.
now total += myArr[total] ( total = total + 3 ) = total = 5.
This s what is happening..
you a different variable for loop and it should work fine.. like i or j..
Alex Rose
@thelyricalrose
Apr 02 2016 04:04
@arunkumrv Thank you, that is a much better explanation of what I was saying
CamperBot
@camperbot
Apr 02 2016 04:04
thelyricalrose sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 413 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
samnesdahl
@samnesdahl
Apr 02 2016 04:05
How do I add an element to "myMusic"?var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];
ManBearPigg
@ManBearPigg
Apr 02 2016 04:09
@samnesdahl So what kind of elements does myMusic contain?
@samnesdahl myMusic is an array of objects, right? You with me so far?
@samnesdahl Objects in arrays are separated by commas, similarly to how numbers in arrays are separated by commas
@samnesdahl So you actually go in there, put a comma after the first object, and write your own object manually
Zach
@Moose1551
Apr 02 2016 04:15
@arunkumrv , I... I see. Thanks!
CamperBot
@camperbot
Apr 02 2016 04:15
moose1551 sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 414 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
samnesdahl
@samnesdahl
Apr 02 2016 04:18
@ManBearPigg thanks :)
CamperBot
@camperbot
Apr 02 2016 04:18
samnesdahl sends brownie points to @manbearpigg :sparkles: :thumbsup: :sparkles:
:star: 310 | @manbearpigg | http://www.freecodecamp.com/manbearpigg
Zach
@Moose1551
Apr 02 2016 04:19
Can someone steer me in this right direction with this "Nesting for Loops" challenge?
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
arr = [
[1.2], [3,4], [5,6,7]
];
for (var i = 0; i < arr.length; i++) {

product = arr[i];
}
// Only change code above this line
return product;
}

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

samnesdahl
@samnesdahl
Apr 02 2016 04:23
@ManBearPigg the comma was holding me back for like an hour lol...
ManBearPigg
@ManBearPigg
Apr 02 2016 04:23
@samnesdahl I know what you mean, I’ve been there lol
@samnesdahl What is the goal of the nesting for loops challenge
V Arun Kumar
@arunvkumr
Apr 02 2016 04:25
@Moose1551 Challenge is "Nesting for loops" but i don't see any nesting.. and you are multiplying elements in a 2d array so.
arr = [[1,2],[3,4],[5,6,7]]; and arr[0] = [1,2] , arr[1] = [3,4]and arr[2] = [5,6,7] .so you can't multiply array with another array. :grinning:
devonwilson1
@devonwilson1
Apr 02 2016 04:25
can someone help me with the accessing objects properties with variables
ManBearPigg
@ManBearPigg
Apr 02 2016 04:27
@devonwilson1 can you be more specific?
Zach
@Moose1551
Apr 02 2016 04:27
That makes a little sense, @arunkumvr. Is this any closer?
 arr = [
[1.2], [3,4], [5,6,7]
];
for (var i = 0; i < arr.length; i++) {
for (var j = [0][1][2]; j < arr[i].length; j++)
product = arr[i][j];
}
// Only change code above this line
return product;
devonwilson1
@devonwilson1
Apr 02 2016 04:31
I'm on that assignment trying to figure out what i am doing wrong ill show you my code
V Arun Kumar
@arunvkumr
Apr 02 2016 04:31
@Moose1551 ya you are close, better then what you had previously. why did you use j = [0][1][2]?
Outer loop starts at 0 and inner loop starts at 0.
Arnaud Casamé
@arnaudcasame
Apr 02 2016 04:32
Help convert html entities
CamperBot
@camperbot
Apr 02 2016 04:32
no wiki entry for: convert html entities
V Arun Kumar
@arunvkumr
Apr 02 2016 04:32
and remove the arr variable assignment statement inside your function
@Moose1551
devonwilson1
@devonwilson1
Apr 02 2016 04:34

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

// Only change code below this line;

var playerNumber = testObj [16]; // Montana,
var player = Montana;

Zach
@Moose1551
Apr 02 2016 04:35
@arunkumrv , When I typed that out, I was envisioning "var i = 0" as a reference to arr = [[],[],[]]", and "var j = [0][1][2]" referencing "[1,2],[3,4],[5,6,7]"
V Arun Kumar
@arunvkumr
Apr 02 2016 04:36
@devonwilson1
var playerNumber = 16; // Montana,
var player = testObj[playerNumber];
devonwilson1
@devonwilson1
Apr 02 2016 04:37
whats wrong with my code
Nicole S.
@nicolesteck
Apr 02 2016 04:39

Confused about what the difference between amount and amt is here.... function printAmount(amt) {
console.log( amt.toFixed( 2 ) );
}

function formatAmount() {
return "$" + amount.toFixed( 2 ); } var amount = 99.99; printAmount( amount * 2 ); // "199.98" amount = formatAmount(); console.log( amount ); // "$99.99"

V Arun Kumar
@arunvkumr
Apr 02 2016 04:40
@Moose1551 you have to take one sub array at a time.. to multiply all the elements...
arr = [[1,2],[3,4],[5,6,7]]; and
arr[0] = [1,2] , arr[1] = [3,4]and arr[2] = [5,6,7]
so to access the first subarray. you have to use..
arr[0] = [1,2] --> arr[0][0] = 1, arr[0][1] = 2,
arr[1] = [3,4] --> arr[1][0] = 3, arr[1][1] = 4 and same goes for arr[2].
Paul Borawski
@iAmNawa
Apr 02 2016 04:40
@nicolesteck amt is a parameter of a function, amount is a variable
Nicole S.
@nicolesteck
Apr 02 2016 04:40
i don't understand what a parameter of a function is/how it's different than a variable
Paul Borawski
@iAmNawa
Apr 02 2016 04:41
a variable is declared by you
V Arun Kumar
@arunvkumr
Apr 02 2016 04:41
@devonwilson1 you are simply assigning Montana to player, you need to get the value from object
Nicole S.
@nicolesteck
Apr 02 2016 04:42
so the parameter doesn't need to be declared or anything? function calculate(amt) can be the first time it's mentioned?
Paul Borawski
@iAmNawa
Apr 02 2016 04:42
function nicole(parameter1, parameter2) {
var variable = parameter1 + parameter2;
console.log(variable);
parameter don’t have to be used
that is a part of functions that can be confusing at first, just keep writing functions and eventually it will make sense @nicolesteck
Nicole S.
@nicolesteck
Apr 02 2016 04:44
so the parameters are used to modify the variable but arent declared like avariable
devonwilson1
@devonwilson1
Apr 02 2016 04:44
@arunkumrv can you help me do that?
Nicole S.
@nicolesteck
Apr 02 2016 04:44
ok.... i was feeling super lost in the FCC section on JS so i moved to "You don't know JS" the book, which explains in more depth.... i still feel stymied!
V Arun Kumar
@arunvkumr
Apr 02 2016 04:45
@devonwilson1 :point_up: April 2, 2016 10:06 AM
Paul Borawski
@iAmNawa
Apr 02 2016 04:45
a function is like the mom and the parameters are her kids, inside the function she can make them do whatever she wants. Outside the function, they don’t exist
Nicole S.
@nicolesteck
Apr 02 2016 04:45
omg
is here omething bigger than brownie points?
thank you @iamnawa!!!
CamperBot
@camperbot
Apr 02 2016 04:46
nicolesteck sends brownie points to @iamnawa :sparkles: :thumbsup: :sparkles:
:star: 323 | @iamnawa | http://www.freecodecamp.com/iamnawa
Paul Borawski
@iAmNawa
Apr 02 2016 04:46
haha no problem
Zach
@Moose1551
Apr 02 2016 04:46
I figured it out, @arunkumrv . Well, kind of. I got incredibly frustrated and looked up the solution. The only thing I was missing was [i][j] in "product *= arr[i][j]"
Nicole S.
@nicolesteck
Apr 02 2016 04:46
but so they're her kids but she has some kind of disorder and theyre not real outside her head? ;)
devonwilson1
@devonwilson1
Apr 02 2016 04:46

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

// Only change code below this line;

var playerNumber = testObj [16]; // Montana,
var player = testObj [16]; // Montana

what the heck is wrong with this
Paul Borawski
@iAmNawa
Apr 02 2016 04:47
haha something like that
Zach
@Moose1551
Apr 02 2016 04:48

Why is the psuedocode using console.log instead of product *=?

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

V Arun Kumar
@arunvkumr
Apr 02 2016 04:51
@Moose1551 haha no prob... really only *. also j = 0right?
Nikita Manahov
@Nikitaw99
Apr 02 2016 04:52
Can somebody kinda fix da timer here? https://github.com/Nikitaw99/backwars-leekspin
it's in the index.html file
withing the <script> tag
V Arun Kumar
@arunvkumr
Apr 02 2016 04:53
@Moose1551 what's that? i didn't get the part psuedocode using console.log
Paul Borawski
@iAmNawa
Apr 02 2016 04:56
@Moose1551 yeah what do you mean?
Zach
@Moose1551
Apr 02 2016 04:57
@arunkumrv , makes sense. In the chapter explanation, the example that FCC provides uses (console.log) instead of (product *=)
I tried to use "console.log(arr[i][j])" instead of "product *= arr[i][j]", but it only returned 1.
Paul Borawski
@iAmNawa
Apr 02 2016 05:03
what challenge is it?
@Moose1551
Nikita Manahov
@Nikitaw99
Apr 02 2016 05:04
backkkkk
Paul Borawski
@iAmNawa
Apr 02 2016 05:04
@Nikitaw99 welcome back!
Nikita Manahov
@Nikitaw99
Apr 02 2016 05:05
I have a question, how do I export a network graph in bitbucket?
Paul Borawski
@iAmNawa
Apr 02 2016 05:05
priviet @Nikitaw99 I am Паша
Nikita Manahov
@Nikitaw99
Apr 02 2016 05:05
ya know, liek the graph thingy in github
@iAmNawa xD
Paul Borawski
@iAmNawa
Apr 02 2016 05:06
export to where?
Zach
@Moose1551
Apr 02 2016 05:06
@iAmNawa , the challenge is "Nesting for Loops"
Nikita Manahov
@Nikitaw99
Apr 02 2016 05:06
@iAmNawa to png or something :P
Paul Borawski
@iAmNawa
Apr 02 2016 05:06
you want to save it off the internet or just change the file format?
Nikita Manahov
@Nikitaw99
Apr 02 2016 05:06
I just want to see the full commit history
instead of browsing through pages
Paul Borawski
@iAmNawa
Apr 02 2016 05:08
 for (var j = 0; j < arr[i].length; j++) {
product = product * arr[i][j];
@Moose1551 that’s what I have and it passed
console.log was just an example
Erik Villoria
@kire73
Apr 02 2016 05:08
using .fromCharCode() and its returning a red dot?
Paul Borawski
@iAmNawa
Apr 02 2016 05:09
@Nikitaw99 it doesn’t work like that
Erik Villoria
@kire73
Apr 02 2016 05:09
nvm
Nikita Manahov
@Nikitaw99
Apr 02 2016 05:09
@iAmNawa damn!
Luis Rivera
@lrivera27
Apr 02 2016 05:20
hey guys, how do I check what's inside an object with a console log, for example, if I use a function that as a parameter it has
"name", and my object is "contacts" should I console.log(contacts[name]); ?
does that work ?
Vivienne Sales
@Natto278
Apr 02 2016 05:23
Thank you @Sonja Moisett for helping me solve the Stand in Line challenge!
CamperBot
@camperbot
Apr 02 2016 05:23
natto278 sends brownie points to @sonja :sparkles: :thumbsup: :sparkles:
:star: 2 | @sonja | http://www.freecodecamp.com/sonja
LHuChemE
@LHuChemE
Apr 02 2016 05:36
anyone have a more verbose description for the Smallest Common Multiple algorithm problem?
I don't understand how the arguments [1,5] gives 60 and [1,13] gives 360360
@camperbot help Smallest Common Multiple
Norman Dela Cruz
@dcnr
Apr 02 2016 05:39
@LHuChemE you get all the LCM for each of the numbers in the range, you're only given 2 numbers, that's the range. [1,5] would mean LCM of [1,2,3,4,5] that's why it's 60
LHuChemE
@LHuChemE
Apr 02 2016 05:40
thanks @dcnr that makes much better sense
CamperBot
@camperbot
Apr 02 2016 05:40
lhucheme sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 760 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Apr 02 2016 05:41
you're welcome, @LHuChemE thanks too!
CamperBot
@camperbot
Apr 02 2016 05:41
dcnr sends brownie points to @lhucheme :sparkles: :thumbsup: :sparkles:
:star: 289 | @lhucheme | http://www.freecodecamp.com/lhucheme
Norman Dela Cruz
@dcnr
Apr 02 2016 05:41
ping @bitgrower
Hemang Kumar
@hemangsk
Apr 02 2016 06:00
Hello campers! :smile:
I've created a new theme for Jekyll, basically for blogging and stuff..Hope you like it :smile:
https://github.com/hemangsk/Gravity :sparkles: Minimal Theme for Jekyll :sparkles:
Live Demo @ http://hemangsk.github.io/Gravity
devonwilson1
@devonwilson1
Apr 02 2016 06:01
can someone tell me what is wrong with this code
for the assignment objects properties with variables PLEASE PLEASE PLEASE

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

// Only change code below this line;

var playerNumber = [16];
var player = testObj [Montana]; // Montana

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

// Only change code below this line;

var playerNumber = 16;
var player = testObj ["16"]; // "Montana"

how is that last one not bracket notation???????
plase
some
one
help
CamperBot
@camperbot
Apr 02 2016 06:05

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

### Basic Commands:

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

:speech_balloon: meet CamperBot in this room!

devonwilson1
@devonwilson1
Apr 02 2016 06:05
me
any
one
Hemang Kumar
@hemangsk
Apr 02 2016 06:05
@devonwilson1 You have to access the property value of 16, so
playerNumber = 16, and var player should be equal to testObj[playerNumber]
var player = testObj ["16"]; // Incorrect because 16 is not a string property, it is an integer property
ykcab
@ykcab
Apr 02 2016 06:09
hello guys
Apr 02 2016 06:10
js
function findLongestWord(str) {
var str2= str.split(' ');

str2.sort(function(a,b){

return b.length - a.length;

});

return str2[0].length;

}

/*  for(var x=0; x<=str.length; x++){
var placeHolder= str2[x].length;
str2[x]= placeHolder;
}

str2.sort(function(a,b){

return b-a;

});

return str2[1].length;
}*/

findLongestWord("The quick brown fox jumped over the lazy dog");
So i wrote 2 different ways to solve this problem. The top one worked great. Im trying to figure out why the second option (currently in / ) didnt work, just so I can understand for the future.
ykcab
@ykcab
Apr 02 2016 06:10
i need some help with a callback function... can someone tells me where my error is on the image below?
devonwilson1
@devonwilson1
Apr 02 2016 06:10
thank you @hemangsk
CamperBot
@camperbot
Apr 02 2016 06:10
devonwilson1 sends brownie points to @hemangsk :sparkles: :thumbsup: :sparkles:
:star: 339 | @hemangsk | http://www.freecodecamp.com/hemangsk
Apr 02 2016 06:11
@ykcab post the code :)
ykcab
@ykcab
Apr 02 2016 06:12
function filter (array, callback){
var output = [];
for (var i = 0; i < array.length; i++){
if (callback(array[i]) === true){
output.push(array[i]);
}
}
here is the user senerio:
Define a function filter which takes an array and a callback function as arguments. filter will iterate through the array, passing each array element to the callback as an argument. If the return value of the callback is true, that element is pushed into a new array. filter will return this new array.
var isEven = function(elem) { return elem % 2 === 0; }
filter([0,1,2,3,4,5,6,7], isEven); -> [0,2,4,6]
filter([11, 7, 100, 14], isEven); -> [100, 14]
uriznik
@uriznik
Apr 02 2016 06:17
@ykcab what are you passing to the callback function?
ykcab
@ykcab
Apr 02 2016 06:19
need to return the output from the callback function
I got it guys... thanks
genn
@gennkill
Apr 02 2016 06:28
hi guys i'm stuck on ' a should be assigned to b with ='
for Storing Values with the Assignment Operator topic
Apr 02 2016 06:28
@gennkill post the code you are working on :)
genn
@gennkill
Apr 02 2016 06:29
okay sorry about that!

// Setup
var a;
var b = 2;

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

ElvisTheStriker
@ElvisTheStriker
Apr 02 2016 06:29

Hi Guys, getting error "TypeError : 0 is read only" with th code below:-
function titleCase(str) {
var tmpArr; // array to hold split string

tmpArr = str.split(); // split str into an array
console.log(tmpArr); // test print to console
for (i=0; i < tmpArr.length; i++){
console.log(tmpArr[i]); // test printto console
tmpArr[i][0] = tmpArr[i][0].toUpperCase(); //deal with the first letter of each word
for (j=1 ; j<tmpArr[i][j].length; j++){
tmpArr[i][j] = tmpArr[i][j].toLowerCase(); // deal with rest of word
}
}
str = tmpArr.join();
return str;
}

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

any ideas waht is causing this?
*what
Vivek
@vivek28111992
Apr 02 2016 06:29
@gennkill why are assign var toa 2 times?
genn
@gennkill
Apr 02 2016 06:30
the only X i got was on 'a should be assigned to b with =' and i thought this would be the correct aproach
Vivek
@vivek28111992
Apr 02 2016 06:30
@gennkill also I think you need to give b = a;
for that b = a; is solution
genn
@gennkill
Apr 02 2016 06:31
oh it worked , thanks vivek
why cant it be a=b; ?
Vivek
@vivek28111992
Apr 02 2016 06:32
a = b is you are assigning value of b to a, we want value of a equal to b
genn
@gennkill
Apr 02 2016 06:33
Oh thank you !
I'm new to programming, thanks a lot.
Vivek
@vivek28111992
Apr 02 2016 06:34
@gennkill Happy Coding !
Kyle Morton
@kmorton1988
Apr 02 2016 06:41
how do I capture form input with jquery?
I've been reading into it for hours, can't seem to find specifically what I want to accomplish
ElvisTheStriker
@ElvisTheStriker
Apr 02 2016 06:42

Hi Guys, getting error "TypeError : 0 is read only" with th code below:-
function titleCase(str) {
var tmpArr; // array to hold split string

tmpArr = str.split(); // split str into an array
console.log(tmpArr); // test print to console
for (i=0; i < tmpArr.length; i++){
console.log(tmpArr[i]); // test printto console
tmpArr[i][0] = tmpArr[i][0].toUpperCase(); //deal with the first letter of each word
for (j=1 ; j<tmpArr[i][j].length; j++){
tmpArr[i][j] = tmpArr[i][j].toLowerCase(); // deal with rest of word
}
}
str = tmpArr.join();
return str;
}

titleCase("I'm a little tea pot");
any ideas what
is causing this?

Kyle Morton
@kmorton1988
Apr 02 2016 06:44
I'm not entirely sure about this, but I think split() and join() both need to have input to actually tell it what to split each character with.
(i don't know, honestly)
so like, string.split("")
to separate each character on its own. Is it working properly when you do console.log(tmpArr);?
Apr 02 2016 06:45
js
function titleCase(str) {

var str2=str.split(' ');
var newArray = [];
for (var x=0;x<str2.length;x++){
newArray.push([str2[x]]);
}
for (var i=0; i<newArray.length;i++){
newArray[i].split('');
newArray[i][1].toUpperCase();
var nextArray = newArray[i].join("");
}
var finalArray= nextArray.join(" ");

return finalArray;

//return str;
}

titleCase("I'm a little tea pot");
trying to figure this out....
Kyle Morton
@kmorton1988
Apr 02 2016 06:45
would it make more sense to split each word first into its own array index, THEN split each word into each character in a sub array?
ElvisTheStriker
@ElvisTheStriker
Apr 02 2016 06:45
when I watch the console the str gets split into an array
Apr 02 2016 06:46
@kmorton1988 thats what it should be doing...
OH! someone else was asking about the same problem :)
Sorry
Kyle Morton
@kmorton1988
Apr 02 2016 06:46
Yeah, lol, yours was just a coincidence that it sort of made sense. lol :P
Apr 02 2016 06:47
lol. well at least I'm not the only one having issues. :)
Kyle Morton
@kmorton1988
Apr 02 2016 06:47
oh, @V1ad1m1r , remember that arrays start at index 0.
Apr 02 2016 06:48
@kmorton1988 i was thinking of that but wouldn't the " in the string be at place [0]?
also for some reason its returning the error- newArray[i].split is not a function... :/
Kyle Morton
@kmorton1988
Apr 02 2016 06:48
your newArray[i][1].toUpperCase(); is gonna uppercase the second letter of each word-array
Apr 02 2016 06:49
oh ok. so the " simply identifies the string, its not a part of it. cool.
Kyle Morton
@kmorton1988
Apr 02 2016 06:49
Yeah, just shows that it's a string and not a variable
so, str2 = str.split(' ') ends up with an array of your words
you don't have to populate a SECOND array with it...
that's probably why you're getting that error you mentioned.
Francisco Franco
@frenktico
Apr 02 2016 06:50

Ppl I want to check something on my script. It is working but I'd like a brief explanation.

var foodDemand = function (food) {
console.log("Quero comer," + " " + food);
};

foodDemand("Pizza");

This one is correctly showing me the result as "Quero comer Pizza". What I still would like to know is what is the mainfunction of function over there with the (food). Could it be anything else?

Another exercise to practice I was doing at another place gave me this exercise:


var greeting = function (name) {
console.log("Que bom ver você," + " " + name);
};

// Na linha 11, chame a função greeting!
greeting("Francisco");

The result again correctly appeared was *Que bom ver você Francisco". Could you guys describe maybe each part of this code so I can have a better idea of how to use on the future?

Kyle Morton
@kmorton1988
Apr 02 2016 06:50
so str2 IS an array containing your words.
Apr 02 2016 06:51
yea i got the array of words ok, I was splitting each word into sub arrays to target the first letter. Did I overthink this?
Kyle Morton
@kmorton1988
Apr 02 2016 06:51
@frenktico , the keyword "function" tells javascript that you're defining a function, and that you're going to be passing a variable into it, that variable will be available to the inner workings of the function as the variable name of "food".
ElvisTheStriker
@ElvisTheStriker
Apr 02 2016 06:52
@V1ad1m1r are you getting the same type error I'm seeing Vladimir ? "typeError: 0 is read only?
Kyle Morton
@kmorton1988
Apr 02 2016 06:53
@V1ad1m1r , get rid of your first for loop. it's basically making a second identical array in which you already have (str2)
then in your second for loop, replace "newArray" with "str2"
Apr 02 2016 06:53
@ElvisTheStiker unfortunately no. Im getting- newArray[i].split is not a function
Francisco Franco
@frenktico
Apr 02 2016 06:54

Let me break down the first code:

var foodDemand = function (food) {
console.log("Quero comer," + " " + food);
};

foodDemand("Pizza");

var variable
foodDemand name of my variable
function the one you just explained
(food) this is the name of my funcion. Am I right? @kmorton1988

Kyle Morton
@kmorton1988
Apr 02 2016 06:54
@frenktico not quite
@frenktico
var tells javascript you're about to define a variable
foodDemand names it
function tells javascript that this variable will be a function
food can be whatever you want, and will be what you use to access the passed information to the inner workings of that function
Francisco Franco
@frenktico
Apr 02 2016 06:55
I still didn't understand the need of this part on the parenthesis as well on the console.log thing.
hmmm okay
That works on my head I guess
ElvisTheStriker
@ElvisTheStriker
Apr 02 2016 06:56
have you tried using the browser console to see what is contained in the array?
Kyle Morton
@kmorton1988
Apr 02 2016 06:56
see how inside the function brackets, you use food to display "pizza" which was passed to it.
ykcab
@ykcab
Apr 02 2016 06:56
@frenktico consol.log(): to show the result
ElvisTheStriker
@ElvisTheStriker
Apr 02 2016 06:56
@V1ad1m1r have you tried using the browser console to see what is contained in the array?
Francisco Franco
@frenktico
Apr 02 2016 06:57
Thanks @kmorton1988 I have to figure out a best way to fix more the knowledge around JS
CamperBot
@camperbot
Apr 02 2016 06:57
frenktico sends brownie points to @kmorton1988 :sparkles: :thumbsup: :sparkles:
:star: 309 | @kmorton1988 | http://www.freecodecamp.com/kmorton1988
Kyle Morton
@kmorton1988
Apr 02 2016 06:57
for sure. good luck, @frenktico
ykcab
@ykcab
Apr 02 2016 06:57
in PYTHON it's: print ('')
Francisco Franco
@frenktico
Apr 02 2016 06:57
Thanks @ykcab
CamperBot
@camperbot
Apr 02 2016 06:57
frenktico sends brownie points to @ykcab :sparkles: :thumbsup: :sparkles:
:star: 186 | @ykcab | http://www.freecodecamp.com/ykcab
Kyle Morton
@kmorton1988
Apr 02 2016 06:57
@ykcab console.log() is a bit different than what print('') would do.
ykcab
@ykcab
Apr 02 2016 06:57
in JAVA is System.out.print("")
Kyle Morton
@kmorton1988
Apr 02 2016 06:58
@ykcab console.log only displays it to the console, it won't actually manipulate the document that the javascript is running inside of.
Apr 02 2016 06:58
@ElvisTheStiker i havent, but i have sent some return statements to see in the left side console.
Kyle Morton
@kmorton1988
Apr 02 2016 06:58
@V1ad1m1r keep in mind, a return command exits the function.
so anything AFTER return something will not run
Apr 02 2016 06:59
@kmorton1988 yea. I have been using to check how things are standing at specific places in the code.
Kyle Morton
@kmorton1988
Apr 02 2016 06:59
ok cool.
buckshot307
@buckshot307
Apr 02 2016 06:59
okay so I'm on the first part of arrays and stuck
ykcab
@ykcab
Apr 02 2016 06:59
@kmorton1988 yeah.... but i see the functionality seem to be the same of output result?
buckshot307
@buckshot307
Apr 02 2016 07:00
where it says to read from myArray using bracket notation so that myData is equal to 8
ykcab
@ykcab
Apr 02 2016 07:00
@buckshot307 post your code here
buckshot307
@buckshot307
Apr 02 2016 07:00

// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[0][0];

Kyle Morton
@kmorton1988
Apr 02 2016 07:00
@ykcab kind of. print('') generally actually returns a user-viewable text block. console.log() only makes it print into the console, which isn't always visible to the user.
@buckshot307, type in js, press enter, paste your code, then press CTRL + enter
buckshot307
@buckshot307
Apr 02 2016 07:01
i've tried myArray[0][0] = 8 but it doesn't change the first number
Apr 02 2016 07:01
@kmorton1988 im looking over taking out the first for loop, but if I do, then i will have an array with words as each element, rather than an array with words as their own individual sub arrays which i can split and call
ykcab
@ykcab
Apr 02 2016 07:01
Yes @buckshot307 ....
buckshot307
@buckshot307
Apr 02 2016 07:02
// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[0][0];
myArray[0][0] = 8
Kyle Morton
@kmorton1988
Apr 02 2016 07:02
@V1ad1m1r you're overthinking it. You don't want a triple nested array (which is kind of what you're planing on doing). You want just an array of your words, then each array index will be split into a sub array of the letters, hence being able to access it with newArray[i][0]
ElvisTheStriker
@ElvisTheStriker
Apr 02 2016 07:02
@V1ad1m1r shouldn't you assign the expression newArray[i].split(''); to something e.g tmpArr =newArray[i].split('');
Apr 02 2016 07:02
@kmorton1988 oh ok. lemme try that.
kirbyedy
@kirbyedy
Apr 02 2016 07:02
@buckshot307 what is the index number of the array you are trying to access ?
@buckshot307 and whats the index number of the element you want to access ?
buckshot307
@buckshot307
Apr 02 2016 07:03
I'm not sure,
kirbyedy
@kirbyedy
Apr 02 2016 07:03
and keep in mind arrays are 0 based
hint: your first array is number 0
CamperBot
@camperbot
Apr 02 2016 07:03
Set a bonfire to talk about with bonfire name
buckshot307
@buckshot307
Apr 02 2016 07:03
var myData  =  myArray[0][0];
Apr 02 2016 07:03
@ElvisTheStiker hmm same error. Im gonna try kmorton1988's thing. :)
kirbyedy
@kirbyedy
Apr 02 2016 07:04
@buckshot307 arrays are 0 based... so that would return what number ?
buckshot307
@buckshot307
Apr 02 2016 07:04
1
kirbyedy
@kirbyedy
Apr 02 2016 07:04
yes
now try to count, and access the element the number you need
buckshot307
@buckshot307
Apr 02 2016 07:05
but the readouit isn't showing it afftecting the array, it's affecting a number before the array
kirbyedy
@kirbyedy
Apr 02 2016 07:05
which element you need to access ?
ElvisTheStriker
@ElvisTheStriker
Apr 02 2016 07:06
@V1ad1m1r you have two lines running concurrently that may you may need to assign to something... the one I mentioned earlier and the one below
it
buckshot307
@buckshot307
Apr 02 2016 07:06
myData: 1 myArray: [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
the 1 before myArray is the number that needs to change
kirbyedy
@kirbyedy
Apr 02 2016 07:06
you only need to change the numbers in this line, nothing else
var myData = myArray[0][0];
in the brackets
so the first bracket is going to be the "number" of your array... which is 0 based
buckshot307
@buckshot307
Apr 02 2016 07:07
oh okay
kirbyedy
@kirbyedy
Apr 02 2016 07:07
and the second bracket the number of your element... again 0 based number
reset the code, and only change the number in the brackets, nothing else
buckshot307
@buckshot307
Apr 02 2016 07:08
ah i see it's asking to find the 8 inside myArray
Apr 02 2016 07:08
js
function titleCase(str) {
str= str.toLowerCase;
var str2=str.split(' ');
var newArray = [];
/*  for (var x=0;x<str2.length;x++){
newArray.push([str2[x]]);
}*/

for (var i=0; i<str2.length;i++){
//   str2[i] = str2[i].split('');
str2[i][0]= str2[i][0].toUpperCase();
var nextArray = str2[i].join("");
}
var finalArray= nextArray.join(" ");

return finalArray;

//return str;
}

titleCase("I'm a little tea pot");
ok here is where im at. now the str.split that was working fine earlier... is coming back as not a function :?
ykcab
@ykcab
Apr 02 2016 07:08
@buckshot307 in myArray each subArray is considered as 1 single element
and to access its element you follow as explained by @kirbyedy
buckshot307
@buckshot307
Apr 02 2016 07:10
okay i see that now, I thought it was asking my to change myArray[0][0], which would be 1, to 8, instead of changing the array location to the 8 already in the array
ykcab
@ykcab
Apr 02 2016 07:11
great @buckshot307 have fun coding...
buckshot307
@buckshot307
Apr 02 2016 07:11
thanks for the help!
Apr 02 2016 07:12
@ElvisTheStiker lol. NOW i'm getting the "0" is read only error! lol.
ElvisTheStriker
@ElvisTheStriker
Apr 02 2016 07:13
Apr 02 2016 07:13
@ElvisTheStiker no worries :) at least I am making progress :)
ElvisTheStriker
@ElvisTheStriker
Apr 02 2016 07:14
@V1ad1m1r did you get it after making the change I suggested ?
Apr 02 2016 07:14
i did add that, but Im getting it now that I removed my second sub array.
Parminder Singh
@Trion129
Apr 02 2016 07:17
var weatherData;
$.getJSON('http://api.openweathermap.org/data/2.5/weather', { lat: latitude, lon: longitude, APPID: appid }, function(json) { weatherData = json; }); weatherData is staying undefined, How do I put the JSON object I get from the api into that variable? V1ad1m1r @V1ad1m1r Apr 02 2016 07:20 Anyone still there? ElvisTheStriker @ElvisTheStriker Apr 02 2016 07:22 me Kyle Morton @kmorton1988 Apr 02 2016 07:25 sorry guys, working on my wikipedia search page. (what I originally came in to get help with lol) V1ad1m1r @V1ad1m1r Apr 02 2016 07:26 js function titleCase(str) { str= str.toLowerCase(); var str2=str.split(' '); var theNextArray=[] ; for (var i=0; i<str2.length;i++){ str2[i] = str2[i].split(''); str2[i][0]= str2[i][0].toUpperCase(); theNextArray[i] = str2[i].join(""); } var finalArray= theNextArray.join(" "); return finalArray; } titleCase("I'm a little tea pot"); @ElvisTheStiker Hey elvis, I finally got it. This is what I came up with. Kyle Morton @kmorton1988 Apr 02 2016 07:26 nice, @V1ad1m1r so did my tips help earlier? Vivienne Sales @Natto278 Apr 02 2016 07:27 Hi! I'm at the Golf Code challenge and I 'm having a lot of trouble getting the message "Par" to show up. Here's my code: function golfScore(par, strokes) { // Only change code below this line if (strokes === 1) return "Hole-in-one!"; else if (strokes <= 2) return "Eagle"; else if (strokes != 1) return "Birdie"; else if (strokes > 2) return "Par"; return "Change Me"; // Only change code above this line } // Change these values to test golfScore(5, 4); V1ad1m1r @V1ad1m1r Apr 02 2016 07:27 @kmorton1988 yes some. the original for loop was pointless, but I had to drop it down to a second sub array, because it wasnt targeting the first letter in each string. Instead it was coming back as "read only" @kmorton1988 Thanks either way though! I certainly needed all the help I could get :) CamperBot @camperbot Apr 02 2016 07:27 v1ad1m1r sends brownie points to @kmorton1988 :sparkles: :thumbsup: :sparkles: :star: 310 | @kmorton1988 | http://www.freecodecamp.com/kmorton1988 Kyle Morton @kmorton1988 Apr 02 2016 07:28 @V1ad1m1r glad I could help at least a bit :) V1ad1m1r @V1ad1m1r Apr 02 2016 07:28 :) Vivienne Sales @Natto278 Apr 02 2016 07:28 Do have to know how to play golf to complete the Golf Code challenge? V1ad1m1r @V1ad1m1r Apr 02 2016 07:29 @Natto278 lol. no. you should be able to do it without "hitting the greens" :) @Natto278 the issues seems to be that you are assigning the strokes in you if/else statement rather than giving them variables that can be input through the function. The "par" for each hole will change so the stroke count for each outcome will change. @Natto278 example- else if (strokes = par-2) return "Eagle"; I am using the par variable alright. I'm off to bed. Night everyone :) Vivek @vivek28111992 Apr 02 2016 07:38 @V1ad1m1r good night ElvisTheStriker @ElvisTheStriker Apr 02 2016 07:38 @V1ad1m1r good night ! good to see you got there... think I've sussed the typeError... I was trying to access a string like an array Vivienne Sales @Natto278 Apr 02 2016 07:43 I'm at an FCC meeting in Seoul and one of the members told me that she had the same issue. How she solved the problem was adding the && operator for each statement. She had to go back and add && to her code for that challenge. Good night, @V1ad1m1r and thank you @V1ad1m1r. It's time for me to take out the paper notebook and write some code before entering it on the FCC challenge website. CamperBot @camperbot Apr 02 2016 07:43 natto278 sends brownie points to @v1ad1m1r :sparkles: :thumbsup: :sparkles: :star: 258 | @v1ad1m1r | http://www.freecodecamp.com/v1ad1m1r Nikhil Kumar @nikhilkumar238 Apr 02 2016 08:01 how can I remove all non-alphanumeric character from a string ? Vivek @vivek28111992 Apr 02 2016 08:05 @nikhilkumar238 \w Arjun Narayanan @anarayanan86 Apr 02 2016 08:15 hey a general question... how do i add one number to all the elements of a numerical array? i.e. if i want to add 5 to all the values in [5, 6, 7, 8, 9, 10, 11, 12] Vivienne Sales @Natto278 Apr 02 2016 08:22 Thank you for explaining the differences between '=', '==', and '===' @SangHoonJu. That and your tip about changing the values helped me do pass the Golf Code challenge! CamperBot @camperbot Apr 02 2016 08:22 natto278 sends brownie points to @sanghoonju :sparkles: :thumbsup: :sparkles: :warning: could not find receiver for sanghoonju Aleksander Gębicki @Takumar Apr 02 2016 08:25 @anarayanan86 there was nice exercise on using map() for this purpose Arjun Narayanan @anarayanan86 Apr 02 2016 08:26 hmm that must be coming up ahead, because i'm not familiar with map() yet Aleksander Gębicki @Takumar Apr 02 2016 08:26 @anarayanan86 oh I have this link: https://www.freecodecamp.com/challenges/iterate-over-arrays-with-map Please do this exercise, because that is exactly what you are looking for :-) Arjun Narayanan @anarayanan86 Apr 02 2016 08:27 oh LOL nvm it was a while ago i simple forgot thanks for the reminder! @Takumar CamperBot @camperbot Apr 02 2016 08:27 anarayanan86 sends brownie points to @takumar :sparkles: :thumbsup: :sparkles: :star: 2950 | @takumar | http://www.freecodecamp.com/takumar Aleksander Gębicki @Takumar Apr 02 2016 08:27 @anarayanan86 but notice that map() don't modify array you have to assign returned array to the array itself. Of course you could do this with simple for loop: for (var i=0; i < arr.length; i++) { arr[i] += 5; } :-) Arjun Narayanan @anarayanan86 Apr 02 2016 08:29 yes, i was hoping there was a way to do without having to recourse to that! Mithlesh Upadhyay @csegate2 Apr 02 2016 08:43 Hello! http://cpp.sh/6lxv4 why "2:11: error: '::main' must return 'int'" why integer ? #include<stdio.h> int main(){ printf("Hello World!\n"); return 0; } Markus Kiili @Masd925 Apr 02 2016 08:44 @csegate2 This channel is for Javascript help. help rooms Aleksander Gębicki @Takumar Apr 02 2016 08:45 @csegate2 because it should be integer :-) I always see that main() returns void type or integer I haven't thought about that but it looks they are only valid types to return. Adole Samuel @int-elligentSam Apr 02 2016 08:48 @csegate2 hello Mithlesh Upadhyay @csegate2 Apr 02 2016 08:48 hi @samconnor Aleksander Gębicki @Takumar Apr 02 2016 08:49 @csegate2 hmm, I have to read about C++, it looks like int is the only valid type to return now. Adole Samuel @int-elligentSam Apr 02 2016 08:49 @csegate2 you learning C too Mithlesh Upadhyay @csegate2 Apr 02 2016 08:49 No, I need to understand this popular program :smile: Adole Samuel @int-elligentSam Apr 02 2016 09:00 Ok Mithlesh Upadhyay @csegate2 Apr 02 2016 09:02 @samconnor , So? migraf @migraf Apr 02 2016 09:09 Hello I dont understand why this function doesnt push the value into the array. ''' CamperBot @camperbot Apr 02 2016 09:09 :bulb: to format code use backticks!  more info migraf @migraf Apr 02 2016 09:09 ''' CamperBot @camperbot Apr 02 2016 09:09 :bulb: to format code use backticks!  more info migraf @migraf Apr 02 2016 09:10 ''' function update(id, prop, value) { if(value !== "" && collection[id][prop] !== "tracks" ) collection[id][prop] = value; else if(value !== "" && collection[id][prop] === "tracks") collection[id][prop].push(value); else delete collection[id][prop]; return collection; } ''' CamperBot @camperbot Apr 02 2016 09:10 :bulb: to format code use backticks!  more info migraf @migraf Apr 02 2016 09:10 hm let me try again with the formatting :smile: Brendan Kinahan @BKinahan Apr 02 2016 09:10 @migraf click that more info link migraf @migraf Apr 02 2016 09:10 function update(id, prop, value) { if(value !== "" && collection[id][prop] !== "tracks" ) collection[id][prop] = value; else if(value !== "" && collection[id][prop] === "tracks") collection[id][prop].push(value); else delete collection[id][prop]; return collection; } Brendan Kinahan @BKinahan Apr 02 2016 09:10 @migraf also edit your message instead of posting a new one :) ah Vitor Lory @vlory73 Apr 02 2016 09:11 @Takumar why would this solve the problem of pushing on a JSON array? var a = collection[id][prop].push(value); instead of collection[id][prop].push(value); Markus Kiili @Masd925 Apr 02 2016 09:11 @migraf The tracks test should be just prop!=="tracks" migraf @migraf Apr 02 2016 09:12 ah thank you thinking too complicated :smile: Brendan Kinahan @BKinahan Apr 02 2016 09:13 @vlory73 they should both do the same thing to collection, but a will have a value equal to the new length of collection[id][prop] @vlory73 did the latter not work for you? Vitor Lory @vlory73 Apr 02 2016 09:14 @BKinahan no it didn't. i'll try to revisit the exercise, but for now the added var a = solved it Brendan Kinahan @BKinahan Apr 02 2016 09:15 @vlory73 odd! I'd be curious to see the full code before the change. Vitor Lory @vlory73 Apr 02 2016 09:15 i can try to put it up here. give me a few minutes as I'm not full proficient with the markdown stuff Brendan Kinahan @BKinahan Apr 02 2016 09:16 @vlory73 js your code here  feel free to copy/paste that and add your code :) Vitor Lory @vlory73 Apr 02 2016 09:17 hahahaha now it worked. but the code was looking like this ( i went through a few iterations until i got it to this point) // Setup var collection = { 2548: { album: "Slippery When Wet", artist: "Bon Jovi", tracks: [ "Let It Rock", "You Give Love a Bad Name" ] }, 2468: { album: "1999", artist: "Prince", tracks: [ "1999", "Little Red Corvette" ] }, 1245: { artist: "Robert Palmer", tracks: [ ] }, 5439: { album: "ABBA Gold" } }; // Keep a copy of the collection for tests var collectionCopy = JSON.parse(JSON.stringify(collection)); // Only change code below this line function update(id, prop, value) { if (value !== "" && prop !== "tracks"){ collection[id][prop] = value; } else if (prop == "tracks" && value !== "") { collection[id][prop].push(value); } else if (value === ""){ delete collection[id][prop]; } return collection; } // Alter values below to test your code update(1245, "tracks", "Adic"); sorry, i should have said "spoiler alert" i made a few mistakes on dot notation versus bracket notation @abrahamnm @abrahamnm Apr 02 2016 09:20 Hi everyone, i'm trying to remove special characters and spaces from a string. I'm using this code: str = str.replace(/(\W*)(\s*)/g, ""); But it doesn't remove the underscore character "_" .... Any ideas? Brendan Kinahan @BKinahan Apr 02 2016 09:23 @vlory73 that all looks fine, but one thing: you can use a nested if structure to avoid checking for the same condition twice, such as if(value!==""){ if(prop!=="tracks){ ... } else if(prop=="tracks"){ ... } } else { delete ... } @abrahamnm \W already includes spaces, so \s is unnecessary. You can use [\W|_], and drop the asterisks since it's checking one character at a time but with a global replace it'll get them all @abrahamnm that's "match a character that is either a non-word character, or underscore" @abrahamnm @abrahamnm Apr 02 2016 09:28 Ohhh, ok ok, thanks, i wasn't aware that \W includes spaces. thanks @BKinahan CamperBot @camperbot Apr 02 2016 09:28 abrahamnm sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles: :star: 1223 | @bkinahan | http://www.freecodecamp.com/bkinahan Vitor Lory @vlory73 Apr 02 2016 09:29 @BKinahan good tip thx CamperBot @camperbot Apr 02 2016 09:29 vlory73 sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles: :star: 1224 | @bkinahan | http://www.freecodecamp.com/bkinahan Rahul Nayak @pragyes31 Apr 02 2016 09:32 Hello campers I am having problem in "Title Case a Sentence" bonfire Vivek @vivek28111992 Apr 02 2016 09:32 @pragyes31 post your code Rahul Nayak @pragyes31 Apr 02 2016 09:32 here is my code : function titleCase(str) { /* step1: convert the string into an array seperated by space step2: using map, convert all array values to lowercase step3: use charAt function inside map function to make first alphabet of every word capitalise */ array=str.split(" "); array=array.map(function(val) { return val.toLowerCase(); }); array=array.map(function(val){ return val.charAt[0].toUpperCase(); }); // alert(array); } Vivek @vivek28111992 Apr 02 2016 09:34 @pragyes31 what error you are getting Brendan Kinahan @BKinahan Apr 02 2016 09:35 @pragyes31 looks like you'll have an array with only the first letter of each word, capitalized. Markus Kiili @Masd925 Apr 02 2016 09:36 @pragyes31 Use .charAt(i) Not [ ] Rahul Nayak @pragyes31 Apr 02 2016 09:36 @vivek28111992 type error: cannot read property "toUpperCase" of undefined Vivek @vivek28111992 Apr 02 2016 09:36 @BKinahan that what is needed, first letter of each word should be capitalized @Masd925 well spotted Rahul Nayak @pragyes31 Apr 02 2016 09:37 @BKinahan why only one letter, with chatAt, i am just trying to slect the first letter and capitalise it. not altering anthing else Vivek @vivek28111992 Apr 02 2016 09:37 @pragyes31 check @Masd925 answer Brendan Kinahan @BKinahan Apr 02 2016 09:37 @vivek28111992 no, "This is a sentence" -> [T,I,A,S] is not what is needed @pragyes31 strings are immutable, you're making a new array with only the first letter, capitalized Markus Kiili @Masd925 Apr 02 2016 09:38 @pragyes31 One .map() should be enough. Vivek @vivek28111992 Apr 02 2016 09:38 and inside one map all the operation should be done Rahul Nayak @pragyes31 Apr 02 2016 09:38 @Masd925 that's an another problem I am facing, wasn't sure if I can do those operation inside one map() Elbert Cortez @trip16661 Apr 02 2016 09:39 guys what api did you guys use in the quote challege? Vivek @vivek28111992 Apr 02 2016 09:40 @pragyes31 you can capitalized first index and make all other to lower case using substr Markus Kiili @Masd925 Apr 02 2016 09:40 @pragyes31 val is the original word and you make the new titlecased word with string operations and return it. Rahul Nayak @pragyes31 Apr 02 2016 09:41 ok, let me make some changes and see. Vivek @vivek28111992 Apr 02 2016 09:41 @pragyes31 just do this  return val.charAt(0).toUpperCase() + val.substr(1).toLowerCase(); Rahul Nayak @pragyes31 Apr 02 2016 09:43 @vivek28111992 thanks but i am not looking for a solution, I m looking for errors that I am making so that I can learn from it. I will use your solution if i am not able to clear it at all. Thanks a lot again :) CamperBot @camperbot Apr 02 2016 09:43 pragyes31 sends brownie points to @vivek28111992 :sparkles: :thumbsup: :sparkles: :star: 446 | @vivek28111992 | http://www.freecodecamp.com/vivek28111992 Vivek @vivek28111992 Apr 02 2016 09:44 @pragyes31 :+1: Elbert Cortez @trip16661 Apr 02 2016 09:49 anyone knows a good quote api (free)? Vivek @vivek28111992 Apr 02 2016 09:50 @trip16661 you dont need api Elbert Cortez @trip16661 Apr 02 2016 09:51 why not? Brendan Kinahan @BKinahan Apr 02 2016 09:55 @trip16661 I used an array :D Vivek @vivek28111992 Apr 02 2016 09:59 @BKinahan me too Elbert Cortez @trip16661 Apr 02 2016 09:59 @BKinahan ye but i want it to have many of them :P and perhaps using a input value to change the author Vivek @vivek28111992 Apr 02 2016 10:00 @trip16661 you can try finding it, and tell us f you find one :smile: Elbert Cortez @trip16661 Apr 02 2016 10:00 i found two but you need to pay them D: Vivek @vivek28111992 Apr 02 2016 10:04 @trip16661 I found this one https://theysaidso.com/api/ Elbert Cortez @trip16661 Apr 02 2016 10:08 the first one wants me to pay if i want to use it without putting it's logo there Prosvia @Prosvia Apr 02 2016 10:14 I I've got a problem, this: .replace(/ |,|./g,"") somhow removes this symbol : "/" from a string I mean array. Elbert Cortez @trip16661 Apr 02 2016 10:16 you want only letters and numbers? Prosvia @Prosvia Apr 02 2016 10:16 Yup. Elbert Cortez @trip16661 Apr 02 2016 10:16 there are ways to do it like that so you don't have to write every single symbol to replace google it out Prosvia @Prosvia Apr 02 2016 10:17 Hmm, well, I also want to learn why the hell the replace method acts the way it does and I don't get why it does that. Elbert Cortez @trip16661 Apr 02 2016 10:17 have you tried the documentation? Prosvia @Prosvia Apr 02 2016 10:18 I went through it and I think that I did everything correctly. Does something looks off? It should remove dots, commas and spaces, not this: "/" Wait there's a different problem here. It's not the replace function. So, okay, I got this string: 0_0 (: /-\ :) 0-0 And when I convert it to array I get it without the "/" I don't get that. Elbert Cortez @trip16661 Apr 02 2016 10:21 string.replace(/[&\/\#,+()$~%.'":*?<>{}]/g,'_')
Islam Ibakaev
@dagman
Apr 02 2016 10:29
done with wikipedia viewer any feedback is appreciated :smile: http://codepen.io/dagman/pen/xVLYOo
Elbert Cortez
@trip16661
Apr 02 2016 10:38
@dagman works ok
Ardian Reshani
@aRdiiaN04
Apr 02 2016 10:40

hello im stuck 
// Example
var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop();
// removedFromOurArray now equals 3, and ourArray now equals [1,2]

// Setup
var myArray = [["John", 23], ["cat", 2]];

// Only change code below this line.
var removedFromMyArray;
removedFromMyArray = ["John", 23].pop();


Elbert Cortez
@trip16661
Apr 02 2016 10:47
var removedFromMyArray; did you inicialized it ?
Ramana Venkata
@vramana
Apr 02 2016 11:09
@dagman Why not use $.getJSON(url, cb) instead of$.ajax and the attributes??
Aleksander Gębicki
@Takumar
Apr 02 2016 11:17
@aRdiiaN04 when you remove element from array, you should operate on your array myArray not ["John",23], so you solution is:
removedFromMyArray = myArray.pop();
Vitor Lory
@vlory73
Apr 02 2016 11:18
hi. anyone else had problems with the Math.random() exercise?
doesn't seem to work. I'm putting
return Math.random();
afk
Pete
@petegarvin1
Apr 02 2016 11:24
Can anyone give me advice on summing large numbers? I've got the answer I want as a binary string, but I need to convert that to a strong representation of the integer (base 10), and I can't do it without JavaScript bringing in scientific notation
Emil Aasa
@emilaasa
Apr 02 2016 11:31
@Spacecamel100 How large is your number?
DavidSavoir
@DavidSavoir
Apr 02 2016 11:31
var count = 0;

function countCheck(counter){
if (counter>0){
return(counter," Bet");
}
else
{
return(counter," Hold");
}
}

function cc(card) {
// Only change code below this line
switch(card){
case 2:
count++;
countCheck(count);
break;
case 3:
count++;
countCheck(count);
break;
case 4:
count++;
countCheck(count);
break;
case 5:
count++;
countCheck(count);
break;
case 6:
count++;
countCheck(count);
break;
case 7:
countCheck(count);
break;
case 8:
countCheck(count);
break;
case 9:
countCheck(count);
break;
case 10:
count--;
countCheck(count);
break;
case 'J':
count--;
countCheck(count);
break;
case 'Q':
count--;
countCheck(count);
break;
case 'K':
count--;
countCheck(count);
break;
case 'A':
count--;
countCheck(count);
break;
default:
console.log("That is not a valid card");
}

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Pete
@petegarvin1
Apr 02 2016 11:32
Too large :) like changes it to something with e+26 on the end
DavidSavoir
@DavidSavoir
Apr 02 2016 11:32
Any idea what's going in my code. The tests are not passing at all...
Pete
@petegarvin1
Apr 02 2016 11:32
Sorry @emilaasa I can't post th example, I'm on my mobile now
Emil Aasa
@emilaasa
Apr 02 2016 11:33
@Spacecamel100 Do you have a rough idea on how many bits ?
Emil Aasa
@emilaasa
Apr 02 2016 11:38
@Spacecamel100 if it's larger than $2^{53}-1$ then you can make an array of the bits and convert them separately
Pete
@petegarvin1
Apr 02 2016 11:39
@emilaasa yeah it is bigger than that. How would I make an array of the bits? Just split the binary string?
Emil Aasa
@emilaasa
Apr 02 2016 11:40
Yep! Depends on what you are doing with the sum tho I guess.
Pete
@petegarvin1
Apr 02 2016 11:41
Just returning it, it's an algorithm challenge. Is there a trick to converting the bits separately, I guess their array position dictates their value, as well as their actual value
Emil Aasa
@emilaasa
Apr 02 2016 11:42
Yeah it's just like the decimal system
Each position represents a value
Timothy Hong
@tim-hong
Apr 02 2016 11:42
Hmm, I'm doing the steamroller exercise (the one where you flatten nested arrays). And I can't figure out why I'm getting recursion depth errors.
DavidSavoir
@DavidSavoir
Apr 02 2016 11:42
afk
Pete
@petegarvin1
Apr 02 2016 11:44
@emilaasa thanks, I'll have a go at it :)
CamperBot
@camperbot
Apr 02 2016 11:44
spacecamel100 sends brownie points to @emilaasa :sparkles: :thumbsup: :sparkles:
:star: 334 | @emilaasa | http://www.freecodecamp.com/emilaasa
DavidSavoir
@DavidSavoir
Apr 02 2016 11:44
back
Emil Aasa
@emilaasa
Apr 02 2016 11:44
@Spacecamel100 No problem, hit me up again if you get stuck! :)
Doing some string/array manipulations you can have the index represent the value that you shuold raise 2 to
Timothy Hong
@tim-hong
Apr 02 2016 11:45
function steamroller(arr) {

ret = [];
for(i = 0; i < arr.length; i++) {
if(Array.isArray(arr[i])) {
ret = ret.concat(steamroller(arr[i]));
}
else {
ret.push(arr[i]);
}
}

return ret;
}
Even [1, [1]] gives me a recursion error.
Emil Aasa
@emilaasa
Apr 02 2016 11:45
to get the decimal system values from your binary string
Thaer Hamodeh
@Thaer1989
Apr 02 2016 11:54

hi guys ...( chunky monkey ) where is the problem
function chunkArrayInGroups(arr, size) {
var row=Math.floor(arr.length/size+1);
var newArr=[];
var x=0;
for(var i=0;i<row;i++)
{
for(var j=0;j<size;j++)
{
newArr[i][j]=arr[x];
x++;
}
}
return newArr;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7], 4);

Shantanu Pushkar
@shantanup9
Apr 02 2016 12:08

var result = "";
// Your code below this line

// Your code above this line
return result;
}

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

I am not able to do this. Please help me out.
Timothy Hong
@tim-hong
Apr 02 2016 12:08
I am beyond confused. I stopped getting my recursion error when I put var in front of ret and i.
Pascal T.
@omegga
Apr 02 2016 12:11
@tim-hong I did not dig into your code, but if you use var you create a local variable, and without you're reusing the same unique variable
@tim-hong I'm thinking maybe you're emptying ret each time you're doing a recursion
Timothy Hong
@tim-hong
Apr 02 2016 12:12
Thanks :)
thanks @yaax
CamperBot
@camperbot
Apr 02 2016 12:13
tim-hong sends brownie points to @yaax :sparkles: :thumbsup: :sparkles:
:star: 340 | @yaax | http://www.freecodecamp.com/yaax
Ayan Bhowmick
@Ayan5
Apr 02 2016 12:19
why every time captcha bother me?
Diego Mayer
@Chrono79
Apr 02 2016 12:22
@DavidSavoir replace return "Change Me" for countCheck(counter)
modify return(counter," Bet"); for return (counter+" Bet"); (the same with counter," Hold")
delete countCheck(counter) in every case
group case 2 to 6 , 7 to 9 and 10 to A in only 3 cases
Maria Campbell
@interglobalmedia
Apr 02 2016 12:30

Hi, I'm working on this Card Counting exercise, and I find it a bit confusing. Especially since I never even have "counted cards"! This is the code I have thus far: var count = 0;
var cardsSequence = [];
function cc(card) {
// Only change code below this line

if ( card >= 2 && card <= 6) {
count++;
return "5 Bet";
} else if (card >= 7 && card <= 9) {
return "0 Hold";
} else if ([10, "J", "Q", "K", "A"]) {
count--;
return "-5 Hold";
} else if ([3, 7, "Q", "8", "A"]) {
count--;
return "-1 Hold";
} else if ([2, "J", 9, 2, 7]) {
count++;
return "1 Bet";
} else if ([3, 2, "A", 10, "K"]) {
count--;
return "-1 Hold";
} else {
return "Change Me";
}
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A'); I have it through "-5 Hold" and have been just about trying everything under the sun, but can't figure the rest of it out. What am I missing here? Thanks!

Diego Mayer
@Chrono79
Apr 02 2016 12:31
Hi
Gintaras
@g1st
Apr 02 2016 12:32
why javascript have switch statement? for me it is the same as else if... or is there any difference?
Diego Mayer
@Chrono79
Apr 02 2016 12:34
@g1st they're similar, likewise for, while cycles
Gintaras
@g1st
Apr 02 2016 12:34
but what the difference is?
Diego Mayer
@Chrono79
Apr 02 2016 12:35
@interglobalmedia there are three cases (or if if you want) 2 to 6, 7 to 8 and 10 to A
@g1st nested ifs if long are difficult to read, cases are a little more clear

@interglobalmedia in your function you only have to evaluate 1 card at a time

else if ([3, 7, "Q", "8", "A"]) {
count--;
return "-1 Hold";
} else if ([2, "J", 9, 2, 7]) {
count++;
return "1 Bet";
} else if ([3, 2, "A", 10, "K"]) {
count--;
return "-1 Hold";
} else {
return "Change Me";
}

delete all that

Maria Campbell
@interglobalmedia
Apr 02 2016 12:40
Really? So I go through all the cards one at a time? Not a grouped sequence? But perhaps I can mix it up? I'll try that out. Thanks for the push in the right direction @Chrono79! I'll let you know how it goes.
CamperBot
@camperbot
Apr 02 2016 12:40
interglobalmedia sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 334 | @chrono79 | http://www.freecodecamp.com/chrono79
Maria Campbell
@interglobalmedia
Apr 02 2016 12:44
@Chrono79 Thanks for the link!
CamperBot
@camperbot
Apr 02 2016 12:44
interglobalmedia sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: interglobalmedia already gave chrono79 points
Gintaras
@g1st
Apr 02 2016 12:46
thanks @Chrono79
CamperBot
@camperbot
Apr 02 2016 12:46
g1st sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 335 | @chrono79 | http://www.freecodecamp.com/chrono79
ZokaKami
@ZokaKami
Apr 02 2016 12:48

function phoneticLookup(val) {
var result = "";

// Only change code below this line
var result = {
"bravo":"Boston",
"charlie":"Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot":"Frank"
};
// Only change code above this line
return result;
// Change this value to test
phoneticLookup("foxtrot");

} i dont get what is wrong with the code

any help?
swishk
@swishk
Apr 02 2016 12:51
I just did this lesson :) I think I'm only one ahead of you.
ZokaKami
@ZokaKami
Apr 02 2016 12:52
nvm just figured it out
testing objects with properties?
swishk
@swishk
Apr 02 2016 12:52
The object variable looks correct. Now you need to make the result contain the correct answer
cool.
@ZokaKami can you let me know what you get for the "Testing Objects for Properties" lesson. I got the correct answer but I'm not to sure if i went about in the simplest method
ZokaKami
@ZokaKami
Apr 02 2016 12:55
will do
how do i return a propertys value again?
i forgot
Diego Mayer
@Chrono79
Apr 02 2016 12:56

@ZokaKami this is wrong:

var result = "";
// Only change code below this line
var result = {

the second time you should redeclare the var, so the secon var is not needed

ajaybti
@ajaybti
Apr 02 2016 12:57
Caesars Cipher help me
ZokaKami
@ZokaKami
Apr 02 2016 12:57
i figured out my mistake in that one
Diego Mayer
@Chrono79
Apr 02 2016 12:57
@ajaybti post your code
Semikin Nikita
@nightrunner91
Apr 02 2016 12:58
hi people. anyone can help me with lesson 41 "word blanks"? https://www.freecodecamp.com/challenges/word-blanks
at least how I need to start. can't figure it out. :(
Diego Mayer
@Chrono79
Apr 02 2016 12:59
@nightrunner91 sure, pm your code
ZokaKami
@ZokaKami
Apr 02 2016 12:59
@swishk if (myObj.hasOwnProperty(checkProp) === true){
return myObj[checkProp];
}
else {
}
this is how i did it
tho i dont think i need the === true part
Diego Mayer
@Chrono79
Apr 02 2016 13:00
@ZokaKami yes, don't needed
swishk
@swishk
Apr 02 2016 13:00
nope you don't.
@ZokaKami Thanks. I did the same but I checked again for a false return. Your way is simple to make else always false.
CamperBot
@camperbot
Apr 02 2016 13:02
swishk sends brownie points to @zokakami :sparkles: :thumbsup: :sparkles:
:star: 2 | @zokakami | http://www.freecodecamp.com/zokakami
ZokaKami
@ZokaKami
Apr 02 2016 13:04
bownie points lol
how did you add a new album in the Introducing JavaScript Object Notation JSON challenge
nvm i missed one coma , thats why it didnt work
atcchh
@atcchh
Apr 02 2016 13:14
@interglobalmedia have you fixed Counting Card?
@interglobalmedia // Only change code below this line why did you add "var cardsSequence = [];" ???
Bogdan3
@Bogdan3
Apr 02 2016 13:15
hey i'm working on Return Largest Numbers in Arrays challenge , my code is good but it wont accept it becaues is gives back [5,27,39,1001] not [27,5,39,1001]
Diego Mayer
@Chrono79
Apr 02 2016 13:15
@Bogdan3 Show your code
Emil Aasa
@emilaasa
Apr 02 2016 13:15
@Bogdan3 lets see some code
Bogdan3
@Bogdan3
Apr 02 2016 13:16
function largestOfFour(arr) {
var x=0;
var maxArr=[];
for(var i= 0; i < arr.length; i++){
for(var j = 0; j< arr[i].length; j++){
if( x < arr[i][j]){
x = arr[i][j];
}
} maxArr.push(x);
}
return maxArr;
}
Aleksander Gębicki
@Takumar
Apr 02 2016 13:17
@Bogdan3 you have to reset x variable before entering second loop, without that it stores largest value from previous subarray.
Apart from that your solution seems complete :thumbsup:
Bogdan3
@Bogdan3
Apr 02 2016 13:19
thanks @Takumar now is working
CamperBot
@camperbot
Apr 02 2016 13:19
bogdan3 sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 2951 | @takumar | http://www.freecodecamp.com/takumar
Aleksander Gębicki
@Takumar
Apr 02 2016 13:19
@Bogdan3 you're welcome, how you did this?
Bogdan3
@Bogdan3
Apr 02 2016 13:20
@Takumar i moved "var x=0; "in the first loop
or are you referring to the code?
Aleksander Gębicki
@Takumar
Apr 02 2016 13:23
@Bogdan3 I would recommend you to assign value of first element of arr[i] subarray to the x variable not 0, in such way your solution will work even when you will have negative values in your arrays.
migraf
@migraf
Apr 02 2016 13:24
hey i have a question regarding the caesars cipher i think i did it right and it matches some characters correctly but some are not matched
function rot13(str) { // LBH QVQ VG!
var newStr = "";
for (var i = 0; i<str.length;i++){
if(str[i].match(/^[a-z0-9]+\$/i)){
newStr += String.fromCharCode(str[i].charCodeAt(0) - 13);
}
else
newStr += str[i];

}
return newStr;
}

// Change the inputs below to test
rot13("SERR CVMMN!");
Bogdan3
@Bogdan3
Apr 02 2016 13:24
@Takumar so var x = arr[i][0]?
migraf
@migraf
Apr 02 2016 13:24
can somebody give me a hint?
Diego Mayer
@Chrono79
Apr 02 2016 13:25
@migraf yes, chars go from 65 to 90 if I'm not wrong
Alphabetic I mean
You should evaluate if the charcode you have to convert falls out of that and correct it
migraf
@migraf
Apr 02 2016 13:26
yeah but shouldn't i get either all correct or all wrong answers?
that's what i dont get
ah now i think i know what you mean
Aleksander Gębicki
@Takumar
Apr 02 2016 13:28
@Bogdan3 right :-)
ZokaKami
@ZokaKami
Apr 02 2016 13:29
is anyone doing Record Collection right now?
Diego Mayer
@Chrono79
Apr 02 2016 13:33
@ZokaKami No, but if you need advise, just ask
Martialis39
@Martialis39
Apr 02 2016 13:34
@Chrono79 Would you answer a question on card counting, please?
Diego Mayer
@Chrono79
Apr 02 2016 13:34
@Martialis39 sure
Martialis39
@Martialis39
Apr 02 2016 13:35
@Chrono79 Thanks! I apologize for the code formatting, I dont know how to do it any better
CamperBot
@camperbot
Apr 02 2016 13:35
martialis39 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 336 | @chrono79 | http://www.freecodecamp.com/chrono79
Martialis39
@Martialis39
Apr 02 2016 13:35

var answer = '';
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count = count + 1;
if (count < 0) {
return count + ' ' + 'Bet';

  } else if (count === 0) {
return count + ' ' + 'Hold';

} else if (count > 0 ) {
return count + ' ' + 'Hold';

}
break;
case 7:
case 8:
case 9:
if (count < 0) {
return count + ' ' + 'Bet';

} else if (count === 0) {
return count + ' ' + 'Hold';

} else if (count > 0 ) {
return count + ' ' + 'Hold';

}
break;
case 10:
case 'J':
case "Q":
case 'K':
case 'A':
count -= 1;
if (count < 0) {
return count + ' ' + 'Bet';

} else if (count === 0) {
return count + ' ' + 'Hold';

} else if (count > 0 ) {
return count + ' ' + 'Hold';

}

}

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

ZokaKami
@ZokaKami
Apr 02 2016 13:35
i need lots of advice, i am not sure if i am doing anything right
Diego Mayer
@Chrono79
Apr 02 2016 13:35
help code format
CamperBot
@camperbot
Apr 02 2016 13:35

## :point_right: code formatting [wiki]

### Multi line Code

js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

 ⇦ Type 3 backticks, then press [enter ⏎]

### Single line Code

This an inline <paste code here> code formatting with a single backtick() at start and end around the code.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

Aleksander Gębicki
@Takumar
Apr 02 2016 13:36
@Martialis39 you are doing good, but move your testing whethere variable is positive or negative outside your switch() {} statement, do it once on the end of your code.
ZokaKami
@ZokaKami
Apr 02 2016 13:36
i used count += 1 instead of the if statement
@Chrono79 first to ask how do i call the props with the ID that we input
return collection[id] ?
Aleksander Gębicki
@Takumar
Apr 02 2016 13:37
@Martialis39 also because you are returning count + " Hold" message you can join conditions count === 0 and count > 0
Diego Mayer
@Chrono79
Apr 02 2016 13:37
@Martialis39 Like Takumar said, do that and also you don't need to separate count === 0 in your if/else
Martialis39
@Martialis39
Apr 02 2016 13:37
Ok! Thanks guys! I\ll give it a try. IT seems to be working somewhat but its not giving me the challenge pass!
Diego Mayer
@Chrono79
Apr 02 2016 13:38
@ZokaKami That's right, when your prop name is a var, you should use [varName]
ZokaKami
@ZokaKami
Apr 02 2016 13:39
but when i do it like that it returns everything , not just the content of the id
Diego Mayer
@Chrono79
Apr 02 2016 13:39
@ZokaKami pm yor code
Aleksander Gębicki
@Takumar
Apr 02 2016 13:39
@Martialis39 I guess you reversed conditions, you should "Bet" when count is positive and "Hold" when negative!
Martialis39
@Martialis39
Apr 02 2016 13:40
:O you\re right!
ZokaKami
@ZokaKami
Apr 02 2016 13:40
i restarted it
1 sec
Martialis39
@Martialis39
Apr 02 2016 13:40
Its always the simplest of things isn\t it :D
ZokaKami
@ZokaKami
Apr 02 2016 13:41
Diego Mayer
@Chrono79
Apr 02 2016 13:41
Always look at the console for what is returned
ZokaKami
@ZokaKami
Apr 02 2016 13:41
i just added return collection[id]; in the function to check if it works, and it return the whole collection
Ivan Temchur
@ttemcha
Apr 02 2016 13:41
hello, guys can you help me with this ?
function queue(arr, item) {
// Your code here

return arr.push(item).shift();  // Change this line
}
its not workung
working
ZokaKami
@ZokaKami
Apr 02 2016 13:42
dont you have to do it in 2 lines?
one for push one for shift
Martialis39
@Martialis39
Apr 02 2016 13:42
yes, I did it that way at least
Aleksander Gębicki
@Takumar
Apr 02 2016 13:42
@Martialis39 unfortunately not always :-)
So is it working now?
Martialis39
@Martialis39
Apr 02 2016 13:42
@Takumar Yes, thanks!
CamperBot
@camperbot
Apr 02 2016 13:42
martialis39 sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 2952 | @takumar | http://www.freecodecamp.com/takumar
Martialis39
@Martialis39
Apr 02 2016 13:43
@Takumar Just 2 more quick things, just for my own education : after the If/Else in the second batch of cases, if I remove 'break' from the end I get an error
but i have no 'break' at the very end where I have the same structure
Ivan Temchur
@ttemcha
Apr 02 2016 13:44
shift is not a fucntion...
function queue(arr, item) {
// Your code here
var newArray = arr.push(item);
return newArray.shift();  // Change this line
}
ZokaKami
@ZokaKami
Apr 02 2016 13:45
@chrono79 any luck?
Ivan Temchur
@ttemcha
Apr 02 2016 13:45
any thoughts ?
karim khalfaoui
@Kaiiim
Apr 02 2016 13:45

hi everone, can you help me i dont understand how to resolve this problem : Manipulate Arrays With pop
and the code is :
// Example
var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop();
// removedFromOurArray now equals 3, and ourArray now equals [1,2]

// Setup
var myArray = [["John", 23], ["cat", 2]];

// Only change code below this line.
var removedFromMyArray; myArray.pop();

Spartano
@Spartano
Apr 02 2016 13:45
hello, i am doing the Random Quote Chalenge, i am using Node with Heroku for getting the quotes from external sites onto my website. I was wondering if there was another aproach for getting the JSON from websites other that Node. Thank You
Aleksander Gębicki
@Takumar
Apr 02 2016 13:46
@Martialis39 at the very end of your code you don't have any cases to check so there is no need to break anything. With break you divide your cases to batches to test. Cases are checked from start to the end
Diego Mayer
@Chrono79
Apr 02 2016 13:46
@ZokaKami I'm looking at it
Martialis39
@Martialis39
Apr 02 2016 13:47
Oh @Takumar , so I only need break if there are more cases yet to come?
Vivek
@vivek28111992
Apr 02 2016 13:47
@ttemcha newArray needs to be array to use shift
Martialis39
@Martialis39
Apr 02 2016 13:47
@ttemcha can you tell me what is the exact name of the challenge?
Ivan Temchur
@ttemcha
Apr 02 2016 13:48
@Martialis39 Stand in Line
Maria Campbell
@interglobalmedia
Apr 02 2016 13:48

Counting Cards Exercise: Well, now I tried it this way with switch() and then various was using count variable, but still isn't working beyond "-5 Hold" : var count = 0;

function cc(card) {
// Only change code below this line
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count += 1;
return "5 Bet";
case 7:
case 8:
case 9:
return "0 Hold";
case 10:
case "J":
case "Q":
case "K":
case "A":
count -= 1;
return "-5 Hold";
case 3:
case 7:
case "Q":
case 8:
case "A":
count -= 2;
return "-1 Hold";
case 2:
case "J":
case 9:
case 2:
case 7:
count -= 1;
return "1 Bet";
case 3:
case 2:
case "A":
case 10:
case "K":
count -= 3;
return "-1 Hold";
default:
count = 0;
return "Change Me";
// Only change code above this line
}
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A'); I'm not a big fan of switch() and never really use it.

Ivan Temchur
@ttemcha
Apr 02 2016 13:48
@vivek28111992 but the result of .push() is an array
@vivek28111992 or not ?
alpox
@alpox
Apr 02 2016 13:49
@ttemcha no its a number -- the number of elements in the array after your push
Aleksander Gębicki
@Takumar
Apr 02 2016 13:49
@Martialis39 yes.
Ivan Temchur
@ttemcha
Apr 02 2016 13:49
@alpox got it, thanks
CamperBot
@camperbot
Apr 02 2016 13:49
ttemcha sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star: 451 | @alpox | http://www.freecodecamp.com/alpox
Martialis39
@Martialis39
Apr 02 2016 13:49
@Takumar Excellent, thank you very much! No more questions for now :)
CamperBot
@camperbot
Apr 02 2016 13:49
martialis39 sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:warning: martialis39 already gave takumar points
Brendan Kinahan
@BKinahan
Apr 02 2016 13:50
@interglobalmedia you should return the current count and what betting decision you should make depending on the count
Diego Mayer
@Chrono79
Apr 02 2016 13:50
@interglobalmedia your function only evaluate 1 card at a time, get rid of this:
case 3:
case 7:
case "Q":
case 8:
case "A":
count -= 2;
return "-1 Hold";
case 2:
case "J":
case 9:
case 2:
case 7:
count -= 1;
return "1 Bet";
case 3:
case 2:
case "A":
case 10:
case "K":
count -= 3;
return "-1 Hold";
default:
count = 0;
return "Change Me";
Aleksander Gębicki
@Takumar
Apr 02 2016 13:50
@Martialis39 you're welcome :-)
Diego Mayer
@Chrono79
Apr 02 2016 13:50
@interglobalmedia also you are missing break; after every cases group
Brendan Kinahan
@BKinahan
Apr 02 2016 13:51
@Chrono79 arguably break isn't needed after a return statement, but that part is also incorrect :P
Diego Mayer
@Chrono79
Apr 02 2016 13:52
@BKinahan You didn't let me finish, I was going to say evaluate count outside the switch, but you're right
ZokaKami
@ZokaKami
Apr 02 2016 13:57
nope, i am completely stuck, i am unable to call anything out of the object. Everything i do just prints out the whole object
Diego Mayer
@Chrono79
Apr 02 2016 13:58
@ZokaKami The goal is to modify the object so I guess they made it that way on pourpose
Forget about it and modify it, if you want, use console.log() and developer tools if you use Chrome or alert()
ZokaKami
@ZokaKami
Apr 02 2016 13:59
still its weird i cant call the id i want
Maria Campbell
@interglobalmedia
Apr 02 2016 14:04
@Chrono79 @BKinahan I already tried with current count and didn't work. Already tried with break didn't work. @Chrono79 I thought you said to do it one at a time. Before I did have it grouped and it didn't work. I thought I did have it "grouped" here though in a way. I'll go back and try it with break again.
Diego Mayer
@Chrono79
Apr 02 2016 14:05
The console you see in the challenges not always gets the return of your function, i.e. in the Counting cards exercise it should return all five results because you're calling your function 5 times

@interglobalmedia
your switch should look like this:

switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count += 1;
break;
case 7:
case 8:
case 9:
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count -= 1;
break;
}

Evaluate the value of count outside the switch and return count + Bet or Hold following the exercise's rules

gotta go, afk
Achilleas Papakonstantinou
@AchiPapakon
Apr 02 2016 14:16

Hi, why can't I center my button "Again!" with the following css?

#again {
margin:0px auto;
}

http://codepen.io/AchiPapakon/pen/BKwxaE

Coen
@coenieman
Apr 02 2016 14:17
its without the px, just margin:0 auto;
Achilleas Papakonstantinou
@AchiPapakon
Apr 02 2016 14:18
@coenieman still, doesn't work. I've tried margin-left: auto and right but no luck.
Coen
@coenieman
Apr 02 2016 14:19
ah, il have a look :)
weird, dont know why it doesnt work, my guess is that there is something wrong in the hierarchy, but even the ugly !important doesnt help
tell me if you found an answer, u got me curious :P @AchiPapakon
alpox
@alpox
Apr 02 2016 14:23
@AchiPapakon Add a display: block; to your #again
Achilleas Papakonstantinou
@AchiPapakon
Apr 02 2016 14:25
@coenieman ok
@alpox that fixed it! Thanks :)
CamperBot
@camperbot
Apr 02 2016 14:25
achipapakon sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star: 452 | @alpox | http://www.freecodecamp.com/alpox
alpox
@alpox
Apr 02 2016 14:26
@AchiPapakon You're welcome :-)
Alex N.
@N0bl3
Apr 02 2016 14:28
Hi! for the simon game project i need to get some free sounds. Do you know any nice ogg lib fot his kind of projects?
Coen
@coenieman
Apr 02 2016 14:30
@AchiPapakon if you apply text-align : center; on the div that contains the button. so in your case the body. it has the right effect. still the margin should work. but i dont know why it doesnt
alpox
@alpox
Apr 02 2016 14:31
@coenieman Its fixed already
Coen
@coenieman
Apr 02 2016 14:31
@alpox howcome that this solves the problem?, is this necasary for centering any kind of button?
alpox
@alpox
Apr 02 2016 14:32
@coenieman The problem was that the button is an inline element what means it is treated like text. The margin auto applies not to inline elements, so a display: block on the button element fixes it.
Coen
@coenieman
Apr 02 2016 14:32
great! thx @alpox that also explains why the text-align did work.
CamperBot
@camperbot
Apr 02 2016 14:32
coenieman sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star: 453 | @alpox | http://www.freecodecamp.com/alpox
Coen
@coenieman
Apr 02 2016 14:34
maybe you could help me with something aswell...
my lookup table doesnt work. only the last data does. in this case foxtrot, but it doesnt seem te be able to acces the rest of it.
var lookup = {
"alpha": result = "Adams",
"bravo": result = "Boston",
"charlie": result = "Chicago",
"delta": result = "Denver",
"echo": result = "Easy",
"foxtrot": result = "Frank"
};
alpox
@alpox
Apr 02 2016 14:36
@coenieman Well only "Frank" gets stored in result at the end because you override your variable result on creation of every entry
@coenieman Thats not how you access objects
Coen
@coenieman
Apr 02 2016 14:38

that makes sence, but in this case should nt lookup[alpha];
have the result of Adams?

it is the same as the example that is given, still something is clearly wrong

alpox
@alpox
Apr 02 2016 14:38
@coenieman Just take a close look on how they access objects in the example on the left:
var alpha = {
1:"Z",
2:"Y",
3:"X",
4:"W",
...
24:"C",
25:"B",
26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"

var value = 2;
alpha[value]; // "Y"
@coenieman You mean lookup["alpha"]? That should RETURN the value "Adams"
@coenieman Can you paste your whole code here?
Coen
@coenieman
Apr 02 2016 14:39
sure

// Setup
function phoneticLookup(val) {
var result = "";

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

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

// Change this value to test
phoneticLookup("charlie");
// Setup
function phoneticLookup(val) {
var result = "";

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

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

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

alpox
@alpox
Apr 02 2016 14:40
Please with code format :-)
Coen
@coenieman
Apr 02 2016 14:40
ghehe, dont know how, can you tell me ? :P
alpox
@alpox
Apr 02 2016 14:40

Must look like that in your chat:
js

<here comes your code>


go sure that you use backticks and these are on their own lines
Markus Kiili
@Masd925
Apr 02 2016 14:41
help format
CamperBot
@camperbot
Apr 02 2016 14:41

## :point_right: code formatting [wiki]

### Multi line Code

js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

 ⇦ Type 3 backticks, then press [enter ⏎]

### Single line Code

This an inline <paste code here> code formatting with a single backtick() at start and end around the code.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

Coen
@coenieman
Apr 02 2016 14:42
'''js
CamperBot
@camperbot
Apr 02 2016 14:42
:bulb: to format code use backticks!  more info
alpox
@alpox
Apr 02 2016 14:42
@Masd925 I have the feeling that this help just confuses the people xD
Coen
@coenieman
Apr 02 2016 14:42

'''js
// Setup
function phoneticLookup(val) {
var result = "";

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

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

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

CamperBot
@camperbot
Apr 02 2016 14:42
:bulb: to format code use backticks!  more info
alpox
@alpox
Apr 02 2016 14:42
@coenieman As camperbot says, use backticks, not streight ticks
Coen
@coenieman
Apr 02 2016 14:42
sorry about that :P
alpox
@alpox
Apr 02 2016 14:42
Btw. you can edit your posts
Moisés Man
@moigithub
Apr 02 2016 14:42
backtick usually is above TAB key (or next to enter/p key )
Coen
@coenieman
Apr 02 2016 14:42

js// Setup
function phoneticLookup(val) {
var result = "";

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

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

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


alpox
@alpox
Apr 02 2016 14:42
@moigithub you have weird keyboard layouts :D
Moisés Man
@moigithub
Apr 02 2016 14:43
:)
Brian Zelip
@brianzelip
Apr 02 2016 14:43
@coenieman the result = should not be in any of those key:value pairs.
alpox
@alpox
Apr 02 2016 14:43
@coenieman Almost :-) the ticks belong on their own line (shift-enter)
Coen
@coenieman
Apr 02 2016 14:43
lol ok
Markus Kiili
@Masd925
Apr 02 2016 14:43
@coenieman You should not touch the lookup object.
Coen
@coenieman
Apr 02 2016 14:43
// Setup
function phoneticLookup(val) {
var result = "";

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

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

// Change this value to test
phoneticLookup("charlie");
yaay
Moisés Man
@moigithub
Apr 02 2016 14:44
:clap:
Brian Zelip
@brianzelip
Apr 02 2016 14:44
only like this:
var lookup = {
};