25th
Aug 2016
Walid Ashri
@walidashri
Aug 25 2016 00:00
all test run right except No 4 give me wrong
Joseph
@revisualize
Aug 25 2016 00:00
@robertkub How many variables do you have in your function? And what are they?
Robert Kub
@robertkub
Aug 25 2016 00:00

@revisualize
function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

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

// Change the inputs below to test your code
convertToF(30);

Joseph
@revisualize
Aug 25 2016 00:00
@robertkub Great.
@robertkub How many variables do you have in your function? And what are they?
Robert Kub
@robertkub
Aug 25 2016 00:01
@revisualize convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86
Andrew Kay
@andrewjkay
Aug 25 2016 00:01
@AshriSoft would you paste your code?
Joseph
@revisualize
Aug 25 2016 00:01
@robertkub I know. I've completed the challenge several times.
Thanks for that.
Walid Ashri
@walidashri
Aug 25 2016 00:01

function destroyer(arr) {
// Remove all the values

var n = Array.from(arguments);
n = n.slice(1,n.length);
arr.filter(function(){
var i = 0;

``````while(i  < arr.length+1){
if(n.indexOf(arr[i])>-1){
arr.splice(i,1);
}
i++;
}``````

});
console.log(arr);
return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

Joseph
@revisualize
Aug 25 2016 00:02
@robertkub :)
Robert Kub
@robertkub
Aug 25 2016 00:02
@revisualize Im very new to java script I am sorry.. do you have everything you need?
Andrew Kay
@andrewjkay
Aug 25 2016 00:03
@AshriSoft this is above me at the moment, thought you were talking about a different exercise
Joseph
@revisualize
Aug 25 2016 00:03
@robertkub I don't need anyhing. Except for you to maybe answer a few questions.
Robert Kub
@robertkub
Aug 25 2016 00:03
@revisualize Okay!
Walid Ashri
@walidashri
Aug 25 2016 00:03
@andrewjkay txs anyway
Joseph
@revisualize
Aug 25 2016 00:04
@robertkub What is the math to convert Celsius to Fahrenheit?
@robertkub How many variables do you have in your function? And what are they?
Robert Kub
@robertkub
Aug 25 2016 00:05
@revisualize temp in celsius time 9/5 plus 32
it says not to worry about function yet
im not sure what they are
Joseph
@revisualize
Aug 25 2016 00:06
@robertkub The variables in your function are `celsius` and `fahrenheit`
Diego Mayer
@Chrono79
Aug 25 2016 00:06
@AshriSoft you're using filter wrong
filter should have a function that returns true or false, and it keeps the values if it's true or discard them if it's false
Joseph
@revisualize
Aug 25 2016 00:06
@robertkub You need `fahrenheit` to = the math that converts `celsius` to fahrenheit.
Walid Ashri
@walidashri
Aug 25 2016 00:07
@Chrono79 what do u mean?
Joseph
@revisualize
Aug 25 2016 00:08
@robertkub The `celsius` variable is passed into the function:
``````function convertToF ( celsius ) {
}``````
Walid Ashri
@walidashri
Aug 25 2016 00:09
nope disagree with that @Chrono79
Diego Mayer
@Chrono79
Aug 25 2016 00:11
Joseph
@revisualize
Aug 25 2016 00:11
@robertkub How are things coming along?
llamatarianism
@llamatarianism
Aug 25 2016 00:11
doesn't matter if you disagree with it @AshriSoft
it's a fact
I can disagree that the earth is round, that won't change its shape
Walid Ashri
@walidashri
Aug 25 2016 00:11
@llamatarianism but it's :D
Robert Kub
@robertkub
Aug 25 2016 00:11
@revisualize nothing is happening
Gray Hildreth
@grayhildreth
Aug 25 2016 00:12

Is there anything wrong with this code?

I'm having trouble passing this challenge...
https://www.freecodecamp.com/challenges/selecting-from-many-options-with-switch-statements

``````
function caseInSwitch(val) {
// Only change code below this line

swicth (val) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4;
break;

}

// Only change code above this line
}

// Change this value to test
caseInSwitch(1);``````
Anthony Drane
@Antiaccess
Aug 25 2016 00:12
Hey guys, I'm working on bounding non numbers/words from an array. The null items are passing through the check, not sure why though
``````function bouncer(arr) {
// Don't show a false ID to this bouncer.
function checkItem(item){
if (item === true || item === false || item === 0 || item === undefined || item === null || item === "") {
return false;
}
console.log(item === null);
return true;
}
return arr.filter(checkItem);
}

//bouncer([7, "ate", "", false, 9]);
bouncer([false, null, 0, NaN, undefined, ""]);``````
bouncing*
llamatarianism
@llamatarianism
Aug 25 2016 00:12
doesn't look like they are
did you mean the `NaN` items?
Diego Mayer
@Chrono79
Aug 25 2016 00:12
@Antiaccess are you sure it's not NaN the problem?
Anthony Drane
@Antiaccess
Aug 25 2016 00:13
@Chrono79 when I tried to do `item(isNaN)` the tests went to true for almost everything
Diego Mayer
@Chrono79
Aug 25 2016 00:13
@grayhildreth misspelled switch
@Antiaccess that's because there are other ways for NaN checking
Gray Hildreth
@grayhildreth
Aug 25 2016 00:14
Ohhhh boy... Thank you! @Chrono79
CamperBot
@camperbot
Aug 25 2016 00:14
:star2: 1903 | @chrono79 |http://www.freecodecamp.com/chrono79
grayhildreth sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Anthony Drane
@Antiaccess
Aug 25 2016 00:14
@Chrono79 okay ill do some research
Robert Kub
@robertkub
Aug 25 2016 00:15
@revisualize thank you for your help but its looking for this "var fahrenheit = (0 - 32) * (5/9);"
CamperBot
@camperbot
Aug 25 2016 00:15
robertkub sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1722 | @revisualize |http://www.freecodecamp.com/revisualize
Diego Mayer
@Chrono79
Aug 25 2016 00:15
marija
@44552
Aug 25 2016 00:17

// Example
var changed = 0;

function change(num) {
return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 0;

function processArg(num) {
return (num + 3) / 5;
}

// Only change code below this line

hello, can anyone help me with this challenge, i do not understand very well what should i do with this code

encount
@encount
Aug 25 2016 00:17
@Antiaccess you know you dont need any of those checks - there is one thing in JS that will check them all
Anthony Drane
@Antiaccess
Aug 25 2016 00:18
@encount okay, i'm not familiar with anything yet
Diego Mayer
@Chrono79
Aug 25 2016 00:18
@encount let him do the long way before, so he learns how to check for NaN in the process
Anthony Drane
@Antiaccess
Aug 25 2016 00:19
@Chrono79 when I put the isNaN in it still removes all the strings from the array
@Chrono79 do I have to completely reformulate my function?
Diego Mayer
@Chrono79
Aug 25 2016 00:19
@Antiaccess that's why I said isNaN is not that useful and you should check another way
``The latest version of ECMAScript (ES2015) contains the Number.isNaN() function. Number.isNaN(x) will be a reliable way to test whether x is NaN or not. Even with Number.isNaN, however, the meaning of NaN remains the precise numeric meaning, and not simply, "not a number". Alternatively, in absense of Number.isNaN, the expression (x != x) is a more reliable way to test whether variable x is NaN or not, as the result is not subject to the false positives that make isNaN unreliable.``
Joseph
@revisualize
Aug 25 2016 00:20
@robertkub That actually isn't correct.
@revisualize "variable" times 9/5 plus 32
@revisualize temp in celsius time 9/5 plus 32
Moisés Man
@moigithub
Aug 25 2016 00:21
:crying_cat_face: went to doc.. and she said tengo arenilla en los riñones :crying_cat_face:
Patrick S
@thinktwice84
Aug 25 2016 00:21
Hey, I can't get the .getCurrentPosition() method to work in codepen. I've literally just copied and pasted the code straight from the W3 site and it's not working. http://codepen.io/thinktwice84/pen/jAjBxR?editors=1011
Joseph
@revisualize
Aug 25 2016 00:21
This message was deleted
Patrick S
@thinktwice84
Aug 25 2016 00:22
well nvm, it's working in firefox just not chrome.
Diego Mayer
@Chrono79
Aug 25 2016 00:22
@thinktwice84 getCurrentPosition() and watchPosition() no longer work on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.
Patrick S
@thinktwice84
Aug 25 2016 00:23
@Chrono79 good to know
Keith
@kmcdougal
Aug 25 2016 00:24
I'm not understanding the directions of Escaping Literal Quotes in Strings (I am a "double quoted" string inside?)
Diego Mayer
@Chrono79
Aug 25 2016 00:25

@kmcdougal
Instructions
Use backslashes to assign a string to the myStr variable so that if you were to print it to the console, you would see:

I am a "double quoted" string inside "double quotes".

Anthony Drane
@Antiaccess
Aug 25 2016 00:26
@Chrono79 thanks mate! I re-read the page and got the message that it's converting the strings to numbers to test them. Rather the Number.isNan function removes strings from the pool to test (and anything that isn't a number). Cheers
CamperBot
@camperbot
Aug 25 2016 00:26
antiaccess sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1904 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Aug 25 2016 00:26
You need to escape the double quotes of that string
You should use two double quotes (") and four escaped double quotes (\").
Variable myStr should contain the string: I am a "double quoted" string inside "double quotes".
@kmcdougal
Anthony Drane
@Antiaccess
Aug 25 2016 00:27
@encount So I've figured it out, what is a simpler way to check for non-numbers/strings (cause I tried .isANumber and .isAString and they didn't seem to work)
encount
@encount
Aug 25 2016 00:28
@Antiaccess ```var filteredArray = arr.filter(Boolean); return filteredArray;```
Keith
@kmcdougal
Aug 25 2016 00:28
var myStr = \"I am a "double quoted" string \" inside "double quotes." ??
Diego Mayer
@Chrono79
Aug 25 2016 00:29
@kmcdougal I see only 2 escaped quotes and 4 common double quotes
Anthony Drane
@Antiaccess
Aug 25 2016 00:29
@encount okay, so the logic being that NaN, 0, "", null, undefined etc. all return `false`?
Thomas
@RoboMantis
Aug 25 2016 00:30
CamperBot
@camperbot
Aug 25 2016 00:30
no wiki entry for: `please`
Anthony Drane
@Antiaccess
Aug 25 2016 00:30
while strings and numbers return `true`?
Keith
@kmcdougal
Aug 25 2016 00:30
okay, thank you @Chrono79
CamperBot
@camperbot
Aug 25 2016 00:30
kmcdougal sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1905 | @chrono79 |http://www.freecodecamp.com/chrono79
Thomas
@RoboMantis
Aug 25 2016 00:30
I feel like the learning rate is too high for this question compared to the last question it bumped up quit a bit.
encount
@encount
Aug 25 2016 00:31
@Antiaccess yup
Anthony Drane
@Antiaccess
Aug 25 2016 00:31
@RoboMantis If you copy your code and put 3 apostrophies at the beginning and end, it will make your code appear in the chat window as readable
`
Diego Mayer
@Chrono79
Aug 25 2016 00:32
Kantra
@removed~kantrakantra
Aug 25 2016 00:32
Can anybody tell me why this function isn't returning a number from `Math.random()`?
``````function normal(){

return Math.random();

}``````
Anthony Drane
@Antiaccess
Aug 25 2016 00:33
@Chrono79 I really need to stop trying to figure it out by my own assumptions and actually read those linked pages ahah
@encount thanks Julian, thanks @Chrono79
CamperBot
@camperbot
Aug 25 2016 00:33
antiaccess sends brownie points to @encount and @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: antiaccess already gave chrono79 points
Diego Mayer
@Chrono79
Aug 25 2016 00:34
@kantrakantra and what is it returning? Math.random() should return a number between 0 (including 0) and 1 (not including it)
Stephen James
@sjames1958gm
Aug 25 2016 00:34
@kantrakantra Can you show a call to that function?
Walid Ashri
@walidashri
Aug 25 2016 00:35
@kantrakantra it works but u have to call the function
Stephen James
@sjames1958gm
Aug 25 2016 00:35
@RoboMantis this.setGear and this.getGear are supposed to be functions inside of Bike.
Kantra
@removed~kantrakantra
Aug 25 2016 00:37
@sjames1958gm @Chrono79 @AshriSoft Yes I simply had to call it. Thank you. thank you
CamperBot
@camperbot
Aug 25 2016 00:37
kantrakantra sends brownie points to @sjames1958gm and @chrono79 and @ashrisoft :sparkles: :thumbsup: :sparkles:
:star2: 2841 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:warning: could not find receiver for ashrisoft
:star2: 1906 | @chrono79 |http://www.freecodecamp.com/chrono79
donna50
@donna50
Aug 25 2016 00:39

need some help on the make objects properties private waypoint this solution works var Bike = function() {
var gear;
this.getGear = function(){
return gear;
};
this.setGear = function(set){
gear = set;
};

};

Thomas
@RoboMantis
Aug 25 2016 00:39

```var myBike = new Bike(1,2);
this.setGear = function(){return setGear};
this.getGear = function(){return getGear};

```

``` var myBike = new Bike(1,2);
this.setGear = function(){return setGear};
this.getGear = function(){return getGear};

```

is wrong
donna50
@donna50
Aug 25 2016 00:41
confused why you can intialize a variable and not set it for gear. My first solution was var gear = 0 and this.getGear = function(value) { return gear = value} however this didn't work
Walid Ashri
@walidashri
Aug 25 2016 00:41
:warning: could not find receiver for ashrisoft? why
Diego Mayer
@Chrono79
Aug 25 2016 00:44
@AshriSoft you need a fcc account linked to the github one I guess
Walid Ashri
@walidashri
Aug 25 2016 00:46
@Chrono79 thx as always u r right :)
CamperBot
@camperbot
Aug 25 2016 00:46
ashrisoft sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1907 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Aug 25 2016 00:46
@donna50 that's because value is undefined, at least when you call getGear()
Thomas
@RoboMantis
Aug 25 2016 00:47
``````var Bike = function(gear) {
var gear;
this.getGear = function(){
return gear;
};
this.setGear = function(set){
return set;
};
// Only change code below this line.
};

var myCar = new Car();

var myBike = new Bike();
myBike.getGear(4);
myBike.getGear(3);
myBike.getGear(1);``````
``````var Bike = function(gear) {
var gear;
this.getGear = function(){
return gear;
};
this.setGear = function(set){
return set;
};
// Only change code below this line.
};

var myCar = new Car();

var myBike = new Bike();
myBike.getGear(4);
myBike.getGear(3);
myBike.getGear(1);``````
``````var Bike = function(gear) {
var gear;
this.getGear = function(){
return gear;
};
this.setGear = function(set){
return set;
};
// Only change code below this line.
};

var myCar = new Car();

var myBike = new Bike();
myBike.getGear(4);
myBike.getGear(3);
myBike.getGear(1);``````
Diego Mayer
@Chrono79
Aug 25 2016 00:48
@RoboMantis and you pasted the same code 3 times because...
Not all method needs a return line, setGear should only change gear value
donna50
@donna50
Aug 25 2016 00:50
@Chrono79 thanks so much :) makes sense. Didn't think about calling getGear without a value
CamperBot
@camperbot
Aug 25 2016 00:50
donna50 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1908 | @chrono79 |http://www.freecodecamp.com/chrono79
Joseph
@revisualize
Aug 25 2016 00:52
@RoboMantis Such spam.. No wow.
George Phalen
@gphalen
Aug 25 2016 00:54
Could anyone help with Map the Debris? I thought I had the calculation for orbital periods figured out, but it's not giving the expected result.
revisualize @revisualize says nothing.
Thomas
@RoboMantis
Aug 25 2016 00:57
oh I know, I know... its because my code is plain and boring and no one wants to look at it
bullseye
Joseph
@revisualize
Aug 25 2016 01:01
@gphalen How are things for you being a freelance web developer?
Diego Mayer
@Chrono79
Aug 25 2016 01:01
@RoboMantis you're just echoing set in setGear
Joseph
@revisualize
Aug 25 2016 01:02
@gphalen Is there really enough work out there to stay employed and pay the bills? I kind of want to go freelance but, I don't really know if I would be able to sustain my life.
Of course, I'm also concerned that I don't have enough hard CS knowledge to make it in the development industry.
George Phalen
@gphalen
Aug 25 2016 01:07
@revisualize between you and me, it's a fancy way of saying "unemployed" ;)
Joseph
@revisualize
Aug 25 2016 01:07
OH.
That sucks.
Sorry.
George Phalen
@gphalen
Aug 25 2016 01:08
haha, it's alright. I had an interview two weeks ago, still waiting to hear back.
Chris Cullen
@123xylem
Aug 25 2016 01:10
http://codepen.io/123xylem/pen/JKqYZY?editors=0010
Im getting lost in this code..
I have 2 Questions: WHy has My USER X stopped Inputting X onto the BOARD?
How Can I get My CPU CLICK To Happen after every User Click?
``````var user;
user=  prompt("Choose X or O","Make sure its Caps!");
});

if (user=="X") {
userX=1 ;
\$(".box").on('click', function act(){
var id = \$(this).attr('id'); //logs clicked box ID and pushes into array
switch(id){  //TAken OUT SWITCHES FOR BREVITY

cpu();
});  //NEED CPU CLICK TO TRIGGER AFTER EVERY/ALL PLAYER CLICKs
}
else {
userO=1;
\$(".box").on('click', function act(){
var id = \$(this).attr('id');
switch(id){  //TAKEN OUT SWITCHES FOR BREVITY
cpu();    });
}

function cpu(){ //CPU move chosen from random choice var
if(userX<1){
\$("#"+choice+"").text("X");
}
else {
\$("#"+choice+"").text("O");}
}

\$(".box").click(function (){ //box click text based on user val
if (userX>0){
\$(this).text("X");
}
else {
\$(this).text("O");
}
});``````
User X used to work onclick
and I tried recalling act() and move() after if user x==1 but it doesnt recur
Joseph
@revisualize
Aug 25 2016 01:13
@gphalen What was the interview like? I'm thinking about taking two months off and doing a hard self study and spend four months looking for a new job. I just don't know.. Not having a job for six months.. I would run out of ALL of my savings and be kind of screwed if I didn't find something at six months and one day.
@123xylem I can't help you with that one.. Sorry. I'm not that far along and I don't really understand the problem. It is something that I eventually need to work on.
sfmajors373
@sfmajors373
Aug 25 2016 01:17
@revisualize I know a lot of people who have used that plan to find jobs and have been very successful and have come out of it much happier
Coy Sanders
@coymeetsworld
Aug 25 2016 01:17
can't study/look for jobs while keeping your current job @revisualize ?
Joseph
@revisualize
Aug 25 2016 01:17
@coymeetsworld yes and no.
@coymeetsworld I've been there a month and a half and I feel like I'm a month and a half behind.
Coy Sanders
@coymeetsworld
Aug 25 2016 01:18
there where? did you get a new job recently?
Joseph
@revisualize
Aug 25 2016 01:18
I was given like 8 projects the first few weeks that I started.
@coymeetsworld In the last month and a half.. Yes.
Actually two months now.
DAMN!
Coy Sanders
@coymeetsworld
Aug 25 2016 01:19
well congrats and I wouldn't worry, don't think anyone would expect someone to be productive right away
even if you know what you're doing it takes time to get acclimated
Joseph
@revisualize
Aug 25 2016 01:20
@coymeetsworld I needed to create a network diagram. (Still not done.) Deadline was July 29th. I was supposed to create a proposal for installing Patch Manager. Not even started.
@coymeetsworld I've never created a proposal for a project before.
Coy Sanders
@coymeetsworld
Aug 25 2016 01:21
do they give you an outline of what they want? Seems like alot to pour on someone after 2 months
Joseph
@revisualize
Aug 25 2016 01:21
Create a proposal and requirements list for a project that's supposed to be done in a day or two.
Coy Sanders
@coymeetsworld
Aug 25 2016 01:21
well i guess 1
hmm, seems odd to create a proposal for something so short lol
Joseph
@revisualize
Aug 25 2016 01:22
@coymeetsworld I have the network diagram mostly done. I have all the VLANs and network ports labeled and I know all the connections between the switches and routers. It took me forever to figure out. I even had to cheat a little and use a free app to help me out.
Marquet
@codenamequet
Aug 25 2016 01:22

var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];

// Only change code below this line

var secondTree = "myPlants1.list1";

I'm supposed to find the second tree here
Coy Sanders
@coymeetsworld
Aug 25 2016 01:22
eh wouldn't say using a tool is cheating lol
Marquet
@codenamequet
Aug 25 2016 01:22
and I'm having trouble seeing what I'm doing wrong
also there's are [] brackets around the 1's
anybody see what I did wrong?
Joseph
@revisualize
Aug 25 2016 01:24
@coymeetsworld i dont even know what an iy project proposal / requirement is.
Ive always just done stuff.
Coy Sanders
@coymeetsworld
Aug 25 2016 01:26
looks fine to me @codenamequet
oh wait it shouldn't be in quotes
`var secondTree = myPlants[1].list[1];`
@revisualize im sure its different based on each company.
Joseph
@revisualize
Aug 25 2016 01:27
I'm like Vanilla Ice... got a problem.. yo I'll solve it. Check out this hook while my dj.....
Coy Sanders
@coymeetsworld
Aug 25 2016 01:27
and context, like are you trying to sell mgmt on a team/idea/product
or just proposing how many manhours/resources it will take to do it
Marquet
@codenamequet
Aug 25 2016 01:28
thanks @coymeetsworld
CamperBot
@camperbot
Aug 25 2016 01:28
codenamequet sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1323 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Marquet
@codenamequet
Aug 25 2016 01:28
I thought I checked that
Coy Sanders
@coymeetsworld
Aug 25 2016 01:28
no problem
Marquet
@codenamequet
Aug 25 2016 01:28
it's kind of misleading that they put quotes there to begin with lol
instead of just nothing after the equal sign or asking me to set a var named secondTree to the second tree in the Var myPlants
Coy Sanders
@coymeetsworld
Aug 25 2016 01:31
is that a FCC challenge?
Joseph
@revisualize
Aug 25 2016 01:31
Yes.
Coy Sanders
@coymeetsworld
Aug 25 2016 01:31
oh they changed it? people don't like gloveboxes anymore? lol
Joseph
@revisualize
Aug 25 2016 01:31
They have two challenges around that.
Coy Sanders
@coymeetsworld
Aug 25 2016 01:31
I see
long123456
@xiaosamianbao
Aug 25 2016 01:33
who die Spinal Tap Case?
sfmajors373
@sfmajors373
Aug 25 2016 01:34
I'm trying to work on the basic algorithms "Title Case a Sentence". I have the loops set up, but I am having issues making the cases so what they are supposed to.
``````
function titleCase(str) {
var arr = str.split(' ');
for(var i = 0; i < arr.length; i++) {
var wordArr = arr[i].split('s');
for(var s = 0;s === 0;s++);
s = wordArr[s].toUpper();
for(s = 1; s < wordArr.length; s++){
s = wordArr[s].toLower();
}
arr = wordArr.join('');
str = arr.join(' ');
}
return str;
}

titleCase("I'm a little tea pot");``````
George Phalen
@gphalen
Aug 25 2016 01:35
@revisualize Interview was alright. It was for an Angularjs position. I studied pretty hard and knew most of the stuff.
Stephen James
@sjames1958gm
Aug 25 2016 01:39
@sfmajors373 If you keep changing s and it is your loop variable? `var wordArr = arr[i].split('s');` this splits on the letter s?
`for(var s = 0;s === 0;s++);` this loop isn't a loop it only goes once, just use wordArr[0]
@sfmajors373 Its toUpperCase not toUpper also same for lower
Leonardo
@martinsl30
Aug 25 2016 01:40

can anyone help plz!?
Iterate over Arrays with map:
var oldArray = [1,2,3,4,5];

return val + 3;
});
var newArray = oldArray;

Stephen James
@sjames1958gm
Aug 25 2016 01:40
@martinsl30 You are supposed to set newArray to the result of the map
Leonardo
@martinsl30
Aug 25 2016 01:41
@sjames1958gm
You should add three to each value in the array. can't pass this
Stephen James
@sjames1958gm
Aug 25 2016 01:42
@martinsl30 Yes, newArray should have the new array with 3 added. That is the result of the .map function
@martinsl30 delete the last line and replace addThree with newArray
Leonardo
@martinsl30
Aug 25 2016 01:44
@sjames1958gm ty man!
CamperBot
@camperbot
Aug 25 2016 01:44
martinsl30 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2842 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Kantra
@removed~kantrakantra
Aug 25 2016 01:45

Hey guys, was curious about `.append()` and `appendChild()`. What I want to happen is for a quote to appear in my `.quotebox` classed div when my "Yes or No" button is clicked. There are no errors in any of the code, it's just not executing what I would like it to.

It's not adding either of my `<p>`'s to the html

http://codepen.io/kantrakantra/pen/mEkmYN

Stephen James
@sjames1958gm
Aug 25 2016 01:45
@martinsl30 You had the right idea, just had to get the specifics of the instructions
Leonardo
@martinsl30
Aug 25 2016 01:45
@sjames1958gm yeah man, thx for the patience, hate to get stuck.... need to study soo much more...
CamperBot
@camperbot
Aug 25 2016 01:45
:warning: martinsl30 already gave sjames1958gm points
martinsl30 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
Aug 25 2016 01:47
@kantrakantra Did you load jquery ? in the settings for js?
Kantra
@removed~kantrakantra
Aug 25 2016 01:49
@sjames1958gm You're right, I hadn't. Though now that I have I'm still getting no response.
Stephen James
@sjames1958gm
Aug 25 2016 01:53
@kantrakantra Doesn't appear there is an appendChild function
Kantra
@removed~kantrakantra
Aug 25 2016 01:55
@sjames1958gm Hah! You're right. It looks like I must have looked a completely fictional function. thx
CamperBot
@camperbot
Aug 25 2016 01:55
kantrakantra sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2843 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Kantra
@removed~kantrakantra
Aug 25 2016 01:55
@sjames1958gm It's working now with just `.append()`
c0d0er
@c0d0er
Aug 25 2016 01:56
could anybody help? why if i change from `new Object` to `Object.create`, it will print out same result?
``````// make a class called `Square` that inherits from
// `Rectangle` and satisfies the following snippet
function Rectangle( width, height ) {
this.width = width;
this.height = height;
}
Rectangle.prototype.area = function() {
return this.width * this.height;
};

function Square(number){
this.width=number;
this.height=number;
this.length=number;
}
Square.prototype=new Object (Rectangle.prototype);//why if i change from `new Object` to `Object.create`, it will print out same result?
var square = new Square( 4 );

console.log(square)

square.area(); // 16
//Square.prototype.area === Rectangle.prototype.area; // true``````
Stephen James
@sjames1958gm
Aug 25 2016 01:56
@kantrakantra :+1:
Mike
@MikeJSchorah
Aug 25 2016 01:56
I'm on Build a Random Quote Machine and I wasn't sure if I should be using the count as my conditional selector for the quote. How do I generate a random number on click and set count to that?
LPR-309
@LPR-309
Aug 25 2016 01:57
@MikeJSchorah From the lessons:
``````function ourRandomRange(ourMin, ourMax) {

return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
}

ourRandomRange(1, 9);``````
Stephen James
@sjames1958gm
Aug 25 2016 01:58
@xiaji1 Object.create is the newer way of doing new Object
Dumdumdev
@jel111
Aug 25 2016 01:59
return early pattern here's my coe
``````// Setup
function abTest(a, b) {
// Only change code below this line

if (a < 0 || b < 0);

return "result";

// Only change code above this line

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

// Change values below to test your code
abTest(3,3);``````
I get the right values but my return function doesnt return undefined
llamatarianism
@llamatarianism
Aug 25 2016 02:00
@jel111 `if (a < 0 || b < 0);` is the same as `if (a < 0 || b < 0) {}`
I'm pretty sure you mean
``````if (a < 0 || b < 0)
return "result";``````

this is precisely why you should just always use braces.

``````if (a < 0 || b < 0) {
return "result";
}``````

there, no mistake.

Mike
@MikeJSchorah
Aug 25 2016 02:02
Thanks @LPR-309
CamperBot
@camperbot
Aug 25 2016 02:02
mikejschorah sends brownie points to @lpr-309 :sparkles: :thumbsup: :sparkles:
Dumdumdev
@jel111
Aug 25 2016 02:02
it still doesnt clear I am missing something here
it doesnt return undefined
llamatarianism
@llamatarianism
Aug 25 2016 02:03
Dumdumdev
@jel111
Aug 25 2016 02:04
the Return Early Patterns for Functions
Joseph
@revisualize
Aug 25 2016 02:04
@jel111 What are you supposed to be returning?
Dumdumdev
@jel111
Aug 25 2016 02:04
Thats a keyword and you should use it as a string it says
I mean shouldn't use it as the string
Joseph
@revisualize
Aug 25 2016 02:05
@jel111 Then fix it.
Dumdumdev
@jel111
Aug 25 2016 02:06
well I see i guess you can use it. From what the question said I thought you couldnt use it
I cleared it
Joseph
@revisualize
Aug 25 2016 02:06
``````function abTest(a, b) {
// Only change code below this line
if (a < 0 || b < 0); // <---- the ; there stops the if statement.
return "result";   // <-- you should be returning undefined not a string of result
// Only change code above this line
return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}``````
Dumdumdev
@jel111
Aug 25 2016 02:06
it ends up you need to
``` javascript
return undefined;
Joseph
@revisualize
Aug 25 2016 02:07
@jel111 We all know what you need to do.
@jel111 I don't like saying this sometimes but, @llamatarianism Is a far better developer than I am .. And I'm pretty okay.
Dumdumdev
@jel111
Aug 25 2016 02:07
Yea I see now the question is very misleading thanks
Joseph
@revisualize
Aug 25 2016 02:08
@jel111 I thought the problem was stated perfectly.
Instructions
Modify the function `abTest` so that if `a` or `b` are less than `0` the function will immediately exit with a value of `undefined`.
If a or b is < 0 ... return undefined
if (a < 0 || b < 0) return undefined;
Mike
@MikeJSchorah
Aug 25 2016 02:10
How should I go about doing the Build a Random Quote Machine project?
I'm stuck
I already know that I need to create divs, but should I used document.getElementByDiv to change the background color?
Cage Echarte
@CageEcharte
Aug 25 2016 02:17
I need help with "Else statements"
anyone?
Joseph
@revisualize
Aug 25 2016 02:18
@CageEcharte Sure.
``````if (condition) { // If the condition is true.
// do true stuff.
}
else { // meaning the condition wasn't true. Ergo, false
// do false stuff
}``````
Cage Echarte
@CageEcharte
Aug 25 2016 02:19

@revisualize whats wrong with my code here
if (val > 5) {
result = "Bigger than 5";
} else {
return "5 or Less";

}

Joseph
@revisualize
Aug 25 2016 02:19
@CageEcharte =
Mike
@MikeJSchorah
Aug 25 2016 02:20
Hell, I'll even take help from @revisualize LOL
Joseph
@revisualize
Aug 25 2016 02:20
@CageEcharte Your `result =` isn't actually returning anything.
@MikeJSchorah I haven't worked on that project. I don't know the scope of it. Nor do I have any advice to give.
Thomas Noe
@t3h2mas
Aug 25 2016 02:21
change the background color with css?
Cage Echarte
@CageEcharte
Aug 25 2016 02:22
@revisualize so what do I need to change ?
Kantra
@removed~kantrakantra
Aug 25 2016 02:23

Hey again guys, does anybody think they can spot why randomizer in the js is only returning the first option? I've literally changed nothing from a minute ago when it was working fine (randomly alternating between the two options Yes or No).

Ignore that the box doesn't start blank/refresh every click I'm still working on that part.

http://codepen.io/kantrakantra/pen/grNRra

Joseph
@revisualize
Aug 25 2016 02:23
@CageEcharte I don't know what you're trying to do. Are you trying to set `result` to be a string? Or are you trying to just `return` a string?
Cage Echarte
@CageEcharte
Aug 25 2016 02:25
@revisualize I guess I want to return a string
Joseph
@revisualize
Aug 25 2016 02:28
@CageEcharte Then why are you setting result to a string?
Thomas Noe
@t3h2mas
Aug 25 2016 02:30
either have two returns, or two assignments and one return after the if/else
Cage Echarte
@CageEcharte
Aug 25 2016 02:30
@revisualize I got it thanks
CamperBot
@camperbot
Aug 25 2016 02:30
cageecharte sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1724 | @revisualize |http://www.freecodecamp.com/revisualize
Bill Nash
@wrnash1
Aug 25 2016 02:30
Has anyone solved Record Collection? I’m having an Issue

// Setup
var collection = {
"2548": {
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": [
"Let It Rock",
"You Give Love a Bad Name"
]
},
"2468": {
"album": "1999",
"artist": "Prince",
"tracks": [
"1999",
"Little Red Corvette"
]
},
"1245": {
"artist": "Robert Palmer",
"tracks": [ ]
},
"5439": {
"album": "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (value === '') {
delete collection[id][prop];
} else if (prop !== "tracks") {
collection[id][prop] = value;
} else {
collection[id][prop].push(value);
}

return collection;
}

// Alter values below to test your code
updateRecords(5439, "tracks", "Take a Chance on Me");

Joseph
@revisualize
Aug 25 2016 02:32
@wrnash1 You're not doing this part:
// If prop is "tracks" but the album doesn't have a "tracks" property,
// create an empty array before adding the new value to the album's
// corresponding property.
``````"1245": {
"artist": "Robert Palmer",
"tracks": [ ]
},
"5439": {
"album": "ABBA Gold"
}``````
@wrnash1 There is no tracks array in "5439" but, you're trying to push to it.
Bill Nash
@wrnash1
Aug 25 2016 02:34
ok thanks
I think I’ve been looking at this for so long I’m overlooking the simple things.
Joseph
@revisualize
Aug 25 2016 02:35
@wrnash1 You need to test if there is an tracks property before you push to it. If there isn't you need to create the tracks property before pushing to it.
Bill Nash
@wrnash1
Aug 25 2016 02:37
Thanks that solved it
Joseph
@revisualize
Aug 25 2016 02:41
CamperBot
@camperbot
Aug 25 2016 02:41
Joseph
@revisualize
Aug 25 2016 02:42
@wrnash1 You didn't solve what the challenge was asking you to do.
@wrnash1 You just got the correct answer.
@wrnash1 You modified the object directly.
@wrnash1 I highly recommend that you learn how to solve this problem based on the instructions.
@wrnash1 Unless you don't want to get a job in web development.
Bill Nash
@wrnash1
Aug 25 2016 02:43
What is the correct way of solving the issue
Joseph
@revisualize
Aug 25 2016 02:44
@wrnash1 If you want to work in Web Development you MUST learn how to work with objects. It is at the core of what you'll be doing with JavaScript as a developer.
Bill Nash
@wrnash1
Aug 25 2016 02:44
Can you send me to a place where I can read up to get the answer
Joseph
@revisualize
Aug 25 2016 02:44
@wrnash1 I highly recommend that you WRITE the answer and not just "read up" on the answer.
Getting the correct answer is not learning.
Anyone can copy and paste and not learn a damn thing.
Bill Nash
@wrnash1
Aug 25 2016 02:45
I agree
Chris Cullen
@123xylem
Aug 25 2016 02:46
Quick Q: http://codepen.io/123xylem/pen/JKqYZY?editors=0011
:Why is my UserO not inputting O?
Even when userO is true and userX is false it still inputs X
NanoSaucer
@NanoSaucer
Aug 25 2016 02:49
I'm having trouble with the Steamroller challenge! The array that is returned is pretty much what the challenge wants, but the way that it is shown doesn't have the spaces between the elements, so the answer isn't "correct"... Does anyone know why is this happening?
Thomas Noe
@t3h2mas
Aug 25 2016 02:53
so if i have array of 10 items, and another consisting of steps i want to take through the array, what's an idiomatic way to get a result from it? any functional way?
AFK3000
@AFK3000
Aug 25 2016 02:55
hello
i need help
can someone explain how to practice my code
with this exercise
``````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;
break;
case 7:
case 8:
case 9:
count+=0;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count-= 1;
break;
}

return count + (count > 0 ? " Bet" : " Hold");
// Only change code above this line
}

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');``````
what do i type
anyone?
how do i test my function?
AFK3000
@AFK3000
Aug 25 2016 03:03
hello
sfmajors373
@sfmajors373
Aug 25 2016 03:05
@sjames1958gm Thanks! It took me a bit of fiddling but I finally got it to work!!
CamperBot
@camperbot
Aug 25 2016 03:05
sfmajors373 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2844 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Joseph
@revisualize
Aug 25 2016 03:09
@AFK3000 Did you write that code?
Ryan Apolinar
@ryanapolinar
Aug 25 2016 03:11
Currently stuck on the Symmetric Difference algorithm challenge, I'm getting the correct output with my code but none of the tests are passing. Here is what I have:
``````function sym(args) {
var args = [];
for (var i = 0; i < arguments.length; i++){
args.push(arguments[i]);
}
//foundation to get the symmetric difference of two arrays
function symDiff(one, two){
for (var i = 0; i < one.length; i++){
}
}
for (var j = 0; j < two.length; j++){
}
}
}
return args.reduce(symDiff).sort();
}``````
Suzanne Atkinson
Aug 25 2016 03:23
@AFK3000 what issues are you having right now?
friesenet21
@friesenet21
Aug 25 2016 03:27
This message was deleted
Suzanne Atkinson
Aug 25 2016 03:28
Anyone who has done friendly date ranges...did you create date objects, or just parse the dates as text and use logic?
friesenet21
@friesenet21
Aug 25 2016 03:31
This message was deleted
David Halls
@DavidHalls
Aug 25 2016 03:33
@AdventureBear im working on that too, what have you got so far?
Suzanne Atkinson
Aug 25 2016 03:33
I started it a year ago! Just picked it up yesterday
Lee Lacy
@llacy730
Aug 25 2016 03:34
what does this mean : Str should have encoded text with the proper escape sequences and no spacing.?
Suzanne Atkinson
Aug 25 2016 03:34
I'll PM you my repl.it code
luis4flames
@luis4flames
Aug 25 2016 03:40

```

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

var strArr = str.split(" ");
var newWord;
var i = 0;

while (i < str.length){
var newArr = [];

``````for(var j=0; j< 3; j++){
//Letter ASCCII
var x = strArr[i].charCodeAt(j);

if ( x > 78 && x < 90){
x -= 13;
} else if (x > 65 && x < 77){
x += 13;
} else {
x = x;
}

newArr[j] = x;

}
i++;
newWord = String.fromCharCode(newArr);``````

}
return newWord;

}

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

``` Can anyone see why my strArr[i] returns as undefined. If i call it with a specific number rather than a variable it works. The variable never passes past the length of the word so there should always be a valid value.

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

var strArr = str.split(" ");
var newWord;
var i = 0;

while (i < str.length){
var newArr = [];

for(var j=0; j< 3; j++){
//Letter ASCCII
var x = strArr[i].charCodeAt(j);

if ( x > 78 && x < 90){
x -= 13;
} else if (x > 65 && x < 77){
x += 13;
} else {
x = x;
}

newArr[j] = x;

}
i++;
newWord = String.fromCharCode(newArr);

}
return newWord;

}

// Change the inputs below to test
rot13("!SERR PBQR PNZC?");``````
Can anyone see why my strArr[i] returns as undefined. If i call it with a specific number rather than a variable it works. The variable never passes past the length of the word so there should always be a valid value.
Chris Cullen
@123xylem
Aug 25 2016 03:42
``````var choices=["a","b","c","d","e","f","g","h","i"];

function removeChoice(){
var val = choices[index];

choices.splice(index, 1);
return choices };

choice =choices[Math.floor(Math.random()*choices.length)];

var userX=false;
var userO=false;

var user;
user=  prompt("Choose X or O","Make sure its Caps!");

if (user=="X") {
userX=true ;
console.log(userX+"X"); console.log(userO +"o");
\$(".box").on('click', function act(){
var id = \$(this).attr('id'); //logs clicked box ID and pushes into array
switch(id){
//REMOVED SWITCHES FOR BREVITY
cpu(); removeChoice();
});``````
So we have choices array.. choice picks one element randomly... cpu uses that random choice one time...
QUESTION:::: why does CPU only work once??? IF its because Choice Is only 1 number and doesnt change WHY doesn my REMOVECHOICE Function Change it as its called after cpu(); which should reset choice??
@luis4flames your code confuses me a bit but maybe its the way u split strArr. by space
Diego Mayer
@Chrono79
Aug 25 2016 03:47
@luis4flames you are iterating over str and strArr is shorter
Chris Cullen
@123xylem
Aug 25 2016 03:48
@luis4flames take the Space out of ur split
luis4flames
@luis4flames
Aug 25 2016 03:48
@123xylem I want that user input to be split into an array with each element being each indiviual word not individual characters.
@Chrono79 yea ended up seeing that. Thanks!!!
CamperBot
@camperbot
Aug 25 2016 03:49
luis4flames sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1909 | @chrono79 |http://www.freecodecamp.com/chrono79
Celena
@rcdjasmin
Aug 25 2016 03:49
Hi, is anyone here? :)
Chris Cullen
@123xylem
Aug 25 2016 03:50
@luis4flames well when i took the space out It returned a value.. you could always rejoin it later into words.. but @Chrono79 knows more than me :)
Diego Mayer
@Chrono79
Aug 25 2016 03:50
I'm leaving right now, but someone else will appear ;)
Thomas Noe
@t3h2mas
Aug 25 2016 03:50
any react/redux gurus on
Diego Mayer
@Chrono79
Aug 25 2016 03:50
see ya
Dave
Aug 25 2016 04:15
would someone mind helping me with the javascript record collection problem?
James Bond
@Dman89
Aug 25 2016 04:16

if you guys could help me with this, that;d be great (office space voice)
i am logging right now but could use your help.... YES YOU!

http://stackoverflow.com/questions/39136578/angular-bootstrap-modal-wont-call-twice-typeerror-v2-deletemodalproject-is-not

fongor
@fongor
Aug 25 2016 04:33
hi everyone, can anyone help me about a certain line from the Convert JSON data to HTML challenge ? (https://www.freecodecamp.com/challenges/convert-json-data-to-html) I have difficulties to understand this line :
var keys = Object.keys(val);
I understand that it gives a new property called keys to every objects by adding to the Object prototype, but I'm not sure what the (val) syntax means
jinjuujii
@jinjuujii
Aug 25 2016 04:37
I did this to complete my factorize example... i couldn't think of a for loop to complete it...... is that bad ?
``````function factorialize(num) {
if (num === 0){
return 1;
}
else{
var array = [];
for (var i = 1; i <= num; i++){
array.push(i);
}

num = array.reduce(function(a,b){
return  a*b;
});

return num;
}
}

factorialize(12);``````
Dion Hobdy
@hobdydion
Aug 25 2016 04:38
Hey guys, I am a tad stuck with the "Stand in Line" challenge. Would anyone be able to help me out?
Lee Lacy
@llacy730
Aug 25 2016 04:41
What am I doing wrong?
var myStr="FirstLine\n\SecondLine\\rThirdLine\"; // Change this line
Dion Hobdy
@hobdydion
Aug 25 2016 04:43

function nextInLine(arr, item) {

return item;
}

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

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

Daulis M Gonzalez
@daulis809
Aug 25 2016 04:46
@hobdydion I'm going through the same
fongor
@fongor
Aug 25 2016 04:49
@hobdydion can you give the link to the challenge ?
Daulis M Gonzalez
@daulis809
Aug 25 2016 04:50
fongor
@fongor
Aug 25 2016 04:51
thanks
Daulis M Gonzalez
@daulis809
Aug 25 2016 04:51

@hobdydion i used this i my solution but one of the lines is not passing with this code:

testArr.push(item);
var removedItem = testArr[0];
testArr.shift([0]);
return removedItem; // Change this line

fongor
@fongor
Aug 25 2016 04:51
Daulis M Gonzalez
@daulis809
Aug 25 2016 04:53
@fongor im trying to pass this challenge but my code (the one i pasted above) isnt fully working to complete the hole challenge
@fongor even when im returning the last item removed and adding/removing the new one
Ryan
@ryanjoya
Aug 25 2016 04:54
Hello, I'm currently stuck in the Javascript challenge "Counting Cards." I'm able to get the first test to pass, but not the rest. This is the code I have so far -
``````
var count = 0;

function cc(card) {
// Only change code below this line
if (card === 2, 3, 4, 5, 6)  {
count+=1;
}
else if (card === 7, 8, 9)  {
count+=0;
}
else if (card === 10, 'J', 'Q', 'K', 'A')  {
count-=1;
}

return count + (count > 0 ? " Bet" : " Hold");
// Only change code above this line
}

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');``````
fongor
@fongor
Aug 25 2016 04:57
@daulis809 gimme a minute to check it out
Daulis M Gonzalez
@daulis809
Aug 25 2016 04:57
@fongor ok, good!
Ryan
@ryanjoya
Aug 25 2016 04:59
Should I use switch instead of if/else?
Balamurugan Subbaian
@dillbala
Aug 25 2016 05:00
anyone knows about android app development?
fongor
@fongor
Aug 25 2016 05:02
@daulis809 ok so : first, you should not operate on testArr but on arr
Dion Hobdy
@hobdydion
Aug 25 2016 05:02
@fongor @daulis809 Hey, sorry for the wait. Here's the link to the challenge.
fongor
@fongor
Aug 25 2016 05:02
because you are inside the body of the function where the argument is arr, not testArr
@hobdydion no worries, I'm just starting to answer the same challenge to @daulis809 so you can just check, starts 2 lines above
Markus Kiili
@Masd925
Aug 25 2016 05:03
@ryebread23 Do `if(card===2 || card===3 || ...)`
@ryebread23 Switch or lookup object are options too.
fongor
@fongor
Aug 25 2016 05:04
but @hobdydion did you try something first?
Ryan
@ryanjoya
Aug 25 2016 05:04
Ah, good point, thanks @Masd925
CamperBot
@camperbot
Aug 25 2016 05:04
ryebread23 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2359 | @masd925 |http://www.freecodecamp.com/masd925
Dion Hobdy
@hobdydion
Aug 25 2016 05:05
@fongor I'm trying to figure out where to start, tbh. This challenge previously discouraged me from here. So I'm trying to beat it after a while of not being on here. lol
Daulis M Gonzalez
@daulis809
Aug 25 2016 05:05
@fongor just passed it, Thanks a lot!!! that's why it didnt work, because i was altering the array directly instead on the arr parameter!!!
CamperBot
@camperbot
Aug 25 2016 05:05
daulis809 sends brownie points to @fongor :sparkles: :thumbsup: :sparkles:
Markus Kiili
@Masd925
Aug 25 2016 05:06
@hobdydion Find out the two methods that do those two things asked and then use them on `arr` and `item`.
fongor
@fongor
Aug 25 2016 05:06

@daulis809 then you were right about the first line : arr.push(item);

but to remove and return the first element, you don't need to use index[0], because the shift() method does it all : it removes the first element of an array, and the value it returns is precisely that removed element. So you can just use shift() and make his value being returned :

return arr.shift();

@daulis809 yes but you should also see that you were making the code more complicate than it needs to be if you just use shift();
@hobdydion ok, so, the point is that, when you need to perform operations on an array, what you need to keep in mind is that, there are operators (methods) that perform operations, and what you need to to do is to properly link them inside your code
Daulis M Gonzalez
@daulis809
Aug 25 2016 05:08
@fongor yes, i removed the index, because since it works i noticed there was no need for the indexing since .shift() will still remove the first item..
fongor
@fongor
Aug 25 2016 05:09
@daulis809 exactly, yes
Dion Hobdy
@hobdydion
Aug 25 2016 05:10
hhmm Alright. @Masd925 mentioned that there are two methods. Is there a specific operation that you personally recommend @fongor?
Daulis M Gonzalez
@daulis809
Aug 25 2016 05:11
@hobdydion i guess the simplest! since its just two line of code...
fongor
@fongor
Aug 25 2016 05:12
@hobdydion so for instance when you are facing this challenge, look it at it methodically : "Ok, I need to remove the last element of the array. Is there a method that does this?" And you will find out that there is such a method: the push() method. So you check how it works and what its syntax is, and use it: arr.push(item);. Then, ok, I need to remove and return the first element, is there a method that does this? And you will find the shift() method. So, same, you check its syntax and then you use it: arr.shift();. And as you need your function to return this element, you use return: return arr.shift();
@hobdydion woops sorry I made a mistake : I first meant " I need to add one element at the end of an array", not to remove it
Andrew Kay
@andrewjkay
Aug 25 2016 05:13
I'm working on the longest word in a string challenge, and I'm having a hard time putting the for loop iterations into one array? something tells me its blindingly simple. Here's what I've got
``````function findLongestWord(str) {
var strArray = str.split(' ');
for (i = 0; i <= str.length; i++) {
var numArray = [];    }
}
findLongestWord("The quick brown fox jumped over the lazy dog");``````
Markus Kiili
@Masd925
Aug 25 2016 05:14
@andrewjkay It should be `<str.length`
Dion Hobdy
@hobdydion
Aug 25 2016 05:14
Alright, so to relay it back to you both @fongor and @daulis809 , push adds an element and shift removes and returns elements?
Andrew Kay
@andrewjkay
Aug 25 2016 05:15
both work in chrome for some reason, but I'll change it
Markus Kiili
@Masd925
Aug 25 2016 05:15
@andrewjkay You could make a result variable that holds the length of longest word found so far and update it on the loop block.
Andrew Kay
@andrewjkay
Aug 25 2016 05:15
What I want is the stuff from strArray[i].length in one array
right now it prints to like eight console lines, but if I can get it in one array I can just sort descending and return the first item
Daulis M Gonzalez
@daulis809
Aug 25 2016 05:16
@hobdydion shift() only removes it but since you have to use return arr.shift(); you are returning it at the same time
fongor
@fongor
Aug 25 2016 05:16
@hobdydion yes correct, but there are different methods, some perform on the last element of the array, push() and pop(), some on the first element, shift() and unshift(). You need to check how they works, so you just google javascript push
Markus Kiili
@Masd925
Aug 25 2016 05:16
@andrewjkay ok. Then initialize the variable holding the array before the loop and push the lengths into it inside the loop block.
Andrew Kay
@andrewjkay
Aug 25 2016 05:16
@Masd925 that was what I attempted first (hold the greatest value in a var)
oh man I've even done that before!
Forgot about it completely and just got really convoluted search results
thanks @Masd925
CamperBot
@camperbot
Aug 25 2016 05:17
andrewjkay sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2360 | @masd925 |http://www.freecodecamp.com/masd925
Dion Hobdy
@hobdydion
Aug 25 2016 05:17
@daulis809 @fongor Alright. Last but not least, how would you guys start the code? Just the start, not the entire formula.
NixonRichard
@NixonRichard
Aug 25 2016 05:18
awww
fongor
@fongor
Aug 25 2016 05:19
@daulis809 @hobdydion it's partially true : shift doesn't only remove it, it also returns it : which means that the VALUE it returns is the value of the removed element (and not, for instance, "true" because it did it, or "0" for the index, or anything else). But the FUNCTION itself doesn't return it if you don't use the return keyword
so you use return
@hobdydion your question shows that it's not really clear for you yet, right? What makes it unclear?
Daulis M Gonzalez
@daulis809
Aug 25 2016 05:21
@hobdydion ok the code says : Add the number to the end of the array, so what method would you use to add a number to it?
Dion Hobdy
@hobdydion
Aug 25 2016 05:21
@fongor Honestly, all of it. I;m just hoping to figure it out as I get going.
@daulis809 Push?
fongor
@fongor
Aug 25 2016 05:22
@hobdydion you've been making previous challenges, right? You've been using methods in your code?
Daulis M Gonzalez
@daulis809
Aug 25 2016 05:22
@hobdydion arr.push(somethingHere);
@hobdydion that way you can push() the number to the end of the array
Dion Hobdy
@hobdydion
Aug 25 2016 05:23
lol @fongor Yes, but have been doing alot oftrial and error
@daulis809 Thanks. :D
CamperBot
@camperbot
Aug 25 2016 05:23
hobdydion sends brownie points to @daulis809 :sparkles: :thumbsup: :sparkles:
Daulis M Gonzalez
@daulis809
Aug 25 2016 05:24
@hobdydion did you pass the challenge?!
NixonRichard
@NixonRichard
Aug 25 2016 05:25
anyone doing the twitch tv challenge ?
Daulis M Gonzalez
@daulis809
Aug 25 2016 05:25
@hobdydion did you pass the challenge?!
Dion Hobdy
@hobdydion
Aug 25 2016 05:25
@daulis809 Not yet. lol I'll let you know when.
Daulis M Gonzalez
@daulis809
Aug 25 2016 05:29
@hobdydion remember that you have to use "return" to return the the first number of the array that was removed.
Daulis M Gonzalez
@daulis809
Aug 25 2016 05:38
good nite @all
fongor
@fongor
Aug 25 2016 05:40

@hobdydion ok, the point is to clearly understand the basics, so that you can build on them. If you don't understand them, it will not get easier with time but more confusing.

So the basics that you really need to understand are:

• Your code will perform some operations (= do stuffs)
• To perform these operations, your code will use METHODS and FUNCTIONS.

• You have some BUILT-IN METHODS, that JavaScript provides. For instance, you have array methods, such as push() : it is a built-in array method, which means that every array has it inside its own definition (because they come from array's prototype, but here this is a detail), so you can use it for every arrays. You also have object methods, built-in for every objects, string methods, built-in for every strings…

• So first you need to have a clear idea about some very common methods. If you google "Javascript built-in methods", or "Javascript array methods", "Javascript object methods"… you should find them easily : push, pop, shift and unshift, map, reduce… There are not so many. So even if you don't know them by heart, you should know that they exist, so you can check them when you need to use one. "Ok, what method can I use for this?" > Check

• When you don't have a built-in method that fits your need, you can yourself build your own functions. (And if you use these functions as object properties, they will also be called "methods" (= "function being an object property") but not "built-in methods".)

• Building a function means performing one or several operations. So you ask yourself "what operations do I want to perform?", and then you write the corresponding code. It is very important that you first understand the meaning of this question, "what operations do I want to perform", because if you don't, you don't know what you're looking for and just act randomly. So "what operations do I want to perform"? For instance: adding an element to the end of an array.

• Once you know what operation you want to perform : is there a built-in method that makes this operation? Here you found : push().

• So you check the method's SYNTAX. Very important, because sometimes the argument of a method will be argument.method(), sometimes it will be method(argument), etc : so you just read the method's docs, how do I write it ?

• And then you add it to your code using the right syntax with the right elements.

• If you have to build your own function, it means that you are defining the function's "rules". So you define them the way you need them, and you know what you need from answering the question "What operations do I want to perform?":

var myFunction = function() {
// do the operations I want to perform
}

@daulis809 good night
Chris Speight
@CRSpeight
Aug 25 2016 05:43
Can someone take a look at my codepen? Working on API the first time.... I thought I followed everything exactly but still not working when I push to change quote (did tests and it worked changing other things), probably getting the API part wrong >_< https://codepen.io/Paradisio/full/BzZXwO/
fongor
@fongor
Aug 25 2016 05:44
@Paradisio why are you using an API and JSON for the quotes ?
Chris Speight
@CRSpeight
Aug 25 2016 05:45
Because I'm an overachiever? Seemed like good practice
fongor
@fongor
Aug 25 2016 05:45
you can just write your own quotes inside your JS, and write a function to display them, you don't need any third party utl
url
fongor
@fongor
Aug 25 2016 05:45
was it part of the challenge to use it, o your own choice?
it doesn't seem better to me, except if it was part of the challenge
Chris Speight
@CRSpeight
Aug 25 2016 05:46
it says you can use an API, not that you should or shouldnt
fongor
@fongor
Aug 25 2016 05:46
oh ok yes but it says this for every challenge
Chris Speight
@CRSpeight
Aug 25 2016 05:46
Im just kinda stubborn now lol
Sergie Marienhof
@marienhof
Aug 25 2016 05:46
Gordon
@gordoh
Aug 25 2016 05:46
Hello everybody
Mike Mulchrone
@mtmulch
Aug 25 2016 05:46
``````
var array = [1, 12, 21, 2];

// Only change code below this line.

array.sort(function(a,b) {
return b - a;
});``````
Hello everyone, just looking for some insight on how the elements are actually passed into this function. Does it move left to right or right to left.
Darth Skywalker
Aug 25 2016 05:46
@fongor : What you say is true. However, the main goal of this challenge is to understand how to work with server. In real world, you seldom have your business logic in the code that runs on browser.
Dion Hobdy
@hobdydion
Aug 25 2016 05:47
@fongor Hhhmmm Would you reccomend that I start the javascript course all over again?
Gordon
@gordoh
Aug 25 2016 05:47
I need some help. I am trying to figure out how to add information to a complex object. I have tried push() but I am not sure if I am going in the right direction. Can somebody just look at my code please and tell me if I am on the right track or not
``````
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
];

myMusic['artist'].push(test);``````
@hobdydion honestly, I feel like I need to start the course over again too... Its really tough
Mike Mulchrone
@mtmulch
Aug 25 2016 05:50
@gordoh .push() is typically used to add elements to an array. I don't see anything stored for your parameter "test". What exactly are you trying to add to the object?
fongor
@fongor
Aug 25 2016 05:51
@hobdydion I recommend that you are very clear with one thing until you move to the next one. So if you're not clear with JavaScript, you can restart from there. But I think, as "Stand in line" is part of the Basics JavaScript Course, maybe the difficulty is the same for every challenges of this course, so you can also keep going. If you feel like it looked easier at the beginning, get back to the beginning. If you feel that the difficulty is the same everywhere, just keep going but emphasize on really understanding, not on "passing the tests"
Gordon
@gordoh
Aug 25 2016 05:51

Oh sorry, it was supposed to be "test"

I want to add test to the artist section

so its gonna say "artist":"Billy Joel", "test"
Markus Kiili
@Masd925
Aug 25 2016 05:52
This message was deleted
fongor
@fongor
Aug 25 2016 05:53
@adityaparab ok, I'm just saying this because it seems to me that using a 3d party API for this challenge is adding one more difficulty and uncertainty to the challenge's goal itself, but, it's sure possible to do so
Chris Speight
@CRSpeight
Aug 25 2016 05:53
And my two cents on the same subject, there are waypoints down the line... like I just got to the part where you start needing APIs... which are jquery. I forgot how to use jquery since I spent so long on the javascript question. Keep your skills sharp.
@fongor I appreciate that. I just know I'll need to know how to use APIs for some of the other projects in this section I just thought this would be an easy one to learn on.
fongor
@fongor
Aug 25 2016 05:54
Dion Hobdy
@hobdydion
Aug 25 2016 05:55
@fongor Yeah, I had found the start of the course to be much easier. lol Maybe I should take a few steps back.
@fongor Thanks. :D
CamperBot
@camperbot
Aug 25 2016 05:55
hobdydion sends brownie points to @fongor :sparkles: :thumbsup: :sparkles:
Gordon
@gordoh
Aug 25 2016 05:55
Any suggestions guys?
fongor
@fongor
Aug 25 2016 05:55
@Paradisio anyway i've superficially looked at your code and couldn't tell where the problem's from. But I didn't check every point precisely
Mike Mulchrone
@mtmulch
Aug 25 2016 05:56
@gordoh I suggest you look into the difference between objects and arrays. For example, to access the contents of the artist property you would need to type the following. myMusic[0].artist. You are accessing an object embedded within an array.
@suraj18gts
Aug 25 2016 05:56
fongor
@fongor
Aug 25 2016 05:56
@hobdydion ok yes, feel really free to do so, it's better to go back than to be always confused, do things your own pace and be sure to make everything clear before you move on. Good luck :)
Gordon
@gordoh
Aug 25 2016 05:56
@suraj18gts Yea I did the counting cards excercise. Thats one i really did enjoy
friesenet21
@friesenet21
Aug 25 2016 05:57
Anybody want to look at my 35 line, 20 second solution for Smallest Common Multiple?
Darth Skywalker
Aug 25 2016 05:57
Bring it on!
@friesenet21
masterbunny
@m4sterbunny
Aug 25 2016 05:58
@gordoh It is easier than you made it! myMusic.push (......
@suraj18gts
Aug 25 2016 05:58
@gordoh What to do in that??
Mike Mulchrone
@mtmulch
Aug 25 2016 05:58
@gordoh To add something to that property you would need to do something like this. myMusic[0].artist += ' Mike';
friesenet21
@friesenet21
Aug 25 2016 05:58
``````//jshint esversion:6,asi:true
function smallestCommons(arr){
let args = []
const s = arr.sort((a,b) => a-b)
while(s[0]<=s[1]){
args.push(s[0])
s[0]++
}
let test = (array) => {//argument must be an array
let first = array[0]
return array.every(t=>{
return t===first
})
}
let num = args[0],
arrToTest = args
//original array, indexed array, lowest value of indexed array
num+=args[0]
//console.log(arrToTest)
b++
}
return num
}
let testArr = []
for(let i in arr){
if(arr[i]+newArr[i]<= num){
testArr.push(arr[i]+newArr[i])
}else testArr.push(newArr[i])
}
return testArr
}

smallestCommons([23,18])``````
I swear it works
Darth Skywalker
Aug 25 2016 05:59

@friesenet21 : Well done, apprentice!

Here is mine

``````function smallestCommons(arr) {
var ggT=function(a,b){
return b===0?a:ggT(b,a%b);
};
var a=1;
for(var b=Math.min.apply(null,arr);b<=Math.max.apply(null,arr);b++)
a*=b/ggT(a,b);
return a;
}

smallestCommons([1,5]);``````

10 lines

:P

I cheated a little by not adding opening and closing `{`}` for the for loop. So yeah, it's really 11 lines :P
@suraj18gts
Aug 25 2016 06:00
wha to do?? @gordoh
masterbunny
@m4sterbunny
Aug 25 2016 06:01
@mtmulch I am playing around with the record collection - I want to see what I have done to my array- how do I output it? document.write(); aint no use, someone suggested JSON.stringify(myMusic); also no luck.
Solomon B
@ssbothwell
Aug 25 2016 06:02
i'm having trouble with the twitchtv exercise. i've got the whole thing done other then adding a placeholder for nonexistant twitch accounts.
friesenet21
@friesenet21
Aug 25 2016 06:02
@adityaparab thanks I feel much better now
CamperBot
@camperbot
Aug 25 2016 06:02
friesenet21 sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
Solomon B
@ssbothwell
Aug 25 2016 06:02
getjson() seems to return nothing when an account doesnt exist
oh wait, i might have just thought of something
Darth Skywalker
Aug 25 2016 06:04
@friesenet21 : You should, because you're `almost` on the right track. All you need to think about now is how to reuse the code so that you will come up with compact version of your code.
@suraj18gts
Aug 25 2016 06:07
anyone can telll me about the Counting card??
fongor
@fongor
Aug 25 2016 06:07

hey people I have a question from the Convert JSON data to HTML challenge (https://www.freecodecamp.com/challenges/convert-json-data-to-html) :

json.forEach(function(val) {
var keys = Object.keys(val);
(…) }

I'm not sure about the second line's meaning: it creates a property 'keys' in Object's prototype, and assigns it the value val ? (and then assigns is to var keys) ?

Markus Kiili
@Masd925
Aug 25 2016 06:07
@adityaparab I did it in one line, but not very pretty code.
Darth Skywalker
Aug 25 2016 06:08

@Masd925 : ! line! :O

Well, do share your method! There is always something more to learn! :D

Gordon
@gordoh
Aug 25 2016 06:09
@suraj18gts You need to try, then if you get stuck I can try advise you. Just make sure that 2,3,4,5 and 6 give a ++ , and 789 mustnt change your "count" value, then 10,"J","Q","K","A" must be set to --
Markus Kiili
@Masd925
Aug 25 2016 06:10
@adityaparab This is just one-line stuffing:
``````function smallestCommons(arr) {
return arguments.length===1 ?
Array.apply(null, {length: Math.max(arr[0],arr[1])-Math.min(arr[0],arr[1])+1})
.map(function(value, index){
return Math.min(arr[0],arr[1]) + index;
})
.reduce(function(prev,curr){return prev*curr / smallestCommons(prev,curr);})
:
arguments[1]===0 ? arguments[0] : smallestCommons(arguments[1], arguments[0]%arguments[1]);
}``````
Gordon
@gordoh
Aug 25 2016 06:11

@mtmulch That helped a lot, but now it puts it in the same "", so i have "Billy Joelmike"...

I cant add a (,) it gives me errors for days.

Darth Skywalker
Aug 25 2016 06:11
Ah! I see what you did there. You chained them and made it look like one line! :D
@Masd925
Still shorter than my code :D
Markus Kiili
@Masd925
Aug 25 2016 06:13
@adityaparab Just formatted it in several lines for easier reading, but technically I think it is a one-liner (not that I really care too much).
Henry Cabello
@hacu9
Aug 25 2016 06:14
Hey,Im really stuck with the Record Collection challenge,any tips? help?
Kantra
@removed~kantrakantra
Aug 25 2016 06:15

Hey guys, I'm having trouble figuring out how to get the quote I've appended to the html to disappear so that the next time the button is pressed the quotes don't end up stacking on top of each other. Is there a way to do this?

http://codepen.io/kantrakantra/pen/PzAKXd

fongor
@fongor
Aug 25 2016 06:17

hey people I have a question from the Convert JSON data to HTML challenge (https://www.freecodecamp.com/challenges/convert-json-data-to-html) :

json.forEach(function(val) {
var keys = Object.keys(val);
(…) }

I'm not sure about the second line's meaning: it creates a property 'keys' in Object's prototype, and assigns it the value val ? (and then assigns is to var keys) ?

@suraj18gts
Aug 25 2016 06:18

@gordoh
var count = 0;

function cc(card) {
// Only change code below this line
if (card<=6){
count++;
}
else if (card<=9){
count +=0;
}
else {
count--;
}
if (count <= 0){
return count + " Hold";
}
else {
return count + " Bet";
// Only change code above this line
}
}
// Note: Only the last will display
cc('2');

is this right??
@gordoh
??
Markus Kiili
@Masd925
Aug 25 2016 06:19
@adityaparab This is the same in understandable code. Must be essentially same as your code:
``````function gcd (a,b) {
return b===0 ? a : gcd(b, a%b);
}

function lcm (a,b) {
return Math.abs(a*b) / gcd(a,b);
}

function smallestCommons(arr) {
var min = Math.min(arr[0],arr[1]);
var max = Math.max(arr[0],arr[1]);
return max===min+1 ? lcm(min,max) : lcm(min,smallestCommons([min+1,max]));
}``````
greg
@wearenotgroot
Aug 25 2016 06:19
@fongor Object keys docs
what it does is it will create an array with all the properties of the object which you pass in as function parameter/argument
• val is an object
• keys will be an array which contains properties of val after Object.keys(...)
fongor
@fongor
Aug 25 2016 06:20
oh, ok, thank you @wearenotgroot
CamperBot
@camperbot
Aug 25 2016 06:20
fongor sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1454 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Murphy
@MurphyYue
Aug 25 2016 06:29
@suraj18gts

function cc(card) {
// Only change code below this line
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count+=1;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count-=1;

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

}

// Only change code above this line
}

Darth Skywalker
Aug 25 2016 06:31

@Masd925 : :+1:

I like this new approach more

scalable.
@suraj18gts
Aug 25 2016 06:38
@MurphyYue
The code I have written.....was that a rght code??
DarkManeiac
@DarkManeiac
Aug 25 2016 06:39
hello guys!

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

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

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");

Lesson: "Profile Lookup"
Markus Kiili
@Masd925
Aug 25 2016 06:41
@DarkManeiac First you need to loop or iterate through the contacts array.
DarkManeiac
@DarkManeiac
Aug 25 2016 06:41
aha
using "for ()"
hmm
how i know it doesntwork
Murphy
@MurphyYue
Aug 25 2016 06:47
@suraj18gts 我觉得你的代码是对的
I think your codes are right
@DarkManeiac “for（）”里面需要嵌套“if（）”吗？
DarkManeiac
@DarkManeiac
Aug 25 2016 06:52
english?
Murphy
@MurphyYue
Aug 25 2016 06:53
sorry，i am trying
DarkManeiac
@DarkManeiac
Aug 25 2016 06:54
"for" must be inside "if""
?
must be "in" it?
:))
Murphy
@MurphyYue
Aug 25 2016 06:55
DarkManeiac
@DarkManeiac
Aug 25 2016 06:55

Murphy
@MurphyYue
Aug 25 2016 06:56
OK
Gurita Alexandru
@Alexycys
Aug 25 2016 06:56
guys. I have to filter an array from false, null, 0, "", undefined, and NaN. And I used the .filter method several times. The problem is that it filters out the null values sometimes, and sometimes, when I have a NaN value, it doesnt. Why??
Mark Todd
@Knochenmark
Aug 25 2016 06:57
@Alexycys super simple arr.filter(function(el){return el;});
Darth Skywalker
Aug 25 2016 06:57
@Alexycys That's because `NaN === NaN` evaluates to false
Mark Todd
@Knochenmark
Aug 25 2016 06:58
@Alexycys you can also use arr.filter(Boolean);
Gurita Alexandru
@Alexycys
Aug 25 2016 06:58
@Knochenmark oh. That's it? :)) lemme see
Darth Skywalker
Aug 25 2016 06:59
This also works
``arr.filter(x=>x);``
Murphy
@MurphyYue
Aug 25 2016 06:59
@DarkManeiac The object you are dealing with,should we have a "if( )" in the "for( )"?
Mark Todd
@Knochenmark
Aug 25 2016 06:59
@Alexycys you need to know, that these values are all falsy, so they are automatically filtered out when you return them
Gurita Alexandru
@Alexycys
Aug 25 2016 07:00
@Knochenmark thanks a lot
CamperBot
@camperbot
Aug 25 2016 07:00
alexycys sends brownie points to @knochenmark :sparkles: :thumbsup: :sparkles:
Gurita Alexandru
@Alexycys
Aug 25 2016 07:00
@adityaparab thanks too, I didn't know that nan===nan is false
CamperBot
@camperbot
Aug 25 2016 07:00
alexycys sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
Mark Todd
@Knochenmark
Aug 25 2016 07:00
@Alexycys search for falsy in javascript and youll find a list with the values you mentioned ;)
melody kiptoo
@melodykiptoo
Aug 25 2016 07:00
var a;
var b = 2;
var a = 7;
var b = 7;
Rico042002
@rico042002
Aug 25 2016 07:01
anybody know good JS video tutorials
melody kiptoo
@melodykiptoo
Aug 25 2016 07:01
some one help? sorry im a bit of a noob :/ aha
Mark Todd
@Knochenmark
Aug 25 2016 07:01
@Alexycys for NaN you need isNaN()
Darth Skywalker
Aug 25 2016 07:01

@Alexycys : However seductive these short codes may seem, I suggest you refrain from using them in the beginning. You need to understand how to drop the NaN element without using `.filter`

Using `.filter` defeats the purpose of this challenge.

Mark Todd
@Knochenmark
Aug 25 2016 07:01
@adityaparab using filter is the whole purpose of that challenge i think :D
Darth Skywalker
Aug 25 2016 07:01
@Knochenmark : I beg to differ. :)
Mark Todd
@Knochenmark
Aug 25 2016 07:02
Gurita Alexandru
@Alexycys
Aug 25 2016 07:02
@Knochenmark yes, it is about falsy values
Darth Skywalker
Aug 25 2016 07:03
Yes, and how exactly does using `.filter`help you understand how to actually handle falsy values? (besides the fact that `.filter` will drop them for you)
Mark Todd
@Knochenmark
Aug 25 2016 07:03
@Alexycys so dont worry, filter is the way to go here
Murphy
@MurphyYue
Aug 25 2016 07:03
@DarkManeiac Having you solved it?we are working the same object and i can not solve it.
Gurita Alexandru
@Alexycys
Aug 25 2016 07:03
yeah, I didn't know that all those Nan and undefined and "" were evaluated as false
Mark Todd
@Knochenmark
Aug 25 2016 07:03
Darth Skywalker
Aug 25 2016 07:03
@Knochenmark : You're not getting the point.
Mark Todd
@Knochenmark
Aug 25 2016 07:04
@adityaparab i think you didnt :D
@Alexycys heres the official link https://developer.mozilla.org/de/docs/Glossary/Falsy
Darth Skywalker
Aug 25 2016 07:05
@Knochenmark Let's assume, you have a array with number of elements indefinitely greater than 4 million, how are you exactly going to filter it? The prototype methods just bomb with that kinda data sets
Mark Todd
@Knochenmark
Aug 25 2016 07:05
@adityaparab you could chain filter :D
Darth Skywalker
Aug 25 2016 07:06
Difference in philosophy, I conclude.
Mark Todd
@Knochenmark
Aug 25 2016 07:07
@Alexycys was there a 0 in the array too?
DarkManeiac
@DarkManeiac
Aug 25 2016 07:08
hello guys

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

function lookUpProfile(firstName, prop){
// Only change code below this line
var total = 0;

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

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");

can u help me?

Murphy
@MurphyYue
Aug 25 2016 07:08
me too
Aug 25 2016 07:09
@DarkManeiac I sat with that exercise a few hours :D
Mark Todd
@Knochenmark
Aug 25 2016 07:10
@adityaparab i mean seriously, right before the basic algorithms you learned funtional programming methods, why would you expect someone to use something else to use right after on the basic algorithm challenges....
DarkManeiac
@DarkManeiac
Aug 25 2016 07:10
you sat?
i dont understand
Aug 25 2016 07:11
@DarkManeiac adica a fost unul dintre cele mai grele exercitii
DarkManeiac
@DarkManeiac
Aug 25 2016 07:11
aa
ma ajuti? te rog
Aug 25 2016 07:11
trebuie sa folosesti un for si cateva if-uri/elese-uri
@DarkManeiac just a second
Darth Skywalker
Aug 25 2016 07:12
What language is this? :D
DarkManeiac
@DarkManeiac
Aug 25 2016 07:12
romanian :)
Darth Skywalker
Aug 25 2016 07:12
`rog` in my language means `disease` :D
DarkManeiac
@DarkManeiac
Aug 25 2016 07:12
:)
Murphy
@MurphyYue
Aug 25 2016 07:12
I cannot understand
Aug 25 2016 07:13

@DarkManeiac // Only change code below this line
function updateRecords(id, prop, value) {
if (prop !== "tracks" && value !== "") {
collection[id][prop] = value;
} else if (prop == "tracks" && collection[id].hasOwnProperty("tracks") == false) {
collection[id]["tracks"] = [];
collection[id][prop] = [value];
} else if (prop == "tracks" && value !== "") {
collection[id][prop].push(value);
} else {
delete collection[id][prop];
}

return collection;
}

Gordon
@gordoh
Aug 25 2016 07:13
I still cant get this one... Its not doing what I want it to do. It says "cannot set property 'title' of undefined
DarkManeiac
@DarkManeiac
Aug 25 2016 07:13
CamperBot
@camperbot
Aug 25 2016 07:13
darkmaneiac sends brownie points to @adrianbrand :sparkles: :thumbsup: :sparkles:
Gordon
@gordoh
Aug 25 2016 07:13
``````var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}

];

myMusic[0].artist = ["Billy Joel" , "mike"];
myMusic[1].title = ["Piano Man" , "will made it"];
myMusic[2].release_year = [1973 , 1989];``````
Aug 25 2016 07:13
@DarkManeiac you welcome
Murphy
@MurphyYue
Aug 25 2016 07:13
Aug 25 2016 07:14
@MurphyYue that's true ;)
greg
@wearenotgroot
Aug 25 2016 07:14
@gordoh well there is nothing in index 1 so(only one element in that array, it's on index 0)
Gordon
@gordoh
Aug 25 2016 07:14
I dont think I am supposed to manually add to the list the way I am doing. I think there must be a way to do myMusic[0].artist += "mike"
Darth Skywalker
Aug 25 2016 07:14
@gordoh You only have 1 object inside your `myMusic` so only valid code is `myMusic[0]`
Gordon
@gordoh
Aug 25 2016 07:14
thanks that helped
Darth Skywalker
Aug 25 2016 07:15
`myMusic[1]` and `myMusic[2]` are `undefined`
Gordon
@gordoh
Aug 25 2016 07:15
then what is the point of making it an array if its only one item?
Markus Kiili
@Masd925
Aug 25 2016 07:15
@gordoh You are supposed to add another record (array element) there.
Darth Skywalker
Aug 25 2016 07:15
@gordoh : The evil that resides within the Majins has clouded your senses :P
Murphy
@MurphyYue
Aug 25 2016 07:15
Gordon
@gordoh
Aug 25 2016 07:16
So should I be leaning toward adding a brand new list to the array? as opposed to just adding the info to the current list?
Darth Skywalker
Aug 25 2016 07:17
@gordoh : Depends on the challenge.
What are you asked to do?
Gordon
@gordoh
Aug 25 2016 07:17
Instructions
Add a new album to the myMusic array. Add artist and title strings, release_year number, and a formats array of strings.
so Im guessing I should add a myMusic1
greg
@wearenotgroot
Aug 25 2016 07:18
@gordoh you can just copy pasta the first object. remember to separate item with , (change the value up a bit)
Markus Kiili
@Masd925
Aug 25 2016 07:18
@gordoh I think you can copy/paste the first element on the array literal and add another so the structure is `=[{...},{...}]` and then change the data on the second element.
DarkManeiac
@DarkManeiac
Aug 25 2016 07:18
@MurphyYue , worked??
Murphy
@MurphyYue
Aug 25 2016 07:18
@DarkManeiac no
Aug 25 2016 07:19
@MurphyYue it worked for me :-?
Gordon
@gordoh
Aug 25 2016 07:19
@Masd925 @wearenotgroot Thank you both kindly
CamperBot
@camperbot
Aug 25 2016 07:19
gordoh sends brownie points to @masd925 and @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 2361 | @masd925 |http://www.freecodecamp.com/masd925
:star2: 1457 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Gordon
@gordoh
Aug 25 2016 07:19
it worked like a baws!!!
greg
@wearenotgroot
Aug 25 2016 07:19
@gordoh :+1:
Murphy
@MurphyYue
Aug 25 2016 07:19
@adrianbrand we are working the "Profile Lookup"
Aug 25 2016 07:22

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

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

Murphy
@MurphyYue
Aug 25 2016 07:22
worked
Markus Kiili
@Masd925
Aug 25 2016 07:23
@adrianbrand It works without the last else if, if you just place the return correctly.
CamperBot
@camperbot
Aug 25 2016 07:23
murphyyue sends brownie points to @adrianbrand :sparkles: :thumbsup: :sparkles:
Gurita Alexandru
@Alexycys
Aug 25 2016 07:23
``````
function destroyer(arr) {
// Remove all the values
return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);``````
how can I access that arguments
after the array?
Markus Kiili
@Masd925
Aug 25 2016 07:24
@Alexycys Use the `arguments` object.
Gurita Alexandru
@Alexycys
Aug 25 2016 07:24
oooooooooooh, I got it
Aug 25 2016 07:24
@Masd925 where should I put it? thnaks
Gurita Alexandru
@Alexycys
Aug 25 2016 07:25
but...how can I know how many arguments are there?
Markus Kiili
@Masd925
Aug 25 2016 07:25
@adrianbrand After you have checked all the contacts -> after the loop block.
@Alexycys You can use `arguments[i]` and `arguments.length`
Aug 25 2016 07:25
@Masd925 thank you :D
CamperBot
@camperbot
Aug 25 2016 07:25
adrianbrand sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2362 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Aug 25 2016 07:26
@Alexycys You can also turn the arguments object into a real array if you like to use array methods on it (helps here also).
Xiao Yang
@xiaopow
Aug 25 2016 07:34
if you need help, ask us on www.codeforx.com
shuntovs
@shuntovs
Aug 25 2016 07:34
you guys
can someone help me w/ dis
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
how is this code suppose to look like?
Xiao Yang
@xiaopow
Aug 25 2016 07:36
@shuntovs if you need help, ask us on www.codeforx.com
shuntovs
@shuntovs
Aug 25 2016 07:37
sigh that ain't helpful I have limited wifi
kirbyedy
@kirbyedy
Aug 25 2016 07:38
@xiaopow why are you doing that ?
either help the guy or dont, but dont make him click on some link
Aug 25 2016 07:41
@shuntovs var remainder = 11%3;
shuntovs
@shuntovs
Aug 25 2016 07:41
CamperBot
@camperbot
Aug 25 2016 07:41
shuntovs sends brownie points to @adrianbrand :sparkles: :thumbsup: :sparkles:
shuntovs
@shuntovs
Aug 25 2016 07:42
wait no

The value of remainder should be 2

You should use the % operator

Aug 25 2016 07:43
11%3 it is 2 :)
maybe the remainder is already decalred
*declared
try remainder = 11 % 3;
shuntovs
@shuntovs
Aug 25 2016 07:44
w8
it worked thanks mate
Aug 25 2016 07:47
;)
shuntovs
@shuntovs
Aug 25 2016 07:49
wait I need more help

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

// Only modify code below this line

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

a should equal 15
b should equal 26
c should equal 19
You should use the += operator for each variable
Do not modify the code above the line

Markus Kiili
@Masd925
Aug 25 2016 07:50
@adrianbrand I wish I was like you, never having to sleep or eat. Just code.
Aug 25 2016 07:51
@Masd925 You are. You are always here from what I saw. I'm a beginner ... long road to go. This chat keeps me motivated ... for now
Markus Kiili
@Masd925
Aug 25 2016 07:53
Aug 25 2016 07:54
@Masd925 lol :D
shuntovs
@shuntovs
Aug 25 2016 07:54
can someone help me doe
Murphy
@MurphyYue
Aug 25 2016 07:56
a+=12;b+=9;c+=7 @shuntovs
shuntovs
@shuntovs
Aug 25 2016 07:57
its not that @MurphyYue
it ruins the results
Jack shi
@chunge16
Aug 25 2016 07:58

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

``}``

}

??
@MurphyYue
kirbyedy
@kirbyedy
Aug 25 2016 07:59
@shuntovs are you sure ? cause I think @MurphyYue is right
a+= 12 will give you 15, because a is 3
amit-mb
@amit-mb
Aug 25 2016 08:00

<code>

var myVar = 87;

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

</code>

whats wrong in this
got it
shuntovs
@shuntovs
Aug 25 2016 08:01
@kirbyedy yes
Aug 25 2016 08:01
@amit-mb myVar += myVar
shuntovs
@shuntovs
Aug 25 2016 08:02

@kirbyedy
a should equal 15

b should equal 26

c should equal 19

amit-mb
@amit-mb
Aug 25 2016 08:02
CamperBot
@camperbot
Aug 25 2016 08:02
amit-mb sends brownie points to @adrianbrand :sparkles: :thumbsup: :sparkles:
Murphy
@MurphyYue
Aug 25 2016 08:05
@chunge16 你这个能通过吗？
Murphy
@MurphyYue
Aug 25 2016 08:10
@chunge16 我试了一下，不能通过啊
Jack shi
@chunge16
Aug 25 2016 08:10

Murphy
@MurphyYue
Aug 25 2016 08:11

Darth Skywalker
Aug 25 2016 08:11
@MurphyYue @chunge16 : You guys do realize that no using English will restrict your chances of getting asnwers.
You do realize that, right?
Murphy
@MurphyYue
Aug 25 2016 08:11

Jack shi
@chunge16
Aug 25 2016 08:12
else if(i == contacts.length-1){
return "No such contact";
} @MurphyYue

Murphy
@MurphyYue
Aug 25 2016 08:12
Jack shi
@chunge16
Aug 25 2016 08:13
CamperBot
@camperbot
Aug 25 2016 08:13
chunge16 sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
Murphy
@MurphyYue
Aug 25 2016 08:13
@chunge16 Me too
Darth Skywalker
Aug 25 2016 08:13
Not to sound rude. :)
Jack shi
@chunge16
Aug 25 2016 08:14
Darth Skywalker
Aug 25 2016 08:14
We do have a chine room on FCC. If you're not comfortable with English, you might wanna use the chinese room
Jack shi
@chunge16
Aug 25 2016 08:14
Murphy
@MurphyYue
Aug 25 2016 08:15
QQ
Dion Hobdy
@hobdydion
Aug 25 2016 08:15
ugh I am so close now
Henry Cabello
@hacu9
Aug 25 2016 08:15
Uh is there anything wrong with my code?
`````````  function lookUpProfile(firstName, prop){
```// Only change code below this line
```for(var p=0;p<contacts.length;p++){
```for(var q=0;q<contacts[p].length;q++){
```
```if(firstName == contacts[p][q] && prop == contacts[p][q]){
```  return prop;
```}else if(firstName !== contacts[p][q]){return "No such contact";}
```else{
```return "No such property";
``` }
```
```}
```}
```
```// Only change code above this line
```}``````
Dion Hobdy
@hobdydion
Aug 25 2016 08:16

function nextInLine(arr, item) {

arr.shift (item);

return arr.push (item); // Change this line
}

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

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

3/4objectives so far.

Darth Skywalker
Aug 25 2016 08:18

@MurphyYue

I didn't understand :D

greg
@wearenotgroot
Aug 25 2016 08:18
@hobdydion .shift() mdn docs <--- when in doubt check the docs
Mark Todd
@Knochenmark
Aug 25 2016 08:18
@adityaparab qq is an instant messanger
@adityaparab that number is his id, but i guess he just mixed up the mentions :D
Darth Skywalker
Aug 25 2016 08:19
right!
thanks!
greg
@wearenotgroot
Aug 25 2016 08:19
QQ same as TT ? :smile:
Mark Todd
@Knochenmark
Aug 25 2016 08:19
@wearenotgroot whats TT?
Murphy
@MurphyYue
Aug 25 2016 08:19
Darth Skywalker
Aug 25 2016 08:19
What's TT? Table Tennis?
greg
@wearenotgroot
Aug 25 2016 08:20
it's just a table from one perspective :)
Mark Todd
@Knochenmark
Aug 25 2016 08:21
Murphy
@MurphyYue
Aug 25 2016 08:21
@adityaparab We have baidu in China
Darth Skywalker
Aug 25 2016 08:21
Mark Todd
@Knochenmark
Aug 25 2016 08:21
anyone saw the new "Independance Day"? I was laughing because there was an advertisement for QQ :D
Murphy
@MurphyYue
Aug 25 2016 08:22
Dion Hobdy
@hobdydion
Aug 25 2016 08:23
@wearenotgroot Thanks :D
CamperBot
@camperbot
Aug 25 2016 08:23
hobdydion sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1460 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Aug 25 2016 08:23
@hobdydion :+1:
Murphy
@MurphyYue
Aug 25 2016 08:24
@Knochenmark i have sean it ,so many chinese
eyeseau
@eyea
Aug 25 2016 08:26
help ,guys
CamperBot
@camperbot
Aug 25 2016 08:26
no wiki entry for: `guys`
who is in
Aug 25 2016 08:27
http://prntscr.com/ca5l7j could I have written this simpler?
Mark Todd
@Knochenmark
Aug 25 2016 08:27
@eyeA you didnt started yet?
eyeseau
@eyea
Aug 25 2016 08:27
hmmm
yes
I have not practise,so...It is embrassed....
Mark Todd
@Knochenmark
Aug 25 2016 08:28
``````function reverseString(str) {
var arr = str.split("");
arr.reverse();
return arr.join("");
}``````
Aug 25 2016 08:29
to convert the array to string
Mark Todd
@Knochenmark
Aug 25 2016 08:30
encount
@encount
Aug 25 2016 08:30
greg
@wearenotgroot
Aug 25 2016 08:30
toString docs
vs
.join(..)
eyeseau
@eyea
Aug 25 2016 08:30
str.split('').reverse().join(',')
Aug 25 2016 08:31
thank you guys, checking .... I felt that I over did it :D
eyeseau
@eyea
Aug 25 2016 08:31
Darth Skywalker
Aug 25 2016 08:31
``return str.split('').reverse().join('');``
Marina
@miss90
Aug 25 2016 08:31

Hello, please help. I think, it's a bag here. The task is :"Quoting Strings with Single Quotes". It writes :"Only remove the backslashes \ used to escape quotes.". My code

``var myStr = '<a href="http//:www.example.com" target="_blank">Link</a>';``

Where is a mistake?

greg
@wearenotgroot
Aug 25 2016 08:33
@miss90 try a refresh on the page?
Marina
@miss90
Aug 25 2016 08:34
@wearenotgroot so is my code correct?
Mark Todd
@Knochenmark
Aug 25 2016 08:34
@miss90 which challenge?
greg
@wearenotgroot
Aug 25 2016 08:34
@miss90 yes it looks like it
Marina
@miss90
Aug 25 2016 08:34
@Knochenmark Quoting Strings with Single Quotes
@wearenotgroot bug is here :"Only remove the backslashes \ used to escape quotes."
greg
@wearenotgroot
Aug 25 2016 08:35
@miss90 i meant move the : on the http//:------> http://
Mark Todd
@Knochenmark
Aug 25 2016 08:35
@miss90 i think you have to run the tests twice there
Marina
@miss90
Aug 25 2016 08:36
@wearenotgroot oh thanks u
CamperBot
@camperbot
Aug 25 2016 08:36
miss90 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1461 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
encount
@encount
Aug 25 2016 08:36
@miss90 no - because it says replace double quotes with single then escape
Mark Todd
@Knochenmark
Aug 25 2016 08:37
@miss90 `var myStr = '<a href="http://www.example.com" target="_blank">Link</a>';`
Gordon
@gordoh
Aug 25 2016 08:37
Hey guys... I dont know how to do a multiplication for loop
Mark Todd
@Knochenmark
Aug 25 2016 08:37
@miss90 tests are green for me
Gordon
@gordoh
Aug 25 2016 08:37
Please look at my code and explain why it wont do what its supposed to
``````function multiplyAll(arr) {
var product = 1;
// Only change code below this line

for (i = 1 ; i < multiplyAll.length; i++){

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);``````
greg
@wearenotgroot
Aug 25 2016 08:37
it was the colon! :)
Darth Skywalker
Aug 25 2016 08:37
@gordoh : What's `multiplyAll` here?
It's a function, not array
Gordon
@gordoh
Aug 25 2016 08:38
aaah!
si arr is the name of the function
greg
@wearenotgroot
Aug 25 2016 08:39
@gordoh also remember each element inside arr is also an array
eyeseau
@eyea
Aug 25 2016 08:39
FCC only javscript ,yes ?
Mark Todd
@Knochenmark
Aug 25 2016 08:39
@gordoh which challenge is that?
Gordon
@gordoh
Aug 25 2016 08:40
215 - nesting for loops
Darth Skywalker
Aug 25 2016 08:40
@eyeA aye (eye)
Anthony Drane
@Antiaccess
Aug 25 2016 08:40
Hey guys, having issues with making an argument to check for numbers matching items in an array. Can you help me out with line 4?
``````function destroyer(arr) {
function removeValues(values){
for (var i = 1; i < arr.length; i++){
return (arr[i].includes(values));
}
}
return arguments[0].filter(removeValues);
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);``````
greg
@wearenotgroot
Aug 25 2016 08:40
@gordoh multiplyAll is the name of the function and arr is the function argument
eyeseau
@eyea
Aug 25 2016 08:40
Mark Todd
@Knochenmark
Aug 25 2016 08:40
@gordoh lol you didnt nest any loop :D
Anthony Drane
@Antiaccess
Aug 25 2016 08:40
`includes` doesn't work here
Darth Skywalker
Aug 25 2016 08:41
@Antiaccess : You need to use either `.includes`/`.indexOf` OR a loop
using both things at the same time is wrong in the context of this problem.
Gordon
@gordoh
Aug 25 2016 08:41
okay im understanding better now let me try again
Aug 25 2016 08:41
@wearenotgroot I don't know if it's just me (as a beginner), but I find it hard to understand most of the concepts from the official documentation. any tips?
Anthony Drane
@Antiaccess
Aug 25 2016 08:42
@adityaparab `.indexOf` seems to only work for strings, not numbers
Mark Todd
@Knochenmark
Aug 25 2016 08:42
@Antiaccess you mean the arguments? since you use ES6 already you can use the ...
Darth Skywalker
Aug 25 2016 08:42

@Antiaccess

try this

``````var a = [1,2,3,4,5];
console.log(a.indexOf(5));``````

;)

Anthony Drane
@Antiaccess
Aug 25 2016 08:42
ok i'll try it
greg
@wearenotgroot
Aug 25 2016 08:43
@adrianbrand yea some of the stuff in the docs is somewhat hard to understand. but usually if you read them a couple of times and try the examples yourself. you'll understand them a bit more
Aug 25 2016 08:44
@wearenotgroot I see. Thanks for the advice ;)
CamperBot
@camperbot
Aug 25 2016 08:44
adrianbrand sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1462 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Darth Skywalker
Aug 25 2016 08:44
@Antiaccess : You just need to do
``````function destroyer(arr) {
function removeValues(values){
return !arr.includes(values);
}
return arguments[0].filter(removeValues);
}``````
Anthony Drane
@Antiaccess
Aug 25 2016 08:44
@adityaparab okay, that helped. I'm passing the first test with `return (!arr.indexOf(values));`
greg
@wearenotgroot
Aug 25 2016 08:44
Aug 25 2016 08:44
@wearenotgroot that's what I usually do
greg
@wearenotgroot
Aug 25 2016 08:45
Aug 25 2016 08:45
@wearenotgroot multiple sources .. .different points of view
Mark Todd
@Knochenmark
Aug 25 2016 08:45
@Antiaccess you lack the arguments that are not passed with the array
greg
@wearenotgroot
Aug 25 2016 08:45
@adrianbrand you can somewhat extrapolate from those :wink:
Anthony Drane
@Antiaccess
Aug 25 2016 08:45
@Knochenmark sorry, I'm not following
Mark Todd
@Knochenmark
Aug 25 2016 08:46
destroyer([1, 2, 3, 1, 2, 3], 2, 3); you just handle the array, but ignore the additional arguemnts
Darth Skywalker
Aug 25 2016 08:46

@Antiaccess : Please be advised, `.includes` is not fully supported across all browsers. It's fine to use for these tutorials, but refrain from using it in your production apps.

For now, it is wise to just stick to `.indexOf`

``````function destroyer() {
function removeValues(values){
return arr[i].indexOf(values) === -1;
}
return arguments[0].filter(removeValues);
}``````
Gordon
@gordoh
Aug 25 2016 08:47
I think I am closer now but I still dont get what I am expecting
``````
function multiplyAll(arr) {
var product = 1;
// Only change code below this line

for (i = 0 ; i < arr[0].length; i++){
for (j = 0; j < arr[1].length; j++)
for (k = 0; k < arr[2].length; k++)

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);``````
greg
@wearenotgroot
Aug 25 2016 08:47
@Antiaccess the named argument arr only contains [1, 2, 3, 1, 2, 3]
2 and 3 can be found in arguments[1] and arguments[2]
Mark Todd
@Knochenmark
Aug 25 2016 08:47
``````function destroyer(arr) {
var args = [].slice.call(arguments,1);
return arr.filter(function(el){
return args.indexOf(el)===-1;
});
}``````
es5 only, check out the args variable
Anthony Drane
@Antiaccess
Aug 25 2016 08:48
okay, give me a few minutes to look at all of your suggestions
greg
@wearenotgroot
Aug 25 2016 08:48
@Antiaccess Arguments Object <------check
Darth Skywalker
Aug 25 2016 08:48
@Antiaccess
correct, you're gonna have to use `arguments` object.
``````function destroyer() {
function removeValues(values){
return arguments.indexOf(values) === -1;
}
return arguments[0].filter(removeValues);
}``````
Gordon
@gordoh
Aug 25 2016 08:48
it just says null...
greg
@wearenotgroot
Aug 25 2016 08:49
@gordoh you should be fine with only two for loops(the array is only 2 levels)
Jonathan Wieben
@JonathanWbn
Aug 25 2016 08:49
hey guys. I am stuck at "Reverse a String". My task is to reverse a string. That is what ive got:
```function reverseString(str) { reverseString.split(""); reverseString.reverse(); reverseString.join(""); return str; }```
What am I doing wrong?
Mark Todd
@Knochenmark
Aug 25 2016 08:49
@adityaparab arguments object is wrong, you need to omit the first index
@JonathanWbn you can chain these methods
Darth Skywalker
Aug 25 2016 08:50
@Knochenmark : Not necessarily
Mark Todd
@Knochenmark
Aug 25 2016 08:50
@JonathanWbn or you need to assign them to a variable
Gordon
@gordoh
Aug 25 2016 08:50
@wearenotgroot I figured 3 would be write because there are 3 items in the array
*right
greg
@wearenotgroot
Aug 25 2016 08:51
@gordoh umm your array is just
outerArray[innerArray, ....] <------two levels
if it was like this
outerArray[innerArray[innermostArray, ....], ....] <-------three levels
Gordon
@gordoh
Aug 25 2016 08:51
it now works sort of but only up till 4
Okay that makes sense.
Jonathan Wieben
@JonathanWbn
Aug 25 2016 08:52
@Knochenmark how do i chain them? .split("").reverse().join("");?
Mark Todd
@Knochenmark
Aug 25 2016 08:52
Gordon
@gordoh
Aug 25 2016 08:52
for (i = 0 ; i < arr.length; i++){
for (j = 0; j < arr[0][1][2].length; j++)
I assume thats how the loops should look then
Mark Todd
@Knochenmark
Aug 25 2016 08:52
@adityaparab since arguments is not an array
greg
@wearenotgroot
Aug 25 2016 08:53

@gordoh

``````for (i = 0 ; i < arr.length; i++){ //<----for outermost array
for (j = 0; j < arr[i].length; j++) //<---inner array``````

no hardcoding!

Mark Todd
@Knochenmark
Aug 25 2016 08:53
@JonathanWbn yes, i think you can just directly return the result
Gordon
@gordoh
Aug 25 2016 08:53
@wearenotgroot Thank you. I got it. I was so close
CamperBot
@camperbot
Aug 25 2016 08:53
gordoh sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1463 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Mark Todd
@Knochenmark
Aug 25 2016 08:53
@JonathanWbn alternatively you need to save the returning string in a variable, like var reversed = arr.reverse();
Darth Skywalker
Aug 25 2016 08:54

@Knochenmark
You can always cast it into an Array by using `.apply`

But for sake of simplicity, let's stick to

``````function destroyer() {
var args = Array.prototype.slice.call(arguments,0);
function removeValues(values){
return args.indexOf(values) === -1;
}
return arguments[0].filter(removeValues);
}``````
greg
@wearenotgroot
Aug 25 2016 08:54
@gordoh close is not good enough :smile:
@gordoh keep at it :+1:
Mark Todd
@Knochenmark
Aug 25 2016 08:55
@adityaparab omit the first index, and you removed the parameter "arr" from destroyer
Darth Skywalker
Aug 25 2016 08:55
@Knochenmark yes
Gordon
@gordoh
Aug 25 2016 08:55
@wearenotgroot i know its not lol! Its very disheartening when I get stuck on something like this. But I have to be honest the guys in this chat are legends. Without you guys I probably would have given up by now. I hope you get the credit that you deserve for all your hard work
Darth Skywalker
Aug 25 2016 08:55
No need to omit the first index since we're filtering over `arguments[0]`
so I don't see how that has any bearing on the calculation
Mark Todd
@Knochenmark
Aug 25 2016 08:56
@adityaparab well you do an indexOf between the array itself, which is redundant
greg
@wearenotgroot
Aug 25 2016 08:56
@gordoh thanks, we like hanging out here and help :smile:
CamperBot
@camperbot
Aug 25 2016 08:56
wearenotgroot sends brownie points to @gordoh :sparkles: :thumbsup: :sparkles:
Darth Skywalker
Aug 25 2016 08:57
@Knochenmark : No it's not
Gordon
@gordoh
Aug 25 2016 08:58
@wearenotgroot you should get paid by FreeCodeCamp for doing the explaining.
greg
@wearenotgroot
Aug 25 2016 08:58
@gordoh nah, it's freecodecamp for a reason :smile:
fongor
@fongor
Aug 25 2016 08:58

hey there, I have a question about JSON and AJAX requests. I couldn't have the behavior I was trying to have in Code pen, and couldn't understand why, so just copied and pasted FCC's code from this page https://www.freecodecamp.com/challenges/convert-json-data-to-html. I copied everything in my codepen HTML, just replacing FCC's json local url by an http url of course (and I checked it), and adding of course bootstrap and jquery to my pen :

<script>

\$("#getMessage").on("click", function() {
\$.getJSON("https://www.freecodecamp.com/json/cats.json", function(json) {

var html = "";
// Only change code below this line.

json.forEach(function(val) {
var keys = Object.keys(val);
html += "<div class = 'cat'>";
keys.forEach(function(key) {
html += "<b>" + key + "</b>: " + val[key] + "<br>";
});
html += "</div><br>";
});

// Only change code above this line.

\$(".message").html(html);

});
});
});

</script>

<div class="container-fluid">
<div class = "row text-center">
<h2>Cat Photo Finder</h2>
</div>
<div class = "row text-center">
<div class = "col-xs-12 well message">
The message will go here
</div>
</div>
<div class = "row text-center">
<div class = "col-xs-12">
<button id = "getMessage" class = "btn btn-primary">
Get Message
</button>
</div>
</div>
</div>

And surprisingly, I don't have the same result in code pen (neither jsfiddle) than I have in fcc : I have the layout, but when I click on the button, nothing happens. Any idea why ??

Markus Kiili
@Masd925
Aug 25 2016 08:58
@adityaparab When you have the number there already, you should put it to 1 `(arguments,1)`
Mark Todd
@Knochenmark
Aug 25 2016 08:59
@adityaparab if you do something twice for no reason and in this case its actually useless, it is redundant