12th
Mar 2016
@roddyongit
Mar 12 2016 00:00
str = str.replace(/'/g,''');
str = str.replace(/'/g,''');
what would be a right way to find a single quote in a string?
Jordan Meyer
@Jordanmeyer89
Mar 12 2016 00:01
so i did arr.push(item); return arr.shift(item); and it worked
so i guess i have to shift the item as well not just shift()
@alpox thank you
CamperBot
@camperbot
Mar 12 2016 00:01
jordanmeyer89 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star: 368 | @alpox | http://www.freecodecamp.com/alpox
alpox
@alpox
Mar 12 2016 00:01
@roddyongit to find or to replace. And replace with what?
@Jordanmeyer89 Nope
Jordan Meyer
@Jordanmeyer89
Mar 12 2016 00:02
nvm it worked without item too
alpox
@alpox
Mar 12 2016 00:02
@Jordanmeyer89 return arr.shift(); is enough since shift doesnt take any input parameters. It just removes the first element of the array and returns it
Jordan Meyer
@Jordanmeyer89
Mar 12 2016 00:02
spooky
@roshankd
Mar 12 2016 00:03
plz give some idea

var count = 0;

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

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

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

alpox
@alpox
Mar 12 2016 00:04
@roshankd card==2,3,4,5,6 you cannot list them like that... better do: card > 1 && card <= 6
@roshankd Comma seperated doesnt work. You can also use switch if you want
@roshankd
Mar 12 2016 00:05
@alpox thank you
CamperBot
@camperbot
Mar 12 2016 00:05
roshankd sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star: 369 | @alpox | http://www.freecodecamp.com/alpox
@roddyongit
Mar 12 2016 00:06
I am to replace the single quote with the equivalent HTML entity "'"
alpox
@alpox
Mar 12 2016 00:06
@roddyongit "'" is not the equivalent html entity
@roddyongit "&apos;" is
maybe you wrote that but i don't see it since it changes here :D
@roddyongit
Mar 12 2016 00:07
yes, that is the one I am using
alpox
@alpox
Mar 12 2016 00:07
ah okay
so: str.replace('\'', "&apos;")
@roddyongit
Mar 12 2016 00:08
ok, let me try that one @alpox
did not work either. still failing this scenario: convert("Shindler's List")
that is the only one I am missing to complete this challenge
alpox
@alpox
Mar 12 2016 00:11
@roddyongit Can you show your whole code here?
With what camperbot says:
help format
CamperBot
@camperbot
Mar 12 2016 00:11

## :point_right: code formatting [wiki]

### Multi line Code

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

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

 ⇦ Type 3 backticks, then press [enter ⏎]

### Single line Code

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

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

@roddyongit
Mar 12 2016 00:12

function convert(str) {

var apos = /'/g;
var apos1 = "'";

var comamp = /\&/g;
var comamp1 = "&";

var quot = /\"/g;
var quot1 = """;

var lt = /</g;
var lt1 = "<";

var gt = />/g;
var gt1 = ">";

var commat = /\@/g;
var commat1 = "@";

str = str.replace(apos,apos1);

//str.split("'").join("'");
str = str.replace(comamp,comamp1);
str = str.replace(quot,quot1);
str = str.replace(lt,lt1);
str = str.replace(gt,gt1);
str = str.replace(commat,commat1);

str = str.replace("\''", "'");

return str;

}


alpox
@alpox
Mar 12 2016 00:13
This message was deleted
Ouh where do i begin
""" you cannot put three of them after each other like that without escaping the middle one
Ah well
I guess that is again that transformation here
Maybe try to put it in a proper backtick wrapper
help format
CamperBot
@camperbot
Mar 12 2016 00:15

## :point_right: code formatting [wiki]

### Multi line Code

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

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

 ⇦ Type 3 backticks, then press [enter ⏎]

### Single line Code

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

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

Segun Akindairo
@Segdaren
Mar 12 2016 00:21
function isLess(a, b) {
// Fix this code
return true < false;
}
alpox
@alpox
Mar 12 2016 00:21
@Segdaren true < false doesnt make much sense :D
Marc
@wumpafruits
Mar 12 2016 00:22
@Segdaren you have to return a, b somehow
alpox
@alpox
Mar 12 2016 00:22
@Segdaren You have to compare the given parameters (a, b)
Marc
@wumpafruits
Mar 12 2016 00:22
^
Segun Akindairo
@Segdaren
Mar 12 2016 00:22
ok thanks
@roddyongit
Mar 12 2016 00:25
There seems to be a trick when finding the single quote in a string

K.K.Smith
@tychonaut
Mar 12 2016 00:27

Woops I posted this in the wrong room.

Anyone here a ninja? Can I get some critique on my solution for "Inventory Update" in Advanced Algorithm? It works but it feels clunky.

http://codepen.io/tychonaut/pen/zqBXgP

@roddyongit
Mar 12 2016 00:28
var str = "Shindler's List";
var str1 = "";
str1 = str.split("'").join("'");
console.log(str);
console.log(str1);
I tested this code and it works find except in the test FCC window
bitgrower
@bitgrower
Mar 12 2016 00:29
probably because you aren't running thru all the test cases ... :)
alpox
@alpox
Mar 12 2016 00:29
@roddyongit Please put the code here properly with  on first and last line
@roddyongit
Mar 12 2016 00:29
all other test cases passed, except the single quote
bitgrower
@bitgrower
Mar 12 2016 00:29
which challenge is this ?
@roddyongit
Mar 12 2016 00:29
HTML entities

function convert(str) {

var apos = /'/g;
var apos1 = "'";

var comamp = /\&/g;
var comamp1 = "&";

var quot = /\"/g;
var quot1 = """;

var lt = /</g;
var lt1 = "<";

var gt = />/g;
var gt1 = ">";

var commat = /\@/g;
var commat1 = "@";

str = str.replace(apos,apos1);
str = str.replace(comamp,comamp1);
str = str.replace(quot,quot1);
str = str.replace(lt,lt1);
str = str.replace(gt,gt1);
str = str.replace(commat,commat1);

str.split("'").join("'");

return str;
}


alpox
@alpox
Mar 12 2016 00:31
@roddyongit the backticks should not be together with other code on the line
shift-enter after the backticks
Ramsay Sewell
@ramsaysewell
Mar 12 2016 00:32
help Seek and Destroy
CamperBot
@camperbot
Mar 12 2016 00:32

# Explanation:

This problem is a bit tricky because you have to familiarize yourself with Arguments, as you will have to work with two or more but on the script you only see two. Many people hardcode this program for three arguments. You will remove any number from the first argument that is the same as any other other arguments.

@roddyongit
Mar 12 2016 00:32
function convert(str) {

var apos = /'/g;
var apos1 = "&apos;";

var comamp = /\&/g;
var comamp1 = "&amp;";

var quot = /\"/g;
var quot1 = "&quot;";

var lt = /</g;
var lt1 = "&lt;";

var gt = /\>/g;
var gt1 = "&gt;";

var commat = /\@/g;
var commat1 = "&commat;";

str = str.replace(apos,apos1);
str = str.replace(comamp,comamp1);
str = str.replace(quot,quot1);
str = str.replace(lt,lt1);
str = str.replace(gt,gt1);
str = str.replace(commat,commat1);

str.split("'").join("&apos;");

return str;
}
got it

str.split("'").join("'");

This last line is an attempt to get it right, since the regular exp is not working

var apos = /'/g;

bitgrower @bitgrower 's eyes thank @roddyongit
CamperBot
@camperbot
Mar 12 2016 00:37
bitgrower sends brownie points to @roddyongit :sparkles: :thumbsup: :sparkles:
:star: 300 | @roddyongit | http://www.freecodecamp.com/roddyongit
alpox
@alpox
Mar 12 2016 00:38
@roddyongit don't split and join. do a replace
@roddyongit
Mar 12 2016 00:39
I ignored the join and only using the replace, but not working... can you check the value I am using for the var apos?
is that the right one for the single quote?
it is not finding it
it is finding all other cases though
alpox
@alpox
Mar 12 2016 00:40
@roddyongit Hahaha :D
@roddyongit I see the problem
@roddyongit
str = str.replace(apos, apos1); after that one its right
@roddyongit But you have a string with an & in it
@roddyongit On the next line you do:
str = str.replace(comamp, comamp1);
That replaces the & with &amp;
thats not quite what you wanted to do i guess :-)
@roddyongit
Mar 12 2016 00:41
ok, let me check...
got it @alpox
Thanks @alpox
CamperBot
@camperbot
Mar 12 2016 00:42
roddyongit sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star: 371 | @alpox | http://www.freecodecamp.com/alpox
@roddyongit
Mar 12 2016 00:43
I just changed the replace line for the single quote to the end
I guess I understand the point, although I will review for my own benefit
Gershom
@jinmanbok
Mar 12 2016 00:46
js
var Car = function(wheels, seats, engines) {
//Change this constructor
this.wheels = wheels;
this.seats = seats;
this.engines = engines;
};

//Try it out here
new Car(3,1,2);
I passed but I think there's a bug
Because when I output it doesn't match
the numbers that I put in for wheels, seats, and engines.
alpox
@alpox
Mar 12 2016 00:48
@jinmanbok When you output what?
Gershom
@jinmanbok
Mar 12 2016 00:48
When I run it shows like the wrong values
on the left-hand side
Under reset help etc.
alpox
@alpox
Mar 12 2016 00:48
@jinmanbok => { wheels: 3, seats: 1, engines: 2 } looks right to me
Gershom
@jinmanbok
Mar 12 2016 00:49
crap i went back to it and now it says "ReferenceError: myCar is not defined"
alpox
@alpox
Mar 12 2016 00:50
@jinmanbok Maybe you changed the setup too much:
var Car = function() {
this.wheels = 4;
this.engines = 1;
this.seats = 1;
};

// Only change code below this line.

var myCar = new Car();
myCar.nickname = "test";
Ramsay Sewell
@ramsaysewell
Mar 12 2016 00:52
Can someone help me with the random quote generator please?
alpox
@alpox
Mar 12 2016 00:52
@ramsaysewell whats up? :D
Oh damn i should really sleep :-/
Gershom
@jinmanbok
Mar 12 2016 00:53
ah thanks @alpox I'll redo it and make sure the code is fine
CamperBot
@camperbot
Mar 12 2016 00:53
jinmanbok sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star: 373 | @alpox | http://www.freecodecamp.com/alpox
Steve Carroll
@SteveCarroll
Mar 12 2016 00:53
Ramsay Sewell
@ramsaysewell
Mar 12 2016 00:53
@alpox I’ve set up how I wanted it laid out but I just need to get the API working. I went over the previsou turotials but it doesn’t clear things up for me.
Steve Carroll
@SteveCarroll
Mar 12 2016 00:54
I did it without touching the API (never said you had to)
But I'll probably go back and do it using the API so I can get familiar with it...
Ramsay Sewell
@ramsaysewell
Mar 12 2016 00:55
That’s why I want to use an API.
To get better at using them.
alpox
@alpox
Mar 12 2016 00:55
@ramsaysewell Do you have some code?
@ramsaysewell Or you don't know an api
Jaron Mauk
@jaronmauk5
Mar 12 2016 00:55
So I am on the challenge "Selecting from many options with Switch Statements" and I am not sure what I need to put in place for the "case value".
Ramsay Sewell
@ramsaysewell
Mar 12 2016 00:55
No Javascript so far, no.
alpox
@alpox
Mar 12 2016 00:56
@ramsaysewell Well sry i cannot help then. I didn't use a quote api so i don't know one... Mine became a random youtube vid machine :D
Steve Carroll
@SteveCarroll
Mar 12 2016 00:56
@ramsaysewell Maybe start generating quotes first?
Ramsay Sewell
@ramsaysewell
Mar 12 2016 00:57
@SteveCarroll Before what?
Steve Carroll
@SteveCarroll
Mar 12 2016 00:57
Before tweeting them
Ramsay Sewell
@ramsaysewell
Mar 12 2016 00:57
@SteveCarroll Yeah, ofc.
Steve Carroll
@SteveCarroll
Mar 12 2016 00:57
It is a js algo, after all...
I don;t even have any styling on mine yet.
But it's functional
alpox
@alpox
Mar 12 2016 00:59
So i'm in bed then
cya guys
Jin Choi
@JiniHendrix
Mar 12 2016 01:10
hello, my output seems to be correct but the lesson says it's wrong
Steve Carroll
@SteveCarroll
Mar 12 2016 01:11
@JiniHendrix Play 'Hey joe' and post your code
Jin Choi
@JiniHendrix
Mar 12 2016 01:11

function drawer(price, cash, cid) {
var change=[]; var total = 0; var newChange; var changeDue = cash-price;
var amountsArr = [0.01, 0.05, 0.1, 0.25, 1, 5, 10, 20, 100];
console.log(price);
// Here is your change, ma'am.
for(var i = 0; i < cid.length; i++) { total += cid[i][1]; } //if cash drawer = change due return closed
if(changeDue == total) return 'Closed';
if(changeDue > total) return 'Insufficient Funds'; //if cash in drawer < change due, return Insufficient Funds

for(i = cid.length-1; i >= 0; i--) {
//first find how many bills of each type there are and then subtract them from total, then move down the list
while(cid[i][1] > 0) {
cid[i][1]=Math.round(cid[i][1] 100) / 100;
changeDue = Math.round(changeDue
100)/100;

  if((newChange = changeDue - cid[i][1]) >= 0) {console.log(cid[i]);cid[i][1] = ;
change.push(cid[i]);

if(newChange === 0) return change;

changeDue = newChange;
cid[i][1] = 0;
}
else {

//newPrice = price;
cid[i][1] -= amountsArr[i];

}
}

}

return 'Insufficient Funds';
}

drawer(19.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);

umm yea how do i format code?
Klubuntu
@Klubuntu
Mar 12 2016 01:12
var arr = [
[1,2], [3,4], [5,6]
];
for (var i=0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++) {
console.log(arr[i][j]);
}
}
....Could anyone explain me every line of this code?
Jin Choi
@JiniHendrix
Mar 12 2016 01:13

'''
function drawer(price, cash, cid) {
var change=[]; var total = 0; var newChange; var changeDue = cash-price;
var amountsArr = [0.01, 0.05, 0.1, 0.25, 1, 5, 10, 20, 100];
console.log(price);
// Here is your change, ma'am.
for(var i = 0; i < cid.length; i++) { total += cid[i][1]; } //if cash drawer = change due return closed
if(changeDue == total) return 'Closed';
if(changeDue > total) return 'Insufficient Funds'; //if cash in drawer < change due, return Insufficient Funds

for(i = cid.length-1; i >= 0; i--) {
//first find how many bills of each type there are and then subtract them from total, then move down the list
while(cid[i][1] > 0) {
cid[i][1]=Math.round(cid[i][1] 100) / 100;
changeDue = Math.round(changeDue
100)/100;

  if((newChange = changeDue - cid[i][1]) >= 0) {console.log(cid[i]);cid[i][1] = ;
change.push(cid[i]);

if(newChange === 0) return change;

changeDue = newChange;
cid[i][1] = 0;
}
else {

//newPrice = price;
cid[i][1] -= amountsArr[i];

}
}

}

return 'Insufficient Funds';
}

drawer(19.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
'''

CamperBot
@camperbot
Mar 12 2016 01:13
:bulb: to format code use backticks!  more info
Jin Choi
@JiniHendrix
Mar 12 2016 01:14
function drawer(price, cash, cid) {
var change=[]; var total = 0; var newChange; var changeDue = cash-price;
var amountsArr = [0.01, 0.05, 0.1, 0.25, 1, 5, 10, 20, 100];
console.log(price);
// Here is your change, ma'am.
for(var i = 0; i < cid.length; i++) { total += cid[i][1]; } //if cash drawer = change due return closed
if(changeDue == total) return 'Closed';
if(changeDue > total) return 'Insufficient Funds'; //if cash in drawer < change due, return Insufficient Funds

for(i = cid.length-1; i >= 0; i--) {
//first find how many bills of each type there are and then subtract them from total, then move down the list
while(cid[i][1] > 0) {
cid[i][1]=Math.round(cid[i][1] * 100) / 100;
changeDue = Math.round(changeDue*100)/100;

if((newChange = changeDue - cid[i][1]) >= 0) {console.log(cid[i]);cid[i][1] = ;
change.push(cid[i]);

if(newChange === 0) return change;

changeDue = newChange;
cid[i][1] = 0;
}
else {

//newPrice = price;
cid[i][1] -= amountsArr[i];

}
}
}

return 'Insufficient Funds';
}

drawer(19.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
ok there we go lol
im doing the cash register one
i have check marks on all except the 3.26 price one, but i dont know why
ykaran
@ykaran
Mar 12 2016 01:15
Variable myStr should equal to ("I am a "double quoted" string inside "double quotes"") ??
Jin Choi
@JiniHendrix
Mar 12 2016 01:15
my console is telling me my output should be correct
ykaran
@ykaran
Mar 12 2016 01:15
can anybody plz help me to solve this question
Jin Choi
@JiniHendrix
Mar 12 2016 01:15
not sure if its because the output needs to be floats and not INT's
ykaran
@ykaran
Mar 12 2016 01:16

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"??

Jin Choi
@JiniHendrix
Mar 12 2016 01:16
or you can use '' instead
on the outside
ykaran
@ykaran
Mar 12 2016 01:17
i am not getting the question ??
where??
Jin Choi
@JiniHendrix
Mar 12 2016 01:17
not sure about the backslashes tbh
to put quotes inside strings for example
myStr = 'Mike "Iron Mike" Tyson'
ykaran
@ykaran
Mar 12 2016 01:18
plz send me the output.
Jin Choi
@JiniHendrix
Mar 12 2016 01:18
and it should output
Mike "Iron Mike" Tyson
you can use '' or "" for string assignments
im sure you can use backslashes one way or another
ykaran
@ykaran
Mar 12 2016 01:19
i m new in js
K.K.Smith
@tychonaut
Mar 12 2016 01:20
@JiniHendrix I get an unexpected colon on line 16 when I paste your code
semi-colon, that is
Jin Choi
@JiniHendrix
Mar 12 2016 01:20
not sure how that got there
function drawer(price, cash, cid) {
var change=[]; var total = 0; var newChange; var changeDue = cash-price;
var amountsArr = [0.01, 0.05, 0.1, 0.25, 1, 5, 10, 20, 100];
console.log(price);
// Here is your change, ma'am.
for(var i = 0; i < cid.length; i++) { total += cid[i][1]; } //if cash drawer = change due return closed
if(changeDue == total) return 'Closed';
if(changeDue > total) return 'Insufficient Funds'; //if cash in drawer < change due, return Insufficient Funds

for(i = cid.length-1; i >= 0; i--) {
//first find how many bills of each type there are and then subtract them from total, then move down the list
while(cid[i][1] > 0) {
cid[i][1]=Math.round(cid[i][1] * 100) / 100;
changeDue = Math.round(changeDue*100)/100;

if((newChange = changeDue - cid[i][1]) >= 0) {console.log(cid[i]);
change.push(cid[i]);

if(newChange === 0) return change;

changeDue = newChange;
cid[i][1] = 0;
}
else {

//newPrice = price;
cid[i][1] -= amountsArr[i];

}
}
}

return 'Insufficient Funds';
}

drawer(19.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
should be just this
now im kinda worried i changed something accidentally...
think it works though
K.K.Smith
@tychonaut
Mar 12 2016 01:23
Did it work for you ..? I did this tonight and yours seems wonky ..
Jin Choi
@JiniHendrix
Mar 12 2016 01:24
i have check marks on all except the 3.26 price one
and for that one my console is saying i have the right output
@roshankd
Mar 12 2016 01:27
plz check this code

var count = 0;

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

if(card==3||card==2||card=='A'||card==10||card=='K'){
count=-1;
return "-1 Hold";
}
if(card==10||card=='J'||card=='Q'||card=='K'||card=='A'){
count=-1;
return "-5 Hold";
}
if(card==3||card==7||card=='Q'||card==8||card=='A'){
count=-1;
return "-1 Hold";
}
if(card==2||card=='J'||card==9||card==2||card==7){
count=-1;
return "1 Bet";
}

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

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

K.K.Smith
@tychonaut
Mar 12 2016 01:29
@JiniHendrix I can see the console logging the right amounts, but then only the 0.04 is getting assigned to your output array.
Jin Choi
@JiniHendrix
Mar 12 2016 01:31
@tychonaut that's strange.. this is my output when i output my change array
3.26
VM616:24 [Array[2]]
VM616:24 [Array[2], Array[2]]
VM616:24 [Array[2], Array[2], Array[2]]
VM616:24 [Array[2], Array[2], Array[2], Array[2]]
VM616:24 [Array[2], Array[2], Array[2], Array[2], Array[2]]
VM616:24 [Array[2], Array[2], Array[2], Array[2], Array[2], Array[2]]
VM616:24 [Array[2], Array[2], Array[2], Array[2], Array[2], Array[2], Array[2]]
K.K.Smith
@tychonaut
Mar 12 2016 01:31
@JiniHendrix ???
Jin Choi
@JiniHendrix
Mar 12 2016 01:31
well its jus showing that i at least have 7 elements for my final output
3.26
VM633:22 ["TWENTY", 60]
VM633:22 ["TEN", 20]
VM633:22 ["FIVE", 15]
VM633:22 ["ONE", 1]
VM633:22 ["QUARTER", 0.5]
VM633:22 ["DIME", 0.2]
VM633:22 ["PENNY", 0.04]
and these are what i'm pushing into the change array
sorry about the stuff no the left
K.K.Smith
@tychonaut
Mar 12 2016 01:32
yeh but according to my codepen output only PENNY has 0.04 .. all the others are 0.
Jin Choi
@JiniHendrix
Mar 12 2016 01:32
wow
ok
ohhhhh
thanks for discovering that
@tychonaut many thanks
CamperBot
@camperbot
Mar 12 2016 01:33
jinihendrix sends brownie points to @tychonaut :sparkles: :thumbsup: :sparkles:
K.K.Smith
@tychonaut
Mar 12 2016 01:33
noproblemo
CamperBot
@camperbot
Mar 12 2016 01:33
:star: 291 | @tychonaut | http://www.freecodecamp.com/tychonaut
Daniel Tait
@4xDMG
Mar 12 2016 01:39
Hey guys. Would anyone be able to help me out with the API call for the wikipedia viewer app?
I'm getting this error: "No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access."
K.K.Smith
@tychonaut
Mar 12 2016 01:41

@JiniHendrix Its seems you aren't accounting for partial payments...? Like .. if you have 60.00 in twenties, you try to subtract 60 from the changeDue .. if that doesn't work out, you go to next iteration ... what about 40.00? or 20.00? You don't have to use all the bills in a drawer, right?

This might not be your issue

Daniel Tait
@4xDMG
Mar 12 2016 01:41
I think I've gotta somehow tell the API where my request is coming from but don't know how to do it. I'm using the $.get method. not sure if thats right either... Segun Akindairo @Segdaren Mar 12 2016 01:42 I am stuck here. var myStr ="I am a \"double quoted \"string inside \"double quotes\"."; Steve Carroll @SteveCarroll Mar 12 2016 01:43 @Segdaren leave some spaces in there Segun Akindairo @Segdaren Mar 12 2016 01:43 ok Steve Carroll @SteveCarroll Mar 12 2016 01:43 before your escape chars Segun Akindairo @Segdaren Mar 12 2016 01:44 i have done that but not woring oh I mean not working Steve Carroll @SteveCarroll Mar 12 2016 01:46 Looks like it should. Copy your code, hit reset and try it again bitgrower @bitgrower Mar 12 2016 01:47 @4xDMG -- you need to research CORS ... Daniel Tait @4xDMG Mar 12 2016 01:49 @bitgrower ok will do. @bitgrower Thanks CamperBot @camperbot Mar 12 2016 01:49 4xdmg sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles: :star: 820 | @bitgrower | http://www.freecodecamp.com/bitgrower Mas hary @mas212 Mar 12 2016 02:07 myTest(4) should return "Less than 5" ?? function myTest(val) { if (val < 10) { return "Less than 10"; } else if (val < 10) { return "Less than 5"; } else { return "Greater than or equal to 10"; } } // Change this value to test myTest(6); rphares @rphares Mar 12 2016 02:14 @mas212 , so if the number is 4.... looking at the order you have now, what will it return? (remember that if you have a return, it exits. So in that order, the first if that is true, it will return and be done, it doesn't keep going...) Jonah Barreto @JBarreto1 Mar 12 2016 02:32 ''' var totalCid = cid.reduce(function(total, num){ return total += num[1]; }, 0); ''' When I return totalCid with cid being the first example in the Exact Change it's off by a little. What's up with that? It returns 335.4099999997 instead of just 335.41 CamperBot @camperbot Mar 12 2016 02:32 :bulb: to format code use backticks!  more info Jonah Barreto @JBarreto1 Mar 12 2016 02:34 var totalCid = cid.reduce(function(total, num){ return total += num[1]; }, 0); When I return totalCid with cid being the first example in the Exact Change it's off by a little. What's up with that? It returns 335.4099999997 instead of just 335.41 Collin @collinferry Mar 12 2016 02:36 @JBarreto1 I had the same issue, i think it has something to do with floating point numbers DJ @qualitymanifest Mar 12 2016 02:37 bitgrower @bitgrower Mar 12 2016 02:41 well, if you rounded the number ... Mas hary @mas212 Mar 12 2016 02:45 @rphares ok brother i will try Maddah Anass @unlimiworks Mar 12 2016 02:46 I'm coming and going without notifying lol :grinning: Can I get a code review on advanced algorithms challenges ? rphares @rphares Mar 12 2016 02:47 cool-- you get the idea? its the order that is throwing it off-- put them in order so that it can keep going ... if you put <10 before <5, for example, all the small numbers will all exit at less than 10... so the numbers that are less than 5 will never reach <5 (because they are less than 10 and it came first) @mas212 ~ Collin @collinferry Mar 12 2016 02:51 @UnlimiWorks Are you looking for cleanliness check of code that works or is there something specific you're working through? Maddah Anass @unlimiworks Mar 12 2016 02:52 @collinferry Cleanliness :) bitgrower @bitgrower Mar 12 2016 02:54 which one @UnlimiWorks ? Maddah Anass @unlimiworks Mar 12 2016 02:55 @bitgrower function telephoneCheck(str) { // Good luck! var regExp =/^(?:1[ -]?)?(?:(?:[0-9]{3})|(?:$$[0-9]{3}$$))[ -]?[0-9]{3}[ -]?[0-9]{4}$/;
//return str.match(regExp);
return regExp.test(str);
}

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

This is one mess of a reg expression... Is there a way to clean that a little bit ?

Kenni Gandira Alamsyah
@kenniga
Mar 12 2016 03:01
Hello Everyone, can anybody explain me how to make a function make "undefined" output?
it always goes with null
Robert Richey
@0x0936
Mar 12 2016 03:22
@UnlimiWorks that's more terse than my solution. :+1: just checked, mine is 7 characters shorter, but the whole string is visually longer due to character widths being variable
DJ
@qualitymanifest
Mar 12 2016 03:24
@UnlimiWorks can be done a little shorter. it would help if you commented it, to convey what each part does. here's the comments from mine to give you an example
/*Allow a 1 and a space, then area code with BOTH parens or NO parens,
*then allow a space/dash, three more numbers, allow another space/dash,
*then and the last four numbers. Nothing before or after*/
Ted Shaw
@TedTShaw
Mar 12 2016 03:26
hey all, wondering if I could "git" some help
Steve Carroll
@SteveCarroll
Mar 12 2016 03:27
@TedTShaw Lie what?
Like
Ted Shaw
@TedTShaw
Mar 12 2016 03:27
I'm on "Convert Celsius to Fahrenheit" on Java
not sure where to start

function convert(celsius) {
// Only change code below this line

// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

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

Steve Carroll
@SteveCarroll
Mar 12 2016 03:27
Sorry, don't have a clue about Java
That's Java? Looks a lot like javascript
Robert Richey
@0x0936
Mar 12 2016 03:29
that's javascript
Ted Shaw
@TedTShaw
Mar 12 2016 03:29
I meant javascript im sorry
Robert Richey
@0x0936
Mar 12 2016 03:29
the function signature would be different in java
@unlimiworks
Mar 12 2016 03:29
@0x0936 I thought it was a very long-could-be-shorter one, happy it's not the case :)
@qualitymanifest I'll try to comment that, coming up with a comment for this is a chore by itself :grin:
Steve Carroll
@SteveCarroll
Mar 12 2016 03:30
@0x0936 Hey, by his initial comment I thought he needed help with "git"
Robert Richey
@0x0936
Mar 12 2016 03:30
@UnlimiWorks my solution resulted from voodoo chanting and tribal dancing. I don't understand what I wrote and never want to look at it again lol
@SteveCarroll yeah, I caught that also ;)
Steve Carroll
@SteveCarroll
Mar 12 2016 03:31
@TedTShaw What is your function returning?
Or rather, what should it be returning?
function convert(celsius) {
// Only change code below this line

// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

// Change the inputs below to test your code
convert(30);
Fatah N
@fatahn
Mar 12 2016 03:34
Morning/Evening Guys
I am on Repeat a string JS algorithms
It asked me to use Global String Object Which I cant seem to unravel the meaning of. My code worked , but I would love to know how the Global String is useful. Thanks
function repeat(str, num) {
// repeat after me
var i = 1;
if(num>0){
while(i < num){
i++;
}
return str;
}
else{
return '';
}
}
repeat("*", 3);
@unlimiworks
Mar 12 2016 03:36
@0x0936 I get that feeling lol
Brigette Eckert
@Brigette-Eckert
Mar 12 2016 03:37
help Binary Agents
CamperBot
@camperbot
Mar 12 2016 03:37

# Explanation:

This problem is very straight forward, you will get a string that will represent a sentence in binary code, and you need to translate that into words. There is not direct way to do this so you will have to translate twice.

Malcolm
@noinkling
Mar 12 2016 03:38
@nfatah "global String object" just refers to the String constructor function/object
(cos all functions in JS are also objects)
Ted Shaw
@TedTShaw
Mar 12 2016 03:39
convert(0) should return a number
convert(-30) should return a value of -22
convert(-10) should return a value of 14
convert(0) should return a value of 32
convert(20) should return a value of 68
convert(30) should return a value of 86
Steve Carroll
@SteveCarroll
Mar 12 2016 03:39
function convert(celsius) {
// Only change code below this line
var fahrenheit ;

// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

// Change the inputs below to test your code
convert(30);
Malcolm
@noinkling
Mar 12 2016 03:39
@nfatah Pretty sure it's just there to give a name to the link, not something you have to worry about
Steve Carroll
@SteveCarroll
Mar 12 2016 03:40
Fatah N
@fatahn
Mar 12 2016 03:41
@noinkling how can i use it for example
Steve Carroll
@SteveCarroll
Mar 12 2016 03:41
Your function should return the conversion from celsius to fahrenheit, the numbers you feed it (or get as a result) don't matter.
So... you need to 'codify', so to speak, the mathematical conversion
Brian
@BrianCodes33
Mar 12 2016 03:41
can someone help me randomize my background color on click?
function change() {
var colorArray = []
var r = Math.floor(Math.random() * 256); // range is 0-255
var g = Math.floor(Math.random() * 256);
var b = Math.floor(Math.random() * 256);
var thergb = "'rgb(" + r + "," + g + "," + b + ")'";
console.log(thergb);
document.body.style.background=thergb;
}

document.querySelector("#brian").addEventListener("click", change);
why isn't the color randomizing?
Jared Pranke
@EtherWolf
Mar 12 2016 03:42
@nfatah via mdn-JavaScript automatically converts primitives to String objects, so that it's possible to use String object methods for primitive strings.
Ted Shaw
@TedTShaw
Mar 12 2016 03:42
got it. So I should be creating a variable of fahrenheit to set the structure
Malcolm
@noinkling
Mar 12 2016 03:42
@nfatah It's right there on the page: String(thing), but in real code it's basically never used
Steve Carroll
@SteveCarroll
Mar 12 2016 03:43
@TedTShaw Correct.
Malcolm
@noinkling
Mar 12 2016 03:43
@nfatah The link is to show you all the other useful info on the page
Steve Carroll
@SteveCarroll
Mar 12 2016 03:43
YOu'll find when you set that variable, you're done.
Providing you use the proper formula :)
Fatah N
@fatahn
Mar 12 2016 03:44
@noinkling no shit! Thanks :)
CamperBot
@camperbot
Mar 12 2016 03:44
nfatah sends brownie points to @noinkling :sparkles: :thumbsup: :sparkles:
:star: 630 | @noinkling | http://www.freecodecamp.com/noinkling
Malcolm
@noinkling
Mar 12 2016 03:46
@nfatah The only times you might use String directly is to access its static methods, e.g. String.fromCharCode()
Brigette Eckert
@Brigette-Eckert
Mar 12 2016 03:46
I've never dealt with binary before and not finding any great explanations - did anyone find any good resources for understanding binary while working on Binary Agents?
Steve Carroll
@SteveCarroll
Mar 12 2016 03:50
You're not calling the function
Malcolm
@noinkling
Mar 12 2016 03:50
@Brigette-Eckert You don't really need to know about binary for this, except that it's base 2
Look up parseInt
Steve Carroll
@SteveCarroll
Mar 12 2016 03:51
addEventListener("click", change());
Malcolm
@noinkling
Mar 12 2016 03:51
That'll allow you to convert it to a normal (base 10) number
Brian
@BrianCodes33
Mar 12 2016 03:51
@SteveCarroll i don't think so
Andrew Charlebois
@andrewchar
Mar 12 2016 03:52
trying to save my codepen and im getting POST http://codepen.io/pen/save net::ERR_NAME_NOT_RESOLVED
:S
Brian
@BrianCodes33
Mar 12 2016 03:52
@SteveCarroll document.querySelector("#button").addEventListener("click", change);
the change is the call
Steve Carroll
@SteveCarroll
Mar 12 2016 03:53
@BrianBorin You're right, nevermind ;)
Brigette Eckert
@Brigette-Eckert
Mar 12 2016 03:53
@noinkling okay thanks
CamperBot
@camperbot
Mar 12 2016 03:53
brigette-eckert sends brownie points to @noinkling :sparkles: :thumbsup: :sparkles:
:star: 631 | @noinkling | http://www.freecodecamp.com/noinkling
Brian
@BrianCodes33
Mar 12 2016 03:53
but why isn't the actual color changing? It is console logging, but not actually changing
Malcolm
@noinkling
Mar 12 2016 03:53
@Brigette-Eckert If you do wanna learn a bit more: http://www.freecodecamp.com/videos/computer-basics-decoding-a-binary-number
Steve Carroll
@SteveCarroll
Mar 12 2016 03:53
try getting rid of the'thergb' variable and feed it directly
sigursiguros
@sigursiguros
Mar 12 2016 03:55
Hi I'm working on the symmetric difference algo. Would you please let me know why my code isn't working
function GetSum( a,b ){
var c = [];
for (var i = 0; i<a.length; i++) {
for (var j = 0; j<b.length; j++) {
if (a[i] != b[j]){
c.push(b[i]);
}
}
}
return c;
}
Steve Carroll
@SteveCarroll
Mar 12 2016 03:56
I don;t see why that wouldn't work, though...
Ted Shaw
@TedTShaw
Mar 12 2016 03:57
@SteveCarroll Do I need to create another function to create the conversion formula?
Brian
@BrianCodes33
Mar 12 2016 03:57
@SteveCarroll not working
Steve Carroll
@SteveCarroll
Mar 12 2016 03:58
@TedTShaw No.
All you need is a simple formula: var fahrenheit = 'the formula';
@BrianBorin What does you html look like?
Malcolm
@noinkling
Mar 12 2016 03:59
@BrianBorin Did you try removing that extra set of quotes?
Steve Carroll
@SteveCarroll
Mar 12 2016 03:59
@noinkling That's it! :)
Malcolm
@noinkling
Mar 12 2016 03:59
var thergb = "rgb(" + r + "," + g + "," + b + ")";
Brian
@BrianCodes33
Mar 12 2016 03:59
        <h1 id="coding">Brian's BadAss Website</h1>
<div id="buttonCenter">
<button id="button">Click me</button>
</div>?
Steve Carroll
@SteveCarroll
Mar 12 2016 04:00
Then what is : document.querySelector("#brian").addEventListener("click", change);
("#brian") ??
Brian
@BrianCodes33
Mar 12 2016 04:00
Oh yea i changed it lol
that isn't the issue
changed it to #button
Steve Carroll
@SteveCarroll
Mar 12 2016 04:00
LOL! I do that stuff all the time ;)
Working?
Brian
@BrianCodes33
Mar 12 2016 04:01
@noinkling extra set of quotes?? not yet
Malcolm
@noinkling
Mar 12 2016 04:01
@BrianBorin Yeah you have some single quotes in there, I don't think they're necessary
Brian
@BrianCodes33
Mar 12 2016 04:01
ok sweet
Danny McCollins
@dmccollins
Mar 12 2016 04:02
I'm stumped on the Record Collection challenge...been struggling for a few days. If some one could just nudge me in the right direction I'd appreciate it.
Steve Carroll
@SteveCarroll
Mar 12 2016 04:02
@noinkling It shouldn't work woith those quotes, I think
Brian
@BrianCodes33
Mar 12 2016 04:03
@noinkling now a function to randomize the fonts onclick...hmmm this is fun :)
Steve Carroll
@SteveCarroll
Mar 12 2016 04:03
@BrianBorin It works?
Malcolm
@noinkling
Mar 12 2016 04:03
@SteveCarroll Yeah that's what I mean. I shoulda said "invalid" or something
Brian
@BrianCodes33
Mar 12 2016 04:03
yes @SteveCarroll
Steve Carroll
@SteveCarroll
Mar 12 2016 04:04
@noinkling So you really did know... you do have an inkling
Malcolm
@noinkling
Mar 12 2016 04:04
It's just my disclaimer in case I get something wrong
:stuck_out_tongue:
Steve Carroll
@SteveCarroll
Mar 12 2016 04:04
LOL
1
Brian
@BrianCodes33
Mar 12 2016 04:06
thanks @noinkling @SteveCarroll
CamperBot
@camperbot
Mar 12 2016 04:06
brianborin sends brownie points to @noinkling and @stevecarroll :sparkles: :thumbsup: :sparkles:
:star: 632 | @noinkling | http://www.freecodecamp.com/noinkling
:star: 294 | @stevecarroll | http://www.freecodecamp.com/stevecarroll
Steve Carroll
@SteveCarroll
Mar 12 2016 04:06
@BrianBorin sure
Mar 12 2016 04:06
hey guys i am doing the tribute page zipline and am having some problems with making a slideshow of images for the page
this is my code so far
anyone experienced with this? i am pretty sure i am doing most thigns right but am missing something small but fundamental
Ted Shaw
@TedTShaw
Mar 12 2016 04:07
@SteveCarroll It just shows the formula in the output, how can I make it a conversion with celsius
Steve Carroll
@SteveCarroll
Mar 12 2016 04:09
@TedTShaw You need to get a formula and make it = to the var
Ted, what is the formula for the conversion?
Mar 12 2016 04:10
@SteveCarroll what do you mean? it doesn't return anything :(
Steve Carroll
@SteveCarroll
Mar 12 2016 04:10
What is: if (!document.images)
What is?
sigursiguros
@sigursiguros
Mar 12 2016 04:11
Hi guys, what's wrong with my code?
function Person(firstAndLast) {
function getFullName(){
return firstAndLast;
}
}

var bob = new Person('Bob Ross');
bob.getFullName();
Steve Carroll
@SteveCarroll
Mar 12 2016 04:12
@sigursiguros Doesn't that exercise separate the first and last name?
Brian
@BrianCodes33
Mar 12 2016 04:13
@SteveCarroll trying to randomize font now, what am I doing wrong?
function changeFont () {
var fontType = ["Arial", "Helvetica", "Georgia", "Comic Sans", "Impact", "Tahoma", "Lucida Console"];
var randomFont = fontType[Math.floor(Math.random() * fontType.length)];
document.getElementById("coding").style.fontStyle = randomFont;
}
Sidharth Kriplani
@sidkrip
Mar 12 2016 04:13
wiki Profile Lookup
CamperBot
@camperbot
Mar 12 2016 04:13

# Checkpoint: Profile Lookup

Instructions

We have an array of objects representing different people in our contacts lists.

A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you.

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

Darwin RC
@darwinrc
Mar 12 2016 04:13
Steve Carroll
@SteveCarroll
Mar 12 2016 04:14
(function() {})();
@BrianBorin You didn't change the id again?:)
Brian
@BrianCodes33
Mar 12 2016 04:17
how is that an IIFE? document.querySelector("#button").addEventListener("click", changeFont);
Mar 12 2016 04:18
@SteveCarroll (!document.images) looks for if the page allows images on it; basically a simple case to keep the code running
sigursiguros
@sigursiguros
Mar 12 2016 04:19
@SteveCarroll yes but simply doing this it's saying that my getFullName() is not identified and I'm not getting why
Mar 12 2016 04:19
@darwinrc I wrapped my code in brackets to no effect :(
Malcolm
@noinkling
Mar 12 2016 04:20
@svadali2 setTimeout("slideit()", 2500) should be setTimeout(slideIt, 2500);
Darwin RC
@darwinrc
Mar 12 2016 04:20
@svadali2 not only the function, your whole code. Check the console, nothing is logging there
Malcolm
@noinkling
Mar 12 2016 04:20
no quotes no call brackets on the function name, and with a capital "I"
Steve Carroll
@SteveCarroll
Mar 12 2016 04:20
(function() {
})();
Brian
@BrianCodes33
Mar 12 2016 04:21
are you taking to me @SteveCarroll
Steve Carroll
@SteveCarroll
Mar 12 2016 04:21
@BrianBorin No, sorry
Sidharth Kriplani
@sidkrip
Mar 12 2016 04:22
Help needed with the bonfire Seek and Destroy
CamperBot
@camperbot
Mar 12 2016 04:22
no wiki entry for: needed with the bonfire seek and destroy
Steve Carroll
@SteveCarroll
Mar 12 2016 04:24
@BrianBorin But you're not accessing the array
var randomFont = fontType[Math.floor(Math.random() * fontType.length)]; - only produces a number, not an array element
Malcolm
@noinkling
Mar 12 2016 04:26
@darwinrc That's not necessary on codepen, JS gets placed at the bottom of the page
It was being executed correctly, just the setTimeout call was wrong
Steve Carroll
@SteveCarroll
Mar 12 2016 04:27
@noinkling You got it working?
Malcolm
@noinkling
Mar 12 2016 04:27
@SteveCarroll Yeah, with the change further up ^
Steve Carroll
@SteveCarroll
Mar 12 2016 04:28
AH!
Tried to invoke it...
Easy to miss (for me) ;)
Malcolm
@noinkling
Mar 12 2016 04:29
You're passing a callback function to execute (after the time elapses), not passing the result of an executed function
Steve Carroll
@SteveCarroll
Mar 12 2016 04:29
Right
Mar 12 2016 04:29
@noinkling good advice but after my set timeout changed, it is still incorrect :( i look ed at console.log it keeps saying maximum call stack exceeded
Steve Carroll
@SteveCarroll
Mar 12 2016 04:29
What exercise is this?
Malcolm
@noinkling
Mar 12 2016 04:29
you must have changed something lemme take another look
Mar 12 2016 04:30
Steve Carroll
@SteveCarroll
Mar 12 2016 04:31
I was born on the same day and year as MJ...
Malcolm
@noinkling
Mar 12 2016 04:31
(function slideIt() {
document.getElementById('img_1').src = slideShow[step].src
if (step < 2)
step++;
else
step = 0;
//call function "slideit()" every 2.5 seconds
setTimeout(slideIt(), 2500)
})();
No need to immediately invoke since you're calling it below, get rid of the wrapper. And change setTimeout(slideIt(), 2500) to setTimeout(slideIt, 2500)
Brian
@BrianCodes33
Mar 12 2016 04:32
@SteveCarroll can you help me a little futher changing the font type
Mar 12 2016 04:32
@noinkling thanks so much!!!
CamperBot
@camperbot
Mar 12 2016 04:32
svadali2 sends brownie points to @noinkling :sparkles: :thumbsup: :sparkles:
:star: 633 | @noinkling | http://www.freecodecamp.com/noinkling
Steve Carroll
@SteveCarroll
Mar 12 2016 04:32
@BrianBorin Did you get my last msg?
Mar 12 2016 04:32
@noinkling it worked and looks great
@SteveCarroll that's coincidental! i am a Huge fan of him :D
Malcolm
@noinkling
Mar 12 2016 04:33
Steve Carroll
@SteveCarroll
Mar 12 2016 04:33
@svadali2 I still get the call stack error
Or did you just change it again?
Mar 12 2016 04:33
ohh i didn't check console @SteveCarroll
yeah let me sen the updated copy
this should work @SteveCarroll
Malcolm
@noinkling
Mar 12 2016 04:34
Yeah just refresh it
I'm not getting any error
Steve Carroll
@SteveCarroll
Mar 12 2016 04:34
Yeah, it's humming now.
Malcolm
@noinkling
Mar 12 2016 04:35
@svadali2 I just wanna add that since you're reusing the same element and just changing its src, you don't need to create those new Image objects, you can just have an array of URLs
Brian
@BrianCodes33
Mar 12 2016 04:35
i guess i'm not understanding string concatenation. Can you help me out where to go from here?
function changeFontType () {
var fonts = ["Gerogia", "Helvetica", "Arial", "Times", "Courier"];
var fontPicker = fonts[Math.floor(Math.random() * fonts.length)];

}
Steve Carroll
@SteveCarroll
Mar 12 2016 04:36
You were never accessing array elements
@BrianBorin You were never accessing array elements
Brian
@BrianCodes33
Mar 12 2016 04:37
lol can you show me? I am struggling here
Steve Carroll
@SteveCarroll
Mar 12 2016 04:37
fonttype.randomFont
YOur randomFont var is just a number
get it?
Malcolm
@noinkling
Mar 12 2016 04:40
@BrianBorin That looks alright to me, except you misspelled "Georgia"
Brian
@BrianCodes33
Mar 12 2016 04:40
@noinkling how do i access the call?
V Arun Kumar
@arunvkumr
Mar 12 2016 04:41
morning @SteveCarroll ! :smile:
Steve Carroll
@SteveCarroll
Mar 12 2016 04:41
@arunkumrv Hey
@BrianBorin fontType.randomFont
Sidharth Kriplani
@sidkrip
Mar 12 2016 04:42
is anyone done with the bonfire Seek and Destroy?
Steve Carroll
@SteveCarroll
Mar 12 2016 04:42
function changeFont () {
var fontType = ["Arial", "Helvetica", "Georgia", "Comic Sans", "Impact", "Tahoma", "Lucida Console"];
var randomFont = fontType[Math.floor(Math.random() * fontType.length)];
document.getElementById("coding").style.fontStyle = randomFont;
}
sigursiguros
@sigursiguros
Mar 12 2016 04:43
@SteveCarroll this is how it looks now, it's still saying getFullName() not defined.
function Person (one,two,three) {
function getFirstName(){
return one;
}
function getLastName(){
return two;
}
function getFullName(){
return three;
}
function setFirstName(first){
one = first;
}
function setLastName(last){
two = last;
}
function setFullName(firstAndLast){
three = firstAndLast;
}
}

var bob = new Person("Bob","Ross","Boss Ross");
bob.getFullName();
Sidharth Kriplani
@sidkrip
Mar 12 2016 04:43
guys...?
bonfire Seek and Destroy?
CamperBot
@camperbot
Mar 12 2016 04:43

## :fire:Bonfire: Seek and Destroy :link:

function destroyer(arr) {
// Remove all the values
return arr;
}

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

You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.

more info:  bf details | bf links | hint

Steve Carroll
@SteveCarroll
Mar 12 2016 04:43
Malcolm
@noinkling
Mar 12 2016 04:43
@SteveCarroll You want .fontFamily
I think
Steve Carroll
@SteveCarroll
Mar 12 2016 04:44
@noinkling He needs to acces the array
access
as well
Brian
@BrianCodes33
Mar 12 2016 04:44
@noinkling awesome!
V Arun Kumar
@arunvkumr
Mar 12 2016 04:45
Steve Carroll
@SteveCarroll
Mar 12 2016 04:45
@BrianBorin It worked without accessing the array?
Malcolm
@noinkling
Mar 12 2016 04:45
@SteveCarroll He was accessing the array, from what I could see from what he posted
Steve Carroll
@SteveCarroll
Mar 12 2016 04:45
@SteveCarroll Never ming, you are, I see it now
Malcolm
@noinkling
Mar 12 2016 04:45
Maybe I missed something earlier
Sidharth Kriplani
@sidkrip
Mar 12 2016 04:45
@SteveCarroll this is my code for it and I dont know why it isnt working.
function destroyer(arr) {
// Remove all the values
var arrays=[];
arrays.push(arr.filter(function(i) {
for (i in arr[0]) {
for(var j=1; j<3; j++)
if(i!== arr[j]) {
return i;}
}
}));
return arrays;
}
Steve Carroll
@SteveCarroll
Mar 12 2016 04:45
NO, I stooped up again
LOL!
Sidharth Kriplani
@sidkrip
Mar 12 2016 04:45
@arunkumrv
Brian
@BrianCodes33
Mar 12 2016 04:46
@SteveCarroll yes
Steve Carroll
@SteveCarroll
Mar 12 2016 04:46
@BrianBorin It works now?
FontStyle... duh
Sidharth Kriplani
@sidkrip
Mar 12 2016 04:47
@SteveCarroll @arunkumrv I guess maybe its not working because I have a return in the if statement and that breaks the loop?
wiki Caesars Cipher
CamperBot
@camperbot
Mar 12 2016 04:48

# Problem Explanation:

• You need to write a function, which will take string encoded with
Caesar cipher as a parameter and decode it.
• The one used here is ROT13 where the value of the letter is
shifted by 13 places.
e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
• You have to shift it back 13 positions, such that 'N' ↔ 'A'.
V Arun Kumar
@arunvkumr
Mar 12 2016 04:48
@sidkrip ---> if(i !== arr[j]) why you are comparing with index?
Steve Carroll
@SteveCarroll
Mar 12 2016 04:48
@arunkumrv Yeah...
Sidharth Kriplani
@sidkrip
Mar 12 2016 04:49
i is the values in the array right. I am comparing it with other values?
V Arun Kumar
@arunvkumr
Mar 12 2016 04:50
@sidkrip isn't the challenge objective is to using arguments objects?
Sidharth Kriplani
@sidkrip
Mar 12 2016 04:50
wiki Seek and Destroy
CamperBot
@camperbot
Mar 12 2016 04:50

# Explanation:

This problem is a bit tricky because you have to familiarize yourself with Arguments, as you will have to work with two or more but on the script you only see two. Many people hardcode this program for three arguments. You will remove any number from the first argument that is the same as any other other arguments.

Sidharth Kriplani
@sidkrip
Mar 12 2016 04:51
@arunkumrv okay yes it is
I will scrape off this code and rewrite another one
V Arun Kumar
@arunvkumr
Mar 12 2016 04:51
@sidkrip and you have almost hardcoded the if part :smile:
Sidharth Kriplani
@sidkrip
Mar 12 2016 04:51
yes I realized the wiki had warned against doing it :)
Liam Bang
@Liam345
Mar 12 2016 04:52
function destroyer(arr,a,b,c) {
// Remove all the values

for (var i=0;i<arr.length;i++)
{
if(arr[i]==a)
{
arr=arr.filter(function(val){
return val!==a;
});
}
else if(arr[i]==b)
{
arr=arr.filter(function(val){
return val!==b;
});

}
else if (arr[i]==c)
{
arr=arr.filter(function(val){
return val!==c;
});

}

}
return arr;
This is my code for seek and destroy, i.e. it destroys the elements from initial array that are same as value in the arguments. What is the logical error in the code?
Ted Shaw
@TedTShaw
Mar 12 2016 04:53
@SteveCarroll not sure what I'm doing wrong if you can take a look

function convert(celsius) {
// Only change code below this line
var fahrenheit = '(9/5) + 32';
// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

// Change the inputs below to test your code
convert(0);

Steve Carroll
@SteveCarroll
Mar 12 2016 04:54
@TedTShaw var fahrenheit = celsius * (9/5) + 32;
See why that works?
V Arun Kumar
@arunvkumr
Mar 12 2016 04:55
@Liam345 instead of using three if condition, you could have used an or operator. :smile:
Jared Pranke
@EtherWolf
Mar 12 2016 05:03
What is the keyboard input for the or operator characters?
Malcolm
@noinkling
Mar 12 2016 05:04
@EtherWolf Shift + backslash
||
Jared Pranke
@EtherWolf
Mar 12 2016 05:04
@noinkling Thanks!
CamperBot
@camperbot
Mar 12 2016 05:04
etherwolf sends brownie points to @noinkling :sparkles: :thumbsup: :sparkles:
:star: 634 | @noinkling | http://www.freecodecamp.com/noinkling
V Arun Kumar
@arunvkumr
Mar 12 2016 05:06
@Liam345 you code is find.. you just have to reset value of i.. after every successful return from filter, that's all you have to do. :smile:
Liam Bang
@Liam345
Mar 12 2016 05:09
@arunkumrv . Can you please explain why?
V Arun Kumar
@arunvkumr
Mar 12 2016 05:09
@Liam345 sure...
Malcolm
@noinkling
Mar 12 2016 05:10
@Liam345 You don't even have to loop manually, filter loops for you
Steve Carroll
@SteveCarroll
Mar 12 2016 05:10
@noinkling Can you take a quick look at something for me?
Malcolm
@noinkling
Mar 12 2016 05:10
@SteveCarroll sure
Steve Carroll
@SteveCarroll
Mar 12 2016 05:10
I need a private chat to show you the loink
Malcolm
@noinkling
Mar 12 2016 05:10
Go for it
Steve Carroll
@SteveCarroll
Mar 12 2016 05:10
But the button for it isn't showing up
Sometimes it does when I hover over you name, other times not...
@noinkling why is that?
bitgrower
@bitgrower
Mar 12 2016 05:13

@UnlimiWorks can be done a little shorter. it would help if you commented it, to convey what each part does. here's the comments from mine to give you an example

/*Allow a 1 and a space, then area code with BOTH parens or NO parens,
*then allow a space/dash, three more numbers, allow another space/dash,
*then and the last four numbers. Nothing before or after*/

nice!

V Arun Kumar
@arunvkumr
Mar 12 2016 05:17
@Liam345 see when you are inside the loop.. your initial array is suppose arr = [1,2,2,3,4,6], a = 2 and b = 3. the first values is compared with a i.e. 1 == 2 return false, then 1 is compare with remaing condition all will return false cos 1 != 2 and 1!=3.
for i = 1, second iteration value of arr[i] is 2.. if compares with first if.. 2 == 2 true.. now it enters the if condition and filter filters all the instances of 2.. so you are left with [1,3,4,6].. here your i value increments to 2.. now arr[2] = 4 because you have stored it in the same array and its using the 3th element but our one of the condition is to compare with b.. see the 2nd element which is 3.. and we missed to compare it...
so after the if gets true if you git i = 0 before returning that would work.
are you clear with what i'm trying to say?
and i second @noinkling on not using loops, cause filter does them automatically.
Ted Shaw
@TedTShaw
Mar 12 2016 05:22
@SteveCarroll Got it, thanks
CamperBot
@camperbot
Mar 12 2016 05:22
tedtshaw sends brownie points to @stevecarroll :sparkles: :thumbsup: :sparkles:
:star: 296 | @stevecarroll | http://www.freecodecamp.com/stevecarroll
bitgrower
@bitgrower
Mar 12 2016 05:22

Seek and Destroy peeps:

#1 -- your solution should handle ANY number of arguments, without you having to add parameters to your function call

#2 -- it's important to understand the arguments object -- which is array-like, but it is not actually an array

...that's it for now ...

it's really really important (and powerful) when you understand how the arguments object works ...
Steve Carroll
@SteveCarroll
Mar 12 2016 05:23
"Seek and Destroy peeps", sounds like a bad movie...
V Arun Kumar
@arunvkumr
Mar 12 2016 05:23
@Liam345 in short...
initially your arr = [1,2,2,3,4,6].. after 2 increaments and filter you arr becomes [1,3,4,6]. you have already done 2 increments(0,1) so i becomes 2 directely pointing to value 4(a[2]). you logic missed the value 3(a[1]).
Steve Carroll
@SteveCarroll
Mar 12 2016 05:23
@TedTShaw Good!
bitgrower
@bitgrower
Mar 12 2016 05:23
LOL @SteveCarroll
V Arun Kumar
@arunvkumr
Mar 12 2016 05:24
@Liam345 and listen to what captain @bitgrower has to say.. :point_up: March 12, 2016 10:52 AM
bitgrower
@bitgrower
Mar 12 2016 05:24
my brain hurts ...
Liam Bang
@Liam345
Mar 12 2016 05:24
@arunkumrv Yes I understand now. thanks
CamperBot
@camperbot
Mar 12 2016 05:24
liam345 sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 354 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Mar 12 2016 05:25
@Liam345 great... now your logic works... use arg objects and dont put function inside loops sometime it gives unexpected results.. :smile:
bitgrower
@bitgrower
Mar 12 2016 05:26
function defs, @arunkumrv ?
V Arun Kumar
@arunvkumr
Mar 12 2016 05:27
@bitgrower yes... when function are defined inside loops it may create multiple instances which may cause unexpected behavior. at least that what i heard :smile:
Malcolm
@noinkling
Mar 12 2016 05:28
thanks @SteveCarroll for teaching me something new
CamperBot
@camperbot
Mar 12 2016 05:28
noinkling sends brownie points to @stevecarroll :sparkles: :thumbsup: :sparkles:
:star: 297 | @stevecarroll | http://www.freecodecamp.com/stevecarroll
Steve Carroll
@SteveCarroll
Mar 12 2016 05:29
@noinkling Teach? I just pointed it.
bitgrower
@bitgrower
Mar 12 2016 05:30
@arunkumrv -- I think every time I've tried to define a function in a loop the code doesn't run ... I think the editor complains ...
V Arun Kumar
@arunvkumr
Mar 12 2016 05:30
@bitgrower even i'm not sure i was working on some code and it gave me something like that then i looked it up and that's what i read..
bitgrower
@bitgrower
Mar 12 2016 05:31
it makes sense ...
Malcolm
@noinkling
Mar 12 2016 05:31
@SteveCarroll Either way it deserves some brownie points :stuck_out_tongue:
bitgrower
@bitgrower
Mar 12 2016 05:31
what you say ...
Steve Carroll
@SteveCarroll
Mar 12 2016 05:31
@noinkling I'll take 'em, thanks!
CamperBot
@camperbot
Mar 12 2016 05:31
stevecarroll sends brownie points to @noinkling :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Mar 12 2016 05:31
does Steve deserve brownie points .. ?
CamperBot
@camperbot
Mar 12 2016 05:31
:star: 635 | @noinkling | http://www.freecodecamp.com/noinkling
bitgrower
@bitgrower
Mar 12 2016 05:31
@oninkling, @SteveCarroll -- thanks for all your work!
CamperBot
@camperbot
Mar 12 2016 05:31
bitgrower sends brownie points to @oninkling and @stevecarroll :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for oninkling
:star: 298 | @stevecarroll | http://www.freecodecamp.com/stevecarroll
Steve Carroll
@SteveCarroll
Mar 12 2016 05:32
Czn I trade them for an actual brownie at some point?
bitgrower
@bitgrower
Mar 12 2016 05:34
oops thanks @noinkling --
CamperBot
@camperbot
Mar 12 2016 05:34
bitgrower sends brownie points to @noinkling :sparkles: :thumbsup: :sparkles:
V Arun Kumar
@arunvkumr
Mar 12 2016 05:34
@bitgrower ya it think the same.. but when the function is done, isn't it removed from the memory so again defining functions should not effect right?
CamperBot
@camperbot
Mar 12 2016 05:34
:star: 636 | @noinkling | http://www.freecodecamp.com/noinkling
bitgrower
@bitgrower
Mar 12 2016 05:34
that would be nice, eh ...
don't even want to go there atm, @arunkumrv -- I just got thru doing a section on hoisting ...
V Arun Kumar
@arunvkumr
Mar 12 2016 05:36
thanks folks.... free brownies for all.. @bitgrower @camperbot @SteveCarroll @noinkling
CamperBot
@camperbot
Mar 12 2016 05:36
arunkumrv sends brownie points to @bitgrower and @camperbot and @stevecarroll and @noinkling :sparkles: :thumbsup: :sparkles:
:star: 637 | @noinkling | http://www.freecodecamp.com/noinkling
:star: 1342 | @camperbot | http://www.freecodecamp.com/camperbot
:star: 299 | @stevecarroll | http://www.freecodecamp.com/stevecarroll
:star: 821 | @bitgrower | http://www.freecodecamp.com/bitgrower
Amoury
@amoury
Mar 12 2016 05:37
Need help with the "Stand in line" challenge. This is the code that I have written in the function queue
queue.push(item);
queue.shift();
return item;
How to have function return the element that was removed
bitgrower
@bitgrower
Mar 12 2016 05:40
@amoury -- not trying to push you off -- but I recommend you go read the MDN pages for push & shift ... you may find your answer there ... (it IS there)
Amoury
@amoury
Mar 12 2016 05:40
ok thanks @bitgrower
CamperBot
@camperbot
Mar 12 2016 05:40
amoury sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 822 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 12 2016 05:42
yw -- happy coding, let us know ...
Mas hary
@mas212
Mar 12 2016 05:42
@bitgrower nice :)
Spas
@Spasmochi
Mar 12 2016 05:43
Anyone completed the Chunky Money challenge?
*Chunky Monkey
In basic algorythms
David Weedmark
@DavidWeedmark
Mar 12 2016 05:44
@Spasmochi ah that's a fun one isn't it?
Spas
@Spasmochi
Mar 12 2016 05:44
@DavidWeedmark yeah, well I solved it; except one tests returns failed despite the output appearing correct :(
bitgrower @bitgrower likes chunk monkey ...
bitgrower
@bitgrower
Mar 12 2016 05:45
@Spasmochi -- post your code ... and I'm feeling generous -- anyone who can post their code with syntax coloring ... well, my eyes will bestow brownie points ...
shalini-guha
@shalini-guha
Mar 12 2016 05:46

//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 lookUp(firstName, prop){
// Only change code below this line
if(contacts[firstName]!==undefined && contacts[prop]!==undefined)
return prop;
if(contacts[firstName]===undefined && contacts[prop]!==undefined)
return "No such contact";
if(contacts[firstName]!==undefined && contacts[prop]===undefined)
return "No such property";
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
^ the profile lookup one, can't figure out what went wrong :(

Steve Carroll
@SteveCarroll
Mar 12 2016 05:46
@bitgrower Does it have to be FCC challenge code?
Spas
@Spasmochi
Mar 12 2016 05:46

var nestArray = [];

function chunk(arr, size) {
var val = arr.length/size;
for (var i = 0; i < val; i++){
nestArray[[i]] = arr.slice(0,size);
for (var x = 0; x < size; x++){
arr.shift();
}

}
return nestArray;

}

chunk([0, 1, 2, 3, 4, 5], 4);

'''
var nestArray = [];

function chunk(arr, size) {
var val = arr.length/size;
for (var i = 0; i < val; i++){
nestArray[[i]] = arr.slice(0,size);
for (var x = 0; x < size; x++){
arr.shift();
}

}
return nestArray;

}

chunk([0, 1, 2, 3, 4, 5], 4);
'''

CamperBot
@camperbot
Mar 12 2016 05:47
:bulb: to format code use backticks!  more info
David Weedmark
@DavidWeedmark
Mar 12 2016 05:47
code goes here
bitgrower
@bitgrower
Mar 12 2016 05:47
LOL ... it has to be something someone is asking for help on a challenge for ... (dang is that enough prepositions?)
Spas
@Spasmochi
Mar 12 2016 05:47
lol, i put apostrophes, fail
var nestArray = [];

function chunk(arr, size) {
var val = arr.length/size;
for (var i = 0; i < val; i++){
nestArray[[i]] = arr.slice(0,size);
for (var x = 0; x < size; x++){
arr.shift();
}

}
return nestArray;

}

chunk([0, 1, 2, 3, 4, 5], 4);
bitgrower
@bitgrower
Mar 12 2016 05:47
hahahahahahahah ... @Spasmochi -- you can edit your message and fix it ...
David Weedmark
@DavidWeedmark
Mar 12 2016 05:48
@Spasmochi there you go!
bitgrower
@bitgrower
Mar 12 2016 05:48
@DavidWeedmark -- cute ...
Spas
@Spasmochi
Mar 12 2016 05:48
@bitgrower or I could be a bigger scrub and lazily post the proper markdown
at least I know now :/
bitgrower
@bitgrower
Mar 12 2016 05:48
"bigger scrub" ??? slang I not know ...
Craig Banach
@CraigBanach
Mar 12 2016 05:49
@bitgrower scrub == noob
kind of
Steve Carroll
@SteveCarroll
Mar 12 2016 05:49
var button = document.querySelector('#button'), quoteBox = document.querySelector('#quote');

function initQuote() {
var rndNum = Math.floor(Math.random() * (85 - 0) + 0);
var quoteStr = "&ldquo;<span class=\"quote\">" + quotes[rndNum].quote + "</span>&rdquo;" + " <span class =\"author\">" + quotes[rndNum].author + "</span>";
return quoteStr;
}

function writeQuote() {
quoteBox.innerHTML = initQuote();
}

writeQuote();

writeQuote();
});
})();
Spas
@Spasmochi
Mar 12 2016 05:50
@DavidWeedmark the code I posted passes every test but the one I posted with the code, the output for that tests matches the requirements, but still fails
David Weedmark
@DavidWeedmark
Mar 12 2016 05:50
@Spasmochi what's this? length/size;
Steve Carroll
@SteveCarroll
Mar 12 2016 05:51
@bitgrower And that is from a FCC challenge
@DavidWeedmark It's dividing the array given into nested arrays matching the size of the second argument
So chunk([0, 1, 2, 3, 4, 5], 4); should output [[0,1,2,3],[4,5]] which it does, but it still fails. I could scrap it, but I'd like to know why it fails
V Arun Kumar
@arunvkumr
Mar 12 2016 05:55
@Spasmochi nestArray[[i]] is that right?
bitgrower
@bitgrower
Mar 12 2016 05:56
@Spasmochi -- it doesn't like the fact that you are returning a Globally defined variable (and I agree, kinda bad form ... I moved the variable to inside the function and it passes all the tests ...
V Arun Kumar
@arunvkumr
Mar 12 2016 05:56
i'm seeing that first time.. :point_up: March 12, 2016 11:25 AM
Spas
@Spasmochi
Mar 12 2016 05:56
@bitgrower Ah, thx, that makes a lot of sense
CamperBot
@camperbot
Mar 12 2016 05:56
spasmochi sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 823 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 12 2016 05:57
@arunkumrv -- yeah, looks weird to me, as well ... LOL ... if you're up for a stretch, @Spasmochi -- your solution solved that particular test case in 30 steps ... my solution did it in 12
so @SteveCarroll -- is this a wanton desire for more brownie points ???? I thought I gave you thanks earlier ...
CamperBot
@camperbot
Mar 12 2016 05:58
bitgrower sends brownie points to @stevecarroll :sparkles: :thumbsup: :sparkles:
:warning: bitgrower already gave stevecarroll points
David Weedmark
@DavidWeedmark
Mar 12 2016 05:58
oh good call. I just tested it and found the same thing
Spas
@Spasmochi
Mar 12 2016 05:58
Yeah, I doubt I needed the that much code, it was what came to me first. I was just surprised it didn't work.
bitgrower
@bitgrower
Mar 12 2016 05:58
I can try !!!!
Tyler Del Rosario
@TylerDelRosario
Mar 12 2016 05:59
I'm having a hard time with Testing Objects for Properties.
I dont understand what I'm doing wrong here.
Here is my code:
// Setup
var myObj = {
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
myObj.hasOwnProperty(checkProp);
if (checkProp === undefined) {
}else {
return myObj[checkProp];
}
return "Change Me!";
}

// Test your code by modifying these values
checkObj("house");
Should I use false instead of undefined?
Chris Phillips
@christoph-phillips
Mar 12 2016 05:59
@HTMLNoob .hasOwnProperty() returns a boolean I think
bitgrower
@bitgrower
Mar 12 2016 05:59
well, your last return is rather superfluous
Gershom
@jinmanbok
Mar 12 2016 06:00
js
var Car = function() {
// this is a private variable
var speed = 10;

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

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

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

var Bike = function() {

// Only change code below this line.

this.setGear = function() {

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

};

var myCar = new Car();

var myBike = new Bike();
Tyler Del Rosario
@TylerDelRosario
Mar 12 2016 06:00
It came with the premade code. If i mess with it for some odd reason the challange wont pass
Gershom
@jinmanbok
Mar 12 2016 06:00
I am totally lost
Steve Carroll
@SteveCarroll
Mar 12 2016 06:00
@arunkumrv I'm a brownie slut now... what can I say
Chris Phillips
@christoph-phillips
Mar 12 2016 06:00
@HTMLNoob you need to store this in a variable first which you can then test if it is true or false
Steve Carroll
@SteveCarroll
Mar 12 2016 06:00
You guys did it to me
bitgrower
@bitgrower
Mar 12 2016 06:00
@jinmanbok -- use the Car function to guide you in what you need to do ...
thanks @jinmanbok
CamperBot
@camperbot
Mar 12 2016 06:00
bitgrower sends brownie points to @jinmanbok :sparkles: :thumbsup: :sparkles:
:star: 245 | @jinmanbok | http://www.freecodecamp.com/jinmanbok
Steve Carroll
@SteveCarroll
Mar 12 2016 06:00
I was fine the other day...
bitgrower
@bitgrower
Mar 12 2016 06:01
and my eyes thank you @HTMLNoob ...
CamperBot
@camperbot
Mar 12 2016 06:01
bitgrower sends brownie points to @htmlnoob :sparkles: :thumbsup: :sparkles:
:star: 208 | @htmlnoob | http://www.freecodecamp.com/htmlnoob
Tyler Del Rosario
@TylerDelRosario
Mar 12 2016 06:01
@christoph-phillips Thanks it worked!
CamperBot
@camperbot
Mar 12 2016 06:01
htmlnoob sends brownie points to @christoph-phillips :sparkles: :thumbsup: :sparkles:
:star: 371 | @christoph-phillips | http://www.freecodecamp.com/christoph-phillips
Gershom
@jinmanbok
Mar 12 2016 06:01
@bitgrower So just copy the car function but modify it for a bike?
cannelflow
@cannelflow
Mar 12 2016 06:01
This message was deleted
wiki format
CamperBot
@camperbot
Mar 12 2016 06:02

## :point_right: code formatting [wiki]

### Multi line Code

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

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

 ⇦ Type 3 backticks, then press [enter ⏎]

### Single line Code

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

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

Gershom
@jinmanbok
Mar 12 2016 06:02
I just know that gears make it easier or harder to pedal (^_^)^
V Arun Kumar
@arunvkumr
Mar 12 2016 06:02
@ShiviAnu ... listen what camper bot has tosay.
cannelflow
@cannelflow
Mar 12 2016 06:02
@ShiviAnu :point_up: March 12, 2016 11:32 AM
bitgrower
@bitgrower
Mar 12 2016 06:02
well, with some discretion, @jinmanbok ... the car has an accelerate function ... you don't, you need to code a set function ... so do the obvious thing ...
V Arun Kumar
@arunvkumr
Mar 12 2016 06:03
later foks... happy coding. :smile:
Gershom
@jinmanbok
Mar 12 2016 06:03
@bitgrower Ah ok thanks I'll research gears then think of something thanks!
CamperBot
@camperbot
Mar 12 2016 06:03
jinmanbok sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 824 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower @bitgrower 's eyes are thanking anyone who posts their code with syntax coloring ... hoping that might be additional encouragement for people to climb the hurdle of posting
V Arun Kumar
@arunvkumr
Mar 12 2016 06:03
thanks @bitgrower @cannelflow @jinmanbok @ShiviAnu @SteveCarroll ..
yayy free brownies for all
CamperBot
@camperbot
Mar 12 2016 06:03
arunkumrv sends brownie points to @bitgrower and @cannelflow and @jinmanbok and @shivianu and @stevecarroll :sparkles: :thumbsup: :sparkles:
:warning: arunkumrv already gave bitgrower points
:warning: arunkumrv already gave stevecarroll points
bitgrower
@bitgrower
Mar 12 2016 06:03
@jinmanbok -- it's not super hard ...
CamperBot
@camperbot
Mar 12 2016 06:03
:star: 892 | @cannelflow | http://www.freecodecamp.com/cannelflow
:star: 246 | @jinmanbok | http://www.freecodecamp.com/jinmanbok
:star: 222 | @shivianu | http://www.freecodecamp.com/shivianu
bitgrower
@bitgrower
Mar 12 2016 06:03
thank you @jinmanbok
CamperBot
@camperbot
Mar 12 2016 06:03
bitgrower sends brownie points to @jinmanbok :sparkles: :thumbsup: :sparkles:
:warning: bitgrower already gave jinmanbok points
Gershom
@jinmanbok
Mar 12 2016 06:04
lol I just overthink things... so I'll figure it out somehow haha
Ahhh higher gear lower gear get gear
Ok I think I know what to work with kkkk
Have a good one guys~
ShiviAnu
@ShiviAnu
Mar 12 2016 06:06
This message was deleted
Steve Carroll
@SteveCarroll
Mar 12 2016 06:08
@bitgrower So you bait me with you're feeling 'generous'... than you lambast me when I go to collect?
ShiviAnu
@ShiviAnu
Mar 12 2016 06:08
This message was deleted
Steve Carroll
@SteveCarroll
Mar 12 2016 06:08
I think a name change is in order here: sh*tgrower ;)
bitgrower
@bitgrower
Mar 12 2016 06:10
hahahahahaha ... lambast you? For having wanton desire ?
ShiviAnu
@ShiviAnu
Mar 12 2016 06:10
js[ ]function update(id, prop, value) { if(value !== "" && prop !== "tracks") collection[id].prop = value;[] why isnt the string passed to prop is reflected at the output screen.
bitgrower
@bitgrower
Mar 12 2016 06:10
that's not lambasting ... that's an acknowledgement of human nature ... :)
Steve Carroll
@SteveCarroll
Mar 12 2016 06:11
One man's (or woman's) lambasting is another's acknowledgement...
bitgrower
@bitgrower
Mar 12 2016 06:13
awwww ... I'm sorry ... :( ... will you forgive me ... ? :)
I already tried to give you more brownie points, but you're time hasn't run out so I can bestow another ... :)
Steve Carroll
@SteveCarroll
Mar 12 2016 06:14
I was actually just tryhing to get you to look at that code and explain why it worked
It's the thing I showed noinkling
bitgrower
@bitgrower
Mar 12 2016 06:16
ahhh ... you mean the code you said is part of an FCC challenge, above ?
Steve Carroll
@SteveCarroll
Mar 12 2016 06:16
Yes
bitgrower
@bitgrower
Mar 12 2016 06:16
for reference ... so, the truth is ... you were feeling spurned .. now I got it ... LOL ...
Steve Carroll
@SteveCarroll
Mar 12 2016 06:17
How'd you do that?
0x0936 @0x0936 detects vanilla js and backs away
bitgrower
@bitgrower
Mar 12 2016 06:17
and you want to boast because you did something cool !!!
alt click on top of the time stamp
Steve Carroll
@SteveCarroll
Mar 12 2016 06:17
No boast, just curious about why it worked.
That's cool
bitgrower
@bitgrower
Mar 12 2016 06:18
aahhahhhahhahahah you're using straight JS ... no jQuery ...
Steve Carroll
@SteveCarroll
Mar 12 2016 06:18
Yeah, Im trying to work with it whenever I can
bitgrower
@bitgrower
Mar 12 2016 06:19
yeah, @dcnr showed me how to do that ... when he wasn't posting laTex stuff ... LOL ...
@SteveCarroll -- for optimization purposes ?
Robert Richey
@0x0936
Mar 12 2016 06:19
${\color{limegreen}{sweet}}$
Steve Carroll
@SteveCarroll
Mar 12 2016 06:19
A lot of times you don't need all that crap
bitgrower
@bitgrower
Mar 12 2016 06:21
yeah, but you also don't need the headache of making sure it works on a dozen different browsers&versions, either ...
nice @0x0936
Steve Carroll
@SteveCarroll
Mar 12 2016 06:21
This should work on most everything
bitgrower
@bitgrower
Mar 12 2016 06:21
true -- but who wants to test it ?
Steve Carroll
@SteveCarroll
Mar 12 2016 06:21
But you have a point...
Most of those days are behind us now, I think...
AceMaridiam
@AceMaridiam
Mar 12 2016 06:22
On Escape Sequences in Strings: based off the instructions is appears to be asking for this
var myStr = "\b \t \t \r \n";
This however is not working
Robert Richey
@0x0936
Mar 12 2016 06:24
@SteveCarroll have you done a lot of DOM manipulation in vanilla JS? I tried it once, and ended up needing to create my own version of jQuery to abstract away the ugliness of vanilla JS DOM manipulation - so, I just went back to jQuery
rphares
@rphares
Mar 12 2016 06:24
@AceMaridiam check the chart again, there is no \b....
bitgrower
@bitgrower
Mar 12 2016 06:25

Most of those days are behind us now, I think...

check out the canIuse.com site ... don't think so ... don't think it's even conceivable, tbh ...

AceMaridiam
@AceMaridiam
Mar 12 2016 06:25
@rphares I noticed that right as you commented. This is why I shouldn't do this stuff after 10PM. :) Thanks for the help.
CamperBot
@camperbot
Mar 12 2016 06:25
acemaridiam sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 3229 | @rphares | http://www.freecodecamp.com/rphares
Steve Carroll
@SteveCarroll
Mar 12 2016 06:25
@bitgrower I mean for basic stuff like what I used there
rphares
@rphares
Mar 12 2016 06:26
anytime! happy coding~
bitgrower
@bitgrower
Mar 12 2016 06:26
yeah ... pretty limited subset of stuff, overall, though, @SteveCarroll -- esp if you want to do anything cool with graphics & animation ...
Steve Carroll
@SteveCarroll
Mar 12 2016 06:27
A lot of that is moving to css
noinkling pointed me to this earlier: http://youmightnotneedjquery.com/
bitgrower
@bitgrower
Mar 12 2016 06:29
yeah ... and you ever look at all that "vendor prefix" stuff ... ??? that's some of the kind of thing which jQuery should/is supposed to hide from you ...
Steve Carroll
@SteveCarroll
Mar 12 2016 06:30
That's what those prefix helpers are for :)
xentricqt
@xentricqt
Mar 12 2016 06:51

i'm on return early pattern for functions (210) i can get it to return a number but it'll return Null for -2,2 or 2,-2 instead of undefind '// Setup
function abTest(a, b) {
// Only change code below this line

console.log (Math.round(Math.pow(Math.sqrt(b) + Math.sqrt(a), 2 )));

// 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(2,-2);'

Gershom
@jinmanbok
Mar 12 2016 06:57
js
var Car = function() {
// this is a private variable
var speed = 10;

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

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

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

var Bike = function() {

// Only change code below this line.
// this is a private variable
var gear;

// these are public methods
this.setGear = function(gear); {
gear +=0;
}

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

var myCar = new Car();

var myBike = new Bike();
CamperBot
@camperbot
Mar 12 2016 06:57
:bulb: to format code use backticks!  more info
Gershom
@jinmanbok
Mar 12 2016 06:58
I feel soooo close but I'm wondering what I'm doing wrong
A gear is just one setting... so if you input a value for gear it remains constant. So I know after inputting a value to "Set" the gear... you just have to "get" the value of the gear that was input.
bitgrower
@bitgrower
Mar 12 2016 06:59
you are to use function expressions -- so all those places in the Car constructor where it uses function -- do the same in your Bike constructor
Gershom
@jinmanbok
Mar 12 2016 07:01
I changed it to function expressions... but still doesn't work (^_^)^
bitgrower
@bitgrower
Mar 12 2016 07:02
well .. you don't need to pass a parameter to each of the functions ... c'mon @jinmanbok -- don't make me think you're just making changes to try and shim the solution ... THINK !!!!
Gershom
@jinmanbok
Mar 12 2016 07:05
Car function accelerate and decelerate..... bike gears 7-11 So I guess have one function that increases.... one that decreases.... and another function that gets the gear that was set?
bitgrower
@bitgrower
Mar 12 2016 07:06
you have a set and a get function ... so you just need to take a parameter and set gear to it, and for the get function, you simply need to return the value of gear ... :)
no messy arithmetic involved ... in fact, no trivial arithmetic involved ... :)
Gershom
@jinmanbok
Mar 12 2016 07:07
Dangit... lol it's always a logical solution. I guess I just overthought...haha I did too many exercises today so my brain is jello
@bitgrower Thanks!
CamperBot
@camperbot
Mar 12 2016 07:07
jinmanbok sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 825 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 12 2016 07:08
LOL ... told ya it wasn't complicated ... I did try to warn you (implicitly) not to overthink ... glad ya got it !!!
Gershom
@jinmanbok
Mar 12 2016 07:08
Thanks :) I'll solve it and then take a break~~~ Have a good night and take care!
sigursiguros
@sigursiguros
Mar 12 2016 07:16
thanks @Rafase282 @guyjoseph @jjmax75 for your help with Algorithm: Symmetric Difference
CamperBot
@camperbot
Mar 12 2016 07:16
sigursiguros sends brownie points to @rafase282 and @guyjoseph and @jjmax75 :sparkles: :thumbsup: :sparkles:
:star: 319 | @jjmax75 | http://www.freecodecamp.com/jjmax75
:star: 339 | @guyjoseph | http://www.freecodecamp.com/guyjoseph
:star: 1058 | @rafase282 | http://www.freecodecamp.com/rafase282
Ariel
@abibliophile
Mar 12 2016 07:25
Hi everyone! I'm just starting the basic JavaScript challenges and I'm having trouble with the converting celsius to fahrenheit challenge
V Bhargav Chowdary
@bhargav4
Mar 12 2016 07:26
How to remove a particular element from an array?
On stackoverflow it said to use arr.splice(index,1) but that returns that element only..
Ariel
@abibliophile
Mar 12 2016 07:26
I'm sorry, I don't know what that means
rphares
@rphares
Mar 12 2016 07:27
@abibliophile , could you paste the code you are trying so far?
Ariel
@abibliophile
Mar 12 2016 07:28
I'm kind of at a loss on how to start, @rphares
José
@Ledjez
Mar 12 2016 07:28
@bhargav4 you have to use the pop() method/function
rphares
@rphares
Mar 12 2016 07:28
ahh, okeydoke--
José
@Ledjez
Mar 12 2016 07:29
@abibliophile copy past your code. i'll make it pretty :P
rphares
@rphares
Mar 12 2016 07:29
so, you want to put some code in var fahrenheit = right? thats what they give you? @abibliophile
and, in the instructions, they give you a formula... what was the formula they give you?
José
@Ledjez
Mar 12 2016 07:29
rphares
@rphares
Mar 12 2016 07:30
( @Ledjez , it sounds like they don't have any code yet, i dont think...? )
Ariel
@abibliophile
Mar 12 2016 07:30
yes . they said that fahrenheit was fahrenheit multiplied by 9, divided by 5, plus 32
V Bhargav Chowdary
@bhargav4
Mar 12 2016 07:30
@Ledjez Pop works only for last element doesn't it
I want to remove any element in the array
bitgrower
@bitgrower
Mar 12 2016 07:31
@bhargav4 -- splice is a very flexible function ... and you can use it to delete elements (which it then returns), as well as insert elements ... you may want to review the MDN page on splice -- it's an extremely powerful method...
Ariel
@abibliophile
Mar 12 2016 07:31
ooh just a sec @rphares
rphares
@rphares
Mar 12 2016 07:31
okay, so we know that will go on the right hand side of the equals, like the other variables @abibliophile
var fahrenheit = OUR FORMULA
cool cool, will do :)
Ariel
@abibliophile
Mar 12 2016 07:32
I figured it out! thanks so much :)
rphares
@rphares
Mar 12 2016 07:32
Oooh, congrats!
happy coding~
rphares @rphares goes to bed... night, all!
bitgrower
@bitgrower
Mar 12 2016 07:32
woot !!!! sounds like you've got a great fuure in coding .... .!!!
Ariel
@abibliophile
Mar 12 2016 07:32
I was having trouble with the idea of doing multiple operations in a row since they never did that
José
@Ledjez
Mar 12 2016 07:32
(Y)
Ariel
@abibliophile
Mar 12 2016 07:32
night @rphares and thanks!
CamperBot
@camperbot
Mar 12 2016 07:32
abibliophile sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Mar 12 2016 07:32
night @rphares and thank you !
CamperBot
@camperbot
Mar 12 2016 07:32
:star: 3231 | @rphares | http://www.freecodecamp.com/rphares
sigursiguros
@sigursiguros
Mar 12 2016 07:32
Hi guys the solution in wiki for symmetric difference doesn't work and I couldn't understand why
function sym(){
var args = Array.prototype.slice.call(arguments);
var getDiff = function(arr1,arr2){
function filterFunction(arr1,arr2){
return arr1.filter(function(item){
return arr2.indexOf(item) === -1;
});
}
return filterFunction(arr1,arr2)
.concat(filterFunction(arr2,arr1));
};
return args.reduce(getDiff,[]);
}

sym([1, 1, 2, 5], [2, 2, 3, 5], [3, 4, 5, 5]);
bitgrower
@bitgrower
Mar 12 2016 07:33
sorry, @sigursiguros -- a bit out of my competence atm ...
sigursiguros
@sigursiguros
Mar 12 2016 07:36
it's ok @bitgrower , thanks anyways
CamperBot
@camperbot
Mar 12 2016 07:36
sigursiguros sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 826 | @bitgrower | http://www.freecodecamp.com/bitgrower
sigursiguros
@sigursiguros
Mar 12 2016 07:41
@bitgrower I think it might be due to duplicate values in original array inputted to the function sym
do you know how I can reduce duplicate values in an array?
with javascript?
bitgrower
@bitgrower
Mar 12 2016 07:43
you might be able to use reduce ...
or filter
sigursiguros
@sigursiguros
Mar 12 2016 07:44
how?
rooms
CamperBot
@camperbot
Mar 12 2016 07:44

## rooms

See all the FreeCodeCamp rooms at gitter.im/FreeCodeCamp/rooms
Or check this wiki article for a shortlist
bitgrower
@bitgrower
Mar 12 2016 07:45
if you're at the point where you are doing symmetric difference, you should be able to play around and figure it out -- use the MDN documentation if you need to ... :)
sigursiguros
@sigursiguros
Mar 12 2016 07:46
DO you think that will solve my problem in the code above?
that's the only problem I can think of
José
@Ledjez
Mar 12 2016 07:48
@jinmanbok i just finished this one. you need to give a value to gear when you create it. makes it a lot easier to figure out after that imo
bitgrower
@bitgrower
Mar 12 2016 07:50
@sigursiguros -- not really ...
...but maybe -- on second thought ... hmmm ... hadn't considered that angle on sym diff
sigursiguros
@sigursiguros
Mar 12 2016 07:51
I'm actually not that advanced, that is why I was referring to wiki and trying to understand the solution @bitgrower
bitgrower
@bitgrower
Mar 12 2016 07:52
thanks @Ledjez ..
CamperBot
@camperbot
Mar 12 2016 07:52
bitgrower sends brownie points to @ledjez :sparkles: :thumbsup: :sparkles:
:star: 238 | @ledjez | http://www.freecodecamp.com/ledjez
bitgrower
@bitgrower
Mar 12 2016 07:52
@sigursiguros -- it's a gnarly problem -- there's a rather reduced version of that challenge in an earlier js challenge...
sigursiguros
@sigursiguros
Mar 12 2016 07:52
like my filter function is not working @bitgrower
  return result.filter(function(a,b){
return (a !== b);
});
bitgrower
@bitgrower
Mar 12 2016 07:53
ah ... sorry -- it's kinda late here ... so my brain cells are kind on empty ... can't be of much help atm, I'm afraid ...
Dave Melia
@Dave-Melia
Mar 12 2016 07:58
Morning guys
sigursiguros
@sigursiguros
Mar 12 2016 08:00
Morning @Dave-Melia any ideas why my above filter function doesn't work?
Dave Melia
@Dave-Melia
Mar 12 2016 08:01
is result an array?
Dave Melia
@Dave-Melia
Mar 12 2016 08:07
@sigursiguros
Aleksander Gębicki
@Takumar
Mar 12 2016 08:10
@sigursiguros in your function a is a value from result array, and b is index of that element in your array.
I don't think you want to check if a !== b - if element is different from its index. Does it have sense to you?

@sigursiguros check documentation for filter: filter() method at MDN

callback is invoked with three arguments:

• the value of the element
• the index of the element
• the Array object being traversed
Fatah N
@fatahn
Mar 12 2016 08:16
hey guys, How come these results are totally different? whats with the .push() function.
var me = function(){
var sports = ['soccer', 'baseball'];
var total = sports.push('football', 'swimming');
return sports;
};
me(); /*returns ['soccer', 'baseball','football', 'swimming']*/
var me = function(){
var sports = ['soccer', 'baseball'];
var total = sports.push('football', 'swimming');
};
me(); //returns 4
Aleksander Gębicki
@Takumar
Mar 12 2016 08:17
@nfatah push() method doesn't return new array, but number of elements of the array after you add elements to it!
That is why it returns 4 after you return total variable.
Fatah N
@fatahn
Mar 12 2016 08:19
@Takumar aha! thanks
CamperBot
@camperbot
Mar 12 2016 08:19
nfatah sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 2673 | @takumar | http://www.freecodecamp.com/takumar
Aleksander Gębicki
@Takumar
Mar 12 2016 08:20
@nfatah you are welcome.
Richard Andrews
@Whiplash5057
Mar 12 2016 08:47
function myReplace(str, before, after) {
var arrInd = [];
arrInd = str.split(" ");
var index = arrInd.indexOf(before);

if(arrInd[index][0] == arrInd[index][0].toUpperCase){

arrInd[index] = after.charAt(0).toUpperCase + after.split(1);
}
else{
arrInd[index] = after;
}

var finalStr = arrInd.join(' ');
return finalStr;

}

myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
guys why is this not working ??
Sujith
@sujithnath
Mar 12 2016 08:49
@Whiplash5057 let me check
Dave Melia
@Dave-Melia
Mar 12 2016 08:50
function findThem(arr, sum) {
var result = [];

for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < arr.length; j++){
if(arr[i] + arr[j] === sum){
result.push(arr[i]);
}
}
}
return result;
}

findThem([3, 5, 2, -4, 8, 11], 7)
How can I push my results into nested arrays? This outputs [5, 2, -4, 11] as expected. However I want it as [[5, 2], [-4, 11]]
Richard Andrews
@Whiplash5057
Mar 12 2016 08:50
i have to replace before with the after but if the before has a capital first letter then the after also has to have a capital first letter
@Dave-Melia I think if you initialize result as [[]]; you can do it
var result = [[]];
I'm not sure though
Sujith
@sujithnath
Mar 12 2016 08:51
@Whiplash5057 gramatically isn't wrong? :P
Dave Melia
@Dave-Melia
Mar 12 2016 08:52
@Whiplash5057 nah, that returns [ [], 5, 2, -4, 11 ]
Richard Andrews
@Whiplash5057
Mar 12 2016 08:52
then your push has to be result[i][j]; @Dave-Melia
@sujithnath I didn't get you
Sujith
@sujithnath
Mar 12 2016 08:53
@Dave-Melia i suggest to write a for loop, accept the length of array and push new array's into it
@Whiplash5057 i am figuring it out
:)
Dave Melia
@Dave-Melia
Mar 12 2016 08:54
@Whiplash5057 that didn't work
Richard Andrews
@Whiplash5057
Mar 12 2016 08:54
@sujithnath cool i'll try that
@Dave-Melia I'll try that in some time ...!!A lill busy with my doubt :smile:
Sujith
@sujithnath
Mar 12 2016 08:55
if(arrInd[index][0] == arrInd[index][0].toUpperCase){
arrInd[index] = after.charAt(0).toUpperCase + after.split(1);
}
Dave Melia
@Dave-Melia
Mar 12 2016 08:56
@sujithnath That's what I'm doing
Sujith
@sujithnath
Mar 12 2016 08:56
try to iterate the above code of urs
Dave Melia
@Dave-Melia
Mar 12 2016 08:56
@Whiplash5057 ok
Achilleas Papakonstantinou
@AchiPapakon
Mar 12 2016 09:02
Can someone explain me why in JS line 4 executes when the page loads?
This is the code: $('#nextQuote').on('click', loadQuote()); I'ts a click event, so I don't get it... Dave Melia @Dave-Melia Mar 12 2016 09:07 function findThem(arr, sum) { var result = []; for (var i = 0; i < arr.length; i++) { for (var j = i + 1; j < arr.length; j++) { if (arr[i] + arr[j] === sum) { result[i] = []; result[i].push(arr[i], arr[j]); } } } return result; } findThem([3, 5, 2, -4, 8, 11], 7) I got it working with this. Fatah N @fatahn Mar 12 2016 09:10 @Dave-Melia nice, I was following your code :) Dave Melia @Dave-Melia Mar 12 2016 09:10 @nfatah Ahh, I'm glad you found it interesting The problem was the second for-loop (j) need to be the same as i + 1, and I needed to create the 2-d array using result[i] = [], then simply push the contents into it Fatah N @fatahn Mar 12 2016 09:11 @Dave-Melia however the current code returns findThem([3, 5, 2, -4, 8, 11], 7) on my side Dave Melia @Dave-Melia Mar 12 2016 09:11 @nfatah How do you mean? Fatah N @fatahn Mar 12 2016 09:12 sorry coulnt copy paste @Dave-Melia check the pic Dave Melia @Dave-Melia Mar 12 2016 09:12 That's strange lol I did notice that running it through the visualizer it would put undefined in the array but the results never displayed that Fatah N @fatahn Mar 12 2016 09:14 @Dave-Melia cool. anyway why did you have to iterate thru' < arr.length instead of < arr.length -1 Dave Melia @Dave-Melia Mar 12 2016 09:15 jihad khorfan @spyshow Mar 12 2016 09:15 hi all i have a question i have this code var myArray = []; myArray = ['jihad khorfan','jkhorfan']; function cutName(str){ var arr = str.split(" "); return arr; } var myData = {} ; myData = {fullName : cutName(myArray[0]) , skype : myArray[1] , github : "spyshow"}; but it give me this Object {fullName: Array[2], skype: "jkhorfan", github: "spyshow"} instead of {fullName: ["jihad","khorfan"], skype: "jkhorfan", github: "spyshow"} Dave Melia @Dave-Melia Mar 12 2016 09:15 check that image @nfatah why would I need to use arr.length -1? Fatah N @fatahn Mar 12 2016 09:16 @Dave-Melia total length of the array? Dave Melia @Dave-Melia Mar 12 2016 09:17 minus 1?> @spyshow Your code gives me { fullName: [ 'jihad', 'khorfan' ], skype: 'jkhorfan', github: 'spyshow' } Fatah N @fatahn Mar 12 2016 09:18 @Dave-Melia yes like for (var i = 0; i < arr.length; i++) { would repeat past the array, right? jihad khorfan @spyshow Mar 12 2016 09:19 i tried it in console and that is what it gave me !! Dave Melia @Dave-Melia Mar 12 2016 09:19 @nfatah not that I'm aware, no. I always use arr.length and it's fine :S @spyshow use repl.it select JavaScript and put your code in there Fatah N @fatahn Mar 12 2016 09:21 @Dave-Melia oki :) Dave Melia @Dave-Melia Mar 12 2016 09:21 @nfatah Argh I can't figure out why it's pushing undefined into the array Fatah N @fatahn Mar 12 2016 09:23 @Dave-Melia wondering the same Dave Melia @Dave-Melia Mar 12 2016 09:24 @nfatah yeah, it's crazy it doesn't display undefined in http://repl.it it just displays as I want it to helpppp Fatah N @fatahn Mar 12 2016 09:25 Got a problem with this Chunky Monkey Exercise It cannot work when I used [] help me understand why >>it works as is. function chunk(arr, size) { // Break it up. var newArr = []; var beginSlice = 0; var endSlice = size; var repeatPush = arr.length/size + arr.length%size; //no. of times items will be pushed for(var i = 1; i<=repeatPush;i++){ newArr.push(arr.slice(beginSlice, endSlice)); beginSlice += size; endSlice += size; }//returns [[0, 1, 2, 3], [4, 5]] if we run chunk([0, 1, 2, 3, 4, 5], 4); if(newArr[newArr.length - 1] == ''){ // the last item is empty [], not 'empty' newArr.pop(); } return newArr; } chunk([0, 1, 2, 3, 4, 5], 4); Dave Melia @Dave-Melia Mar 12 2016 09:25 @Faredhattab paste the code in here, please @nfatah What SHOULD it return? @nfatah that is a LOT of of code for that solution Fatah N @fatahn Mar 12 2016 09:27 @Faredhattab Encode the following sequence, separated by spaces: backslash tab tab carriage-return new-line and assign it to myStr For example var my String = '\\' would give myString as \ add all the others now... \t ... Dave Melia @Dave-Melia Mar 12 2016 09:28 @Faredhattab Ahhh I see, I thought you did something and didn't understand why it works md sajid newaj @mdsajidnewaj Mar 12 2016 09:29 hlw.. Farid @Faredhattab Mar 12 2016 09:29 @nfatah thx CamperBot @camperbot Mar 12 2016 09:29 faredhattab sends brownie points to @nfatah :sparkles: :thumbsup: :sparkles: :star: 261 | @nfatah | http://www.freecodecamp.com/nfatah md sajid newaj @mdsajidnewaj Mar 12 2016 09:29 var myObj = { gift: "pony", pet: "kitten", bed: "sleigh" }; function checkObj(checkProp) { if (myObj.hasOwnProperty("checkProp")=== true); {return myObj[checkProp];} return "Not Found"; } // Test your code by modifying these values checkObj("house"); i can not find out what is wrong Dave Melia @Dave-Melia Mar 12 2016 09:30 @Faredhattab escape sequences are used when JavaScript would interpret a character in a different way. for example if you had a string "and he said "Hello, World!"", JavaScript would only see "And he said ", which would cause your code to fail li @lileonlin Mar 12 2016 09:30 hey guys, i get stuck on the last step of "Storing Values with the Equal Operator" "a should be assigned to b with =" Dave Melia @Dave-Melia Mar 12 2016 09:30 @Faredhattab So you would escape it like this "and he said \"Hello, World!\"", JavcScript will see this as "and he said "Hello, World" " Fatah N @fatahn Mar 12 2016 09:30 @Dave-Melia :) thats long!! It returns as expected but I cant figure why I should use '' when the last item I pop()'ed out was [] and not ''. Please check the comments on that line li @lileonlin Mar 12 2016 09:30 i wrote "a=b;" Dave Melia @Dave-Melia Mar 12 2016 09:32 @nfatah Sorry, I don't understand your code. Fatah N @fatahn Mar 12 2016 09:32 @lileonlin could you link to that exercise Dave Melia @Dave-Melia Mar 12 2016 09:32 @nfatah This is my solution to it, though: function chunk(arr, size) { var array = []; var total = arr.length; for ( i = 0 ; i < (total/size); i++){ answer = arr.splice(0,size); array[i] = answer; } return array; } md sajid newaj @mdsajidnewaj Mar 12 2016 09:34 var myObj = { gift: "pony", pet: "kitten", bed: "sleigh" }; function checkObj(checkProp) { // Your Code Here if (myObj.hasOwnProperty("checkProp")=== true); {return myObj[checkProp];} return "Not Found" ; } // Test your code by modifying these values checkObj("house"); Fatah N @fatahn Mar 12 2016 09:35 @Dave-Melia cool. thanks CamperBot @camperbot Mar 12 2016 09:35 nfatah sends brownie points to @dave-melia :sparkles: :thumbsup: :sparkles: :star: 291 | @dave-melia | http://www.freecodecamp.com/dave-melia Richard Andrews @Whiplash5057 Mar 12 2016 09:50 function myReplace(str, before, after) { var arrInd = []; arrInd = str.split(" "); var index = arrInd.indexOf(before); if(arrInd[index][0] === arrInd[index][0].toUpperCase()){ arrInd[index] = after.charAt(0).toUpperCase + after.split(1); } else{ arrInd[index] = after; } var finalStr = arrInd.join(' '); return finalStr; } myReplace("He is Sleeping on the couch", "Sleeping", "sitting"); hey guys ..why is this not working i'm getting He is function toUpperCase(){[native code] } sitting on the couch John Tzanidakis @johntzan Mar 12 2016 10:15 I think you're missing the () to toUpperCase() function in this part here : arrInd[index] = after.charAt(0).toUpperCase + after.split(1); Syed-Moin @Syed-Moin Mar 12 2016 10:22 hi i am unable to complete this // Initialize these three variables var a; var b; var c; var a = 5; var b = 10; var c = c + //I am a; // Do not change code below this line a = a + 1; b = b + 5; c = c + " String!"; can u pls help Coy Sanders @coymeetsworld Mar 12 2016 10:24 @Syed-Moin var c = c + //I am a; line is not right i think you want to have c = c + "I am a"; Syed-Moin @Syed-Moin Mar 12 2016 10:25 yes but it is showing error Coy Sanders @coymeetsworld Mar 12 2016 10:26 that code you showed above would generate an error yeah Syed-Moin @Syed-Moin Mar 12 2016 10:26 c should not contain undefined and should have a value of "I am a String!" Coy Sanders @coymeetsworld Mar 12 2016 10:26 did you make that change I mentioned? Syed-Moin @Syed-Moin Mar 12 2016 10:26 yes in results it is showing c = 'undefinedI am a String!' Coy Sanders @coymeetsworld Mar 12 2016 10:32 oh lol it should be var c = "I am a"; so what's happening is you declare var c at the top, but don't assign it anything, so its undefined you can't put it on the right of the equals sign without giving it a value, or else you'll get that error esllou @esllou Mar 12 2016 10:38 is it true that dot notation can't be used when the property name of an object is a number? so list.4 would need to be replaced with list[4] ? Artem @foolishhare Mar 12 2016 11:05 Did some know what i had to do with that? "function wordBlanks" Anybody done that task? I didnt understand what they want function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) { var result = ""; // Your code below this line // Your code above this line return result; } // Change the words here to test your function wordBlanks("dog", "big", "ran", "quickly"); cannelflow @cannelflow Mar 12 2016 11:07 @foolishhare MAKE A SENTENCE USING myNoun, myAdjective, myVerb, myAdverb when you call a function like wordBlanks("dog", "big", "ran", "quickly"); now your function function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) { var result = ""; has the value myNoun=dog, myAdjective=big, myVerb=ran, myAdverb=quickly so make a sentence using myNoun, myAdjective, myVerb, myAdverb return result; } @foolishhare Artem @foolishhare Mar 12 2016 11:10 @cannelflow thanks) I done it) CamperBot @camperbot Mar 12 2016 11:10 foolishhare sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles: :star: 895 | @cannelflow | http://www.freecodecamp.com/cannelflow Artem @foolishhare Mar 12 2016 11:11 @cannelflow cool streak) @cannelflow did you go in freelance? cannelflow @cannelflow Mar 12 2016 11:12 @foolishhare still learning Artem @foolishhare Mar 12 2016 11:13 @cannelflow front or back end? cannelflow @cannelflow Mar 12 2016 11:15 @foolishhare data viz now learning d3 Fatah N @fatahn Mar 12 2016 11:16 Hello, was this your solution for the Slasher flick JS Basic Algorithm challenge? I passed this ex, but would like to see ur code :) function slasher(arr, howMany) { // it doesn't always pay to be first arr.splice(0,howMany); return arr; } slasher([1, 2, 3], 2); Clem @ctataru Mar 12 2016 11:37 Hey guys. Is there an easier way to do this Seek and Destroy exercise? The point is to filter a given array from additional given arguments. function destroyer(arr) { for (var i = 1; i < arguments.length; i++) { for (var j = 0; j < arr.length; j++) { if (arr[j] === arguments[i]) { delete arr[j]; } } } return arr.filter(function(value) {return Boolean(value);}); } destroyer([1, 2, 3, 1, 2, 3], 2, 3); Kevin De Baerdemaeker @kefkef5 Mar 12 2016 12:15 @ctataru  function destroyer(arr) { // Remove all the values var initialArray = arguments[0]; var argumentArray = Array.prototype.slice.call(arguments, 1); //checking if it the argumentArray element is the same or not function isElement(value){ return value !== argumentArray[i]; } //runs the initialArray.filter(isElement); as many times as needed for (var i=0; i < argumentArray.length; i++){ initialArray = initialArray.filter(isElement); //don't make functions within a loop, predefine them } return initialArray; } destroyer([1, 2, 3, 1, 2, 3], 2, 3); Mine is even longer so, probably won't be much of us Soumitra Varindra Chakravarti @soumitrachakravarti Mar 12 2016 12:16 Hello, can anyone help me with the wikipedia challenge All 100 divs are loading but as undefined variables $(document).ready(function() {
$('#searchButton').on('click', function() {$('#randomSection').addClass('hide');
var searchInput = document.getElementById("searchInput").value;
$.ajax({ dataType: "jsonp", url: "https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=" + searchInput + "&callback=JSON_CALLBACK", success: function(res) { var results = res.query.pages; var render = "";$.each(results, function(val) {

render += '<div class="callout"><h3>' + val.title + '</h3><p>' + val.extract + '</p></div>';
\$('#resultsSection').html(render);
});
}
});
});
});
golfguy1984
@golfguy1984
Mar 12 2016 12:19
anyone have a minute to help me understand closures?
Jowze
@Jowze
Mar 12 2016 12:20
Hi guys, I'm slowly but steadily going through the basic algorythm section but my brain just exploded going through the falsy bouncer challenge
I don't understand how to start using the boolean object
anyone knows of tutorial different from MDN explaining how to use it?
V Bhargav Chowdary
@bhargav4
Mar 12 2016 12:23
@Jowze since you want to remove all false Nan undefined when these are returned you get false
So,use filter method
Jowze
@Jowze
Mar 12 2016 12:26
@bhargav4 , I'm stuck on how to use .filter()
golfguy1984
@golfguy1984
Mar 12 2016 12:26
Bueller…..Bueller….
Jowze
@Jowze
Mar 12 2016 12:27
I'll give it more twists and turns and let's see what comes out
V Bhargav Chowdary
@bhargav4
Mar 12 2016 12:28
@Jowze
arr.filter(function(x){
return(x)
});
if x is false that element will be removed from the array
Jowze
@Jowze
Mar 12 2016 12:30
@