These are chat archives for FreeCodeCamp/HelpJavaScript

12th
Mar 2016
Adolfo Rosario R.
@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
roshan khadka
@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
}

// Add/remove calls to test your function.
// 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
roshan khadka
@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
Adolfo Rosario R.
@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
Adolfo Rosario R.
@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;")
Adolfo Rosario R.
@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

:pencil: read more about code formatting on the FCC Wiki

Adolfo Rosario R.
@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

:pencil: read more about code formatting on the FCC Wiki

Segun Akindairo
@Segdaren
Mar 12 2016 00:21
function isLess(a, b) {
// Fix this code
return true < false;
}
please help
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
Adolfo Rosario R.
@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

Adolfo Rosario R.
@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
Adolfo Rosario R.
@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 ?
Adolfo Rosario R.
@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

:point_right: algorithm seek and destroy [wiki]

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.

:pencil: read more about algorithm seek and destroy on the FCC Wiki

Adolfo Rosario R.
@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
Adolfo Rosario R.
@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 :-)
Adolfo Rosario R.
@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
Adolfo Rosario R.
@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
@ramsaysewell What's your issue?
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
you answered your own question i think
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
roshan khadka
@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
}

// Add/remove calls to test your function.
// 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
Maddah Anass
@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);
Start with "Create a variable fahrenheit..."
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;
  var strAdd = str;
  if(num>0){
  while(i < num){
    str = str + strAdd;
    i++;
  }
  return str;
  }
  else{
    return '';
  }
}
repeat("*", 3);
Maddah Anass
@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

:point_right: algorithm binary agents [wiki]

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.

:pencil: read more about algorithm binary agents on the FCC Wiki

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
Start with that, Ted.
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
@BrianBorin add the ()
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
Must be a bad reference
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
Vadali Soumitri
@svadali2
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
@svadali2 Does it return immediately?
Ted, what is the formula for the conversion?
Vadali Soumitri
@svadali2
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

:point_right: checkpoint profile lookup [wiki]

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"

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about checkpoint profile lookup on the FCC Wiki

Darwin RC
@darwinrc
Mar 12 2016 04:13
@svadali2 : @SteveCarroll means that you are not executing your javascript code once the page in fully loaded. Your should enclose your code in what is called an IIFE on document.ready: http://tech.myemma.com/iifes-javascript-control-variable-scope/
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);
Vadali Soumitri
@svadali2
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
Vadali Soumitri
@svadali2
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() {
  // your code goes here
})();
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
Vadali Soumitri
@svadali2
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
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
Vadali Soumitri
@svadali2
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?
Vadali Soumitri
@svadali2
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
@svadali2 no problem
Steve Carroll
@SteveCarroll
Mar 12 2016 04:33
@svadali2 I still get the call stack error
Or did you just change it again?
Vadali Soumitri
@svadali2
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
@sidkrip What's your issue?
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
@sidkrip post your code.
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

:point_right: algorithm caesars cipher [wiki]

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'.
:pencil: read more about algorithm caesars cipher on the FCC Wiki
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

:point_right: algorithm seek and destroy [wiki]

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.

:pencil: read more about algorithm seek and destroy on the FCC Wiki

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();
    twitter.setAttribute('href','https://twitter.com/intent/tweet?hashtags=quotes -' + quoteBox.textContent)
  }

  writeQuote();

  button.addEventListener('click', function() {
    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 = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
 myObj.hasOwnProperty(checkProp);
 if (checkProp === undefined) {
   return "Not Found";
 }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
ShiviAnu
@ShiviAnu
Mar 12 2016 06:01
http://www.freecodecamp.com/challenges/record-collection#?solution=%2F%2F%20Setup%0Avar%20collection%20%3D%20%7B%0A%20%20%20%202548%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%22Let%20It%20Rock%22%2C%20%0A%20%20%20%20%20%20%20%20%22You%20Give%20Love%20a%20Bad%20Name%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%202468%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%221999%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%221999%22%2C%20%0A%20%20%20%20%20%20%20%20%22Little%20Red%20Corvette%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%201245%3A%20%7B%0A%20%20%20%20%20%20artist%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%205439%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%22ABBA%20Gold%22%0A%20%20%20%20%7D%0A%7D%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse(JSON.stringify(collection))%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20update(id%2C%20prop%2C%20value)%20%7B%0Aif(value%20!%3D%3D%20%22%22%20%26%26%20prop%20!%3D%3D%20%22tracks%22)%0A%20%20collection%5Bid%5D.prop%20%3D%20value%3B%0A%20%20else%20if(value%20!%3D%3D%20%22%22%20%26%26%20prop%20%3D%3D%20%22tracks%22)%0A%20%20%20%20collection%5Bid%5D.prop%20%3D%20value%3B%0A%20%20else%20if(value%20%3D%3D%3D%20%22%22)%0A%20%20%20%20delete%20collection%5Bid%5D.prop%3B%0A%20%20%20%20%0A%0A%20%20return%20collection%3B%0A%7D%0A%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0Aupdate(2548%2C%20%22artist%22%2C%20%22%22)%3B%0A%0A
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

:pencil: read more about code formatting on the FCC Wiki

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
sweet{\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?
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');
return total;
};
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
blob
sorry coulnt copy paste
@Dave-Melia check the pic
Dave Melia
@Dave-Melia
Mar 12 2016 09:12
Capture.PNG
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
Capture1.PNG
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 didn`t 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

CodePen: http://codepen.io/soumitrachakravarti/full/KzMBKR/

$(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
@
Abd-afeez Abd-hamid Adedamola
@Itsdenty
Mar 12 2016 12:31
please i need help, i am stuck at the card counting challenge.
Jowze
@Jowze
Mar 12 2016 12:31
@bhargav4 thanks, I'll keep working on it
CamperBot
@camperbot
Mar 12 2016 12:31
jowze sends brownie points to @bhargav4 :sparkles: :thumbsup: :sparkles:
:star: 314 | @bhargav4 | http://www.freecodecamp.com/bhargav4
Abd-afeez Abd-hamid Adedamola
@Itsdenty
Mar 12 2016 12:31
i keep getting wrong values
V Bhargav Chowdary
@bhargav4
Mar 12 2016 12:34
@Itsdenty paste your code here
Abd-afeez Abd-hamid Adedamola
@Itsdenty
Mar 12 2016 12:40

var count = 0;

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

if (count > 0) {
act = "Bet";
}
else if (count <= 0); {
act = "Hold";
}
return count + " " + act;
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Brendan Kinahan
@BKinahan
Mar 12 2016 12:41
@Itsdenty what is this card in high syntax you're using? Haven't seen that before.
Abd-afeez Abd-hamid Adedamola
@Itsdenty
Mar 12 2016 12:42
want to check if the arguement card is in the high list
Abd-afeez Abd-hamid Adedamola
@Itsdenty
Mar 12 2016 12:43
okay, checking out the link already thanks
alpox
@alpox
Mar 12 2016 12:48
@Itsdenty https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Operators/in the in operator tests only for indexes but not for values
Abd-afeez Abd-hamid Adedamola
@Itsdenty
Mar 12 2016 12:54
updated my code now
the index of syntax yielded four positive results out of six

var count = 0;

function cc(card) {
// Only change code below this line
var high = [2, 3, 4, 5, 6];
var mid = [7, 8, 9];
var low = [10, 'J', 'Q', 'K','A'];
var act = "";
if (high.indexOf(card) > -1) {
count += 1;
}
else if (mid.indexOf(card) > -1) {
count += 0;
}
else if (low.indexOf(card) > -1) {
count -= 1;
}

if (count > 0) {
act = "Bet";
}
else if (count <= 0); {
act = "Hold";
}
return count + " " + act;
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Ardian Reshani
@aRdiiaN04
Mar 12 2016 12:56
hello guys i stuck here to escaping literal quotes
var myStr; "I am a "Ardian" string inside "Coder";// Change this line
Clem
@ctataru
Mar 12 2016 12:57
Could anyone give me a little pointer here? My function outputs a bunch of chinese characters. I'm trying to decipher ROT13 text. Am I not iterating over the unicode string properly in my second for loop?
function rot13(str) { // LBH QVQ VG!
  var newStr = "";
  var realStr = "";
  for (var i = 0; i < str.length; i++) {
    newStr += str.charCodeAt(i) - 13;
  }
  for (var j = 0; j < newStr.length; j+=2) {
    realStr += String.fromCharCode(newStr.substr(j, j+2));
  }

  return realStr;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
alpox
@alpox
Mar 12 2016 12:59
@ctataru werent you supposed to go 13 up and not down? :D
@ctataru Btw I would not use a string to store charcodes
Clem
@ctataru
Mar 12 2016 13:01
@alpox was i? haha
alpox
@alpox
Mar 12 2016 13:01
@ctataru The charcodes do not always have the same amount of numbers:
96 82 95 95 45 93 79 94 95 45 93 91 103 80
Clem
@ctataru
Mar 12 2016 13:01
@alpox ahh alright. i'll rework that
Amir Lib
@babudabu
Mar 12 2016 13:02
Hello. I have a problem in the "Find the Longest Word in a String" challenge of Basic Algorithm Scripting.
I wrote this code and all the result are correct, but "Run test" dont find them correct.
function findLongestWord(str) {
  str = str.split(' ');
  var arrLen = str.length;
  var res = 0;
  for (var i = 0; i < arrLen; i++) {
    res = str[i].length;
    str[i] = str[i].replace(str[i], res);
  }
  str.sort(function(a, b) {
    return b-a;
  });
  return str.shift();
}

findLongestWord("May the force be with you");
Clem
@ctataru
Mar 12 2016 13:02
@alpox if "A" becomes "N" with ROT13, and we're deciphering it, shouldn't it be -13?
alpox
@alpox
Mar 12 2016 13:03
@ctataru A --> 65, N --> 78
65-13 = 52
RemyClarkson
@RemyClarksonApp
Mar 12 2016 13:04

Pls someone Help. what does this mean?

To test your learning you will create a solution "from scratch". Place your code between the indicated lines and it will be tested against multiple test cases.

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.

You are given a variable celsius representing a temperature in Celsius. Create a variable fahrenheit and apply the algorithm to assign it the corresponding temperature in Fahrenheit.

Clem
@ctataru
Mar 12 2016 13:05
@alpox yeah, but the text is already ciphered. so all "As" are "Ns". the point is to decipher it, and 78-65 = 13
V Bhargav Chowdary
@bhargav4
Mar 12 2016 13:05

Can someone explain how this code works?

str = str.replace(/([a-z])([A-Z])/g, "$1 $2");

this inserts space before a capital letter in a string

alpox
@alpox
Mar 12 2016 13:05
@ctataru What :D
Abhisek Pattnaik
@abhisekp
Mar 12 2016 13:06
@RemyClarksonApp which part didn't u understand?
Clem
@ctataru
Mar 12 2016 13:06
@alpox lol i didn't think i was confused about that part, but maybe i am
Abhisek Pattnaik
@abhisekp
Mar 12 2016 13:06
@bhargav4 do u understand regex?
alpox
@alpox
Mar 12 2016 13:06
@ctataru Write a function which takes a ROT13 encoded string as input and returns a decoded string.
Abd-afeez Abd-hamid Adedamola
@Itsdenty
Mar 12 2016 13:06
please how do you attach the java script window to the chat?
alpox
@alpox
Mar 12 2016 13:06
@ctataru You got it the wrong way round :D
Abhisek Pattnaik
@abhisekp
Mar 12 2016 13:06
@Itsdenty what do u mean?
V Bhargav Chowdary
@bhargav4
Mar 12 2016 13:07
@abhisekp A little
RemyClarkson
@RemyClarksonApp
Mar 12 2016 13:07
@abhisekp what am meant to do exactly?
alpox
@alpox
Mar 12 2016 13:07
@Itsdenty o.O attach the javascript window to the chat? huh
@Itsdenty Maybe you mean that:
help format
CamperBot
@camperbot
Mar 12 2016 13:07

: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

:pencil: read more about code formatting on the FCC Wiki

Abhisek Pattnaik
@abhisekp
Mar 12 2016 13:07
@bhargav4
[A-Z] = character class which includes all upper case letters
[a-z] = character class which includes all lower case letters
dkennell
@dkennell
Mar 12 2016 13:07
@RemyClarksonApp It wants you to write out the formula to convert Fahrenheit to Celsius. So, like, 'var celsius = _'
Abd-afeez Abd-hamid Adedamola
@Itsdenty
Mar 12 2016 13:08
i mean everybody else shares their code in the black editor but i was unable to do that
Abhisek Pattnaik
@abhisekp
Mar 12 2016 13:08
@Itsdenty :point_up: March 12, 2016 6:37 PM
V Bhargav Chowdary
@bhargav4
Mar 12 2016 13:09
@abhisekp Yes i know that part
What exactly $1 $2 does?
This code inserts space before a capital letter in a string. How does it do that?
Abhisek Pattnaik
@abhisekp
Mar 12 2016 13:09
@bhargav4
(...) = parenthesis "captures" the matched string
$1 = is the 1st match
$2 = refers to the 2nd match
alpox
@alpox
Mar 12 2016 13:10
@bhargav4 [a-z] --> a lowercase letter. [A-Z] an uppercase letter. () means remembering what is in the braces. so you want to match a lowercase letter which is followed by an uppercase letter and remember both letter seperately since you have () around each of them. In the replace string "$1 $2" the $1 refers to the first remembered catch, $2 to the second. So $1 is the lowercase letter, $2 the uppercase letter.
Abhisek Pattnaik
@abhisekp
Mar 12 2016 13:10
@bhargav4 so $1 $2 would insert a space between 1st and 2nd match
alpox
@alpox
Mar 12 2016 13:11
@Itsdenty Exactly. listen to camperbot:
help format
CamperBot
@camperbot
Mar 12 2016 13: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

:pencil: read more about code formatting on the FCC Wiki

Abd-afeez Abd-hamid Adedamola
@Itsdenty
Mar 12 2016 13:16
var count = 0;

function cc(card) {
  // Only change code below this line
var high = [2, 3, 4, 5, 6];
var mid = [7, 8, 9];
var low = [10, 'J', 'Q', 'K','A'];
var act = "";
  if (high.indexOf(card) > -1) {
    count += 1;
    }
  else if (mid.indexOf(card) > -1) {
    count += 0;
  }
  else if (low.indexOf(card) > -1) {
    count -= 1;
  }

  if (count > 0) {
    act = "Bet";
  }
  else if (count <= 0); {
    act = "Hold";
  }
  return count + " " + act;
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);
oh i got it
alpox
@alpox
Mar 12 2016 13:18
@Itsdenty
else if (mid.indexOf(card) > -1) { count += 0; } Is kinda useless since it does nothing
V Bhargav Chowdary
@bhargav4
Mar 12 2016 13:18
@alpox @abhisekp Thanks a lot
CamperBot
@camperbot
Mar 12 2016 13:18
bhargav4 sends brownie points to @alpox and @abhisekp :sparkles: :thumbsup: :sparkles:
:star: 2292 | @abhisekp | http://www.freecodecamp.com/abhisekp
:star: 378 | @alpox | http://www.freecodecamp.com/alpox
alpox
@alpox
Mar 12 2016 13:21
@Itsdenty else if (count <= 0); { you have a semicolon after the if close brace. That breaks your code at that point and doesnt fulfill the if. The code act = "Hold"; gets always executed.
Abd-afeez Abd-hamid Adedamola
@Itsdenty
Mar 12 2016 13:24
oh, just noticed that, thanks a bunch, fixing that instantly
challenge passed...thanks a million alpox and every other contributors
your a big life saver
Ardian Reshani
@aRdiiaN04
Mar 12 2016 13:29

// Setup
var lastNameLength = 9;
var lastName = "Lovelace";

// Only change code below this line.

lastNameLength = lastName.length;

can help me
alpox
@alpox
Mar 12 2016 13:31
@aRdiiaN04 Looks right to me... what is the question though?
Ardian Reshani
@aRdiiaN04
Mar 12 2016 13:31
"You should be getting the length of lastName by using .length like this: lastName.length."
i do it but this is not woriking
alpox
@alpox
Mar 12 2016 13:32
@aRdiiaN04 I see... you changed the setup, which you are not supposed to do...
// Only change code below this line.
@aRdiiaN04
// Example
var firstNameLength = 0;
var firstName = "Ada";

firstNameLength = firstName.length;

// Setup
var lastNameLength = 0;
var lastName = "Lovelace";

// Only change code below this line.

lastNameLength = lastName;
This was the actual setup before
Ardian Reshani
@aRdiiaN04
Mar 12 2016 13:32
ohh yes
i fixt it
i cheng to 9
thenks you
alpox
@alpox
Mar 12 2016 13:33
np
dkennell
@dkennell
Mar 12 2016 13:37
Hey, all. I'm trying to figure out how to check for the existence of certain keys or properties in an object. I'm stuck on the 'Profile Lookup' challenge and my code is a total mess right now.
This message was deleted
CamperBot
@camperbot
Mar 12 2016 13:37
:bulb: to format code use backticks! ``` more info
dkennell
@dkennell
Mar 12 2016 13:38
This message was deleted
CamperBot
@camperbot
Mar 12 2016 13:38
:bulb: to format code use backticks! ``` more info
dkennell
@dkennell
Mar 12 2016 13:39
Also, I can't figure out how to format code in the chat window. Lol
//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

i = 0;
while (i <= contacts.length) {
  if (contacts[i].firstName == firstName) {
    if (contacts[i][prop] === "") {
      return "No such property";
    }
    else {return contacts[i][prop];}
  }
i++;
}
return "No such contact";
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
mudi thareja
@tharejamudit
Mar 12 2016 13:42
stuck at this challenge
pls help
Return Early Pattern for Functions
?
roshan khadka
@roshankd
Mar 12 2016 13:47
how to use bracket notation

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

// Only change code below this line;
var number=2;
var playerNumber=testObj[number]; // Change this Line
var player = testObj["16"]; // Change this Line

dkennell
@dkennell
Mar 12 2016 13:47
@tharejamudit So here's the point of this one: If you return a value from a function, the function stops. So you just have to enter two return statements into this function.
Ardian Reshani
@aRdiiaN04
Mar 12 2016 13:47
// Setup
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "H"; // Fix Me
i stuck i dont know what to do
dkennell
@dkennell
Mar 12 2016 13:48
@tharejamudit So, if a <= 0, return undefined or if b <= 0, return undefined.
@tharejamudit Also, remember that the 'or' operator is || .
Jowze
@Jowze
Mar 12 2016 13:51
Hey guys, stuck on the seek and destroy challenge at the moment. Any idea why this doesn't work?
```js
Brendan Kinahan
@BKinahan
Mar 12 2016 13:52
@aRdiiaN04 Strings are immutable in javascript, meaning you can't change the value of them in part or in whole. You could do something like myStr = "H" + "ello World"; however (but note that is not what is required of this challenge)
Jowze
@Jowze
Mar 12 2016 13:52
function destroyer(arr) {
var newArr = [];
  for (var i = 1 ; i < arr.length ; i++){
    for (var j = 0 ; j < arr.length[0] ; j++){
      if (arr[0][j] !== arr[i]) {
      newArr.push(arr[0][j]);
      }
    }
  }
  return newArr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Ardian Reshani
@aRdiiaN04
Mar 12 2016 13:53
@BKinahan Thnks
CamperBot
@camperbot
Mar 12 2016 13:53
ardiian04 sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1040 | @bkinahan | http://www.freecodecamp.com/bkinahan
cannelflow
@cannelflow
Mar 12 2016 13:53
@aRdiiaN04 if var abc = xyz and if you want to change it to ayz then only way to do is like assign its value again like var abc = ayz
Brendan Kinahan
@BKinahan
Mar 12 2016 13:54
@Jowze arr[0] is 1, arr[0][j] is undefined for any value of j since arr is not a two-dimensional array.
@Jowze read about the arguments object, there should be a link in the challenge instructions.
Jowze
@Jowze
Mar 12 2016 13:54
I read it, but I have to admin I'm always very confused by MDN
the examples always include elements I don't understand yet.
Brendan Kinahan
@BKinahan
Mar 12 2016 13:56
@Jowze when you call a function with any number of arguments, that function (and the code within it) has access to its own arguments object, which is like an array that contains all of the arguments passed in for this particular call to it. So the arguments object for your example would be [[1,2,3,1,2,3],2,3]
David Weedmark
@DavidWeedmark
Mar 12 2016 13:56
@Jowze if you'd like to see why it doesn't work, try returning arr.length[0]
Jowze
@Jowze
Mar 12 2016 13:58
@DavidWeedmark it doesn't return anything :)
@BKinahan ok I see
David Weedmark
@DavidWeedmark
Mar 12 2016 13:58
yeah sorry, didn't see BKinahan was helping you already. you're in good hands
Brendan Kinahan
@BKinahan
Mar 12 2016 14:00
@Jowze try using return arguments; to see the object for yourself. It's what is called array-like, meaning you can't do things like arguments.push() or arguments.pop(), but you can still access its elements as you would with an array. arguments[0] == [1,2,3,1,2,3]
Jowze
@Jowze
Mar 12 2016 14:00
@BKinahan I see, so I can use arguments in a for loop
Brendan Kinahan
@BKinahan
Mar 12 2016 14:00
@Jowze exactly!
Jowze
@Jowze
Mar 12 2016 14:01
the way I was trying to access it with arr[0]
alright, that gives me quite a lot to chew on already :)
not sure how to implement .filter() the way they advise to, but that'll come next
dkennell
@dkennell
Mar 12 2016 14:01
Hey all, I'm stuck on the 'Profile Lookup' challenge. I can't figure out how to check for the existence of a property in the object. Could someone give me a hand?
Brendan Kinahan
@BKinahan
Mar 12 2016 14:02
@Jowze the function is declared as destroyer(arr), with only one parameter, which we say means it expects one argument when it is called. In other words the function doesn't know how many additional numbers to expect after the first argument, but it does expect that there will at least be one argument, the array.
@Jowze it would be possible to declare it as destroyer() without any given parameters, and you could then just refer to the array as arguments[0], but calling it arr makes the code a bit easier to read and understand.
@dkennell something like: myObj.hasOwnProperty(prop)
Jowze
@Jowze
Mar 12 2016 14:04
@BKinahan it still works to use arr.length in a for loop though?
Brendan Kinahan
@BKinahan
Mar 12 2016 14:05
@Jowze right, if you want to loop through each element of arr. But it isn't necessary to do that if you use a filter, since .filter() checks each element of the array it's called on without needing any loops.
Kipranija
@Kipranija
Mar 12 2016 14:05
Hey , at Check for Palindromes why does palindrome("0_0 (: /-\ :) 0-0") has to return true?
that smile
Brendan Kinahan
@BKinahan
Mar 12 2016 14:06
@Kipranija put `backticks` around code to prevent formatting :) (backticks)
David Weedmark
@DavidWeedmark
Mar 12 2016 14:07
I love a happy palindrome
Brendan Kinahan
@BKinahan
Mar 12 2016 14:07
@Kipranija Because with only alphanumeric characters, the input turns into "0000" which is a palindrome.
Jowze
@Jowze
Mar 12 2016 14:07
@BKinahan thanks man
CamperBot
@camperbot
Mar 12 2016 14:07
jowze sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1041 | @bkinahan | http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Mar 12 2016 14:08
@Jowze no problem :)
Kipranija
@Kipranija
Mar 12 2016 14:08
@BKinahan thanks
CamperBot
@camperbot
Mar 12 2016 14:08
kipranija sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1042 | @bkinahan | http://www.freecodecamp.com/bkinahan
Federico Dente
@fez994
Mar 12 2016 14:08
Hi guys, i'm working on my portfolio, can someone tell me how to create the "split" effect that you can see here? (http://blackrockdigital.github.io/startbootstrap-grayscale/)
I've setted the full page image, created the navbar but i can't figure out how to "split" the page in differente parts, i've tried using divs but it didn't work
Abhisek Pattnaik
@abhisekp
Mar 12 2016 14:09
@BKinahan :chicken:
Brendan Kinahan
@BKinahan
Mar 12 2016 14:09
@abhisekp quack
Abhisek Pattnaik
@abhisekp
Mar 12 2016 14:10
:D
Brendan Kinahan
@BKinahan
Mar 12 2016 14:10
@abhisekp hey, any idea on my HelpContributors problem?
that room seems a bit dead right now
hm.. or maybe my message didn't go through? it says no one has read it .-.
dkennell
@dkennell
Mar 12 2016 14:11
@BKinahan Okay, that helps. Thanks a bunch!
CamperBot
@camperbot
Mar 12 2016 14:11
dkennell sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1044 | @bkinahan | http://www.freecodecamp.com/bkinahan
scharla
@scharla
Mar 12 2016 14:15
@fez994 by split effect you mean one image above another as background?
Abhisek Pattnaik
@abhisekp
Mar 12 2016 14:16
@BKinahan prolly a typo.
Brendan Kinahan
@BKinahan
Mar 12 2016 14:17
@abhisekp link to the wrong challenge, you mean? I can't find the information about the right settings to use anywhere else /:
roshan khadka
@roshankd
Mar 12 2016 14:18
playerNumber should be a number
The variable player should be a string
The value of player should be "Montana"
You should use bracket notation to ac