These are chat archives for FreeCodeCamp/HelpJavaScript

31st
Mar 2016
Moshe Stauber
@notACodeMonkey1
Mar 31 2016 00:04
Hi all, I figure out how to do the last intermediate Javascript algorithm challenge, Arguments Optional. can anybody point me in the right direction. Thanks!
Matt Green
@mattxgreen
Mar 31 2016 00:05
@notACodeMonkey1 arguments object is key
Moshe Stauber
@notACodeMonkey1
Mar 31 2016 00:06
@mattxgreen I think know how to use the arguments object and can check it's length. I dont understand how to return a function which could be added to. the closure part
Matt Green
@mattxgreen
Mar 31 2016 00:07
@notACodeMonkey1 ok, let me review the excercise
Moshe Stauber
@notACodeMonkey1
Mar 31 2016 00:07
@mattxgreen I read the link for closures provided by FCC but it's not clicking in my head.
Gabriel Brunette-Savard
@gabrielsavard
Mar 31 2016 00:07
can someone please let me know why my css is not affecting my button http://codepen.io/gabrielbrunette/pen/pyrxYG
Moshe Stauber
@notACodeMonkey1
Mar 31 2016 00:08
@mattxgreen Thanks!
CamperBot
@camperbot
Mar 31 2016 00:08
notacodemonkey1 sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:star: 422 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
Matthew Fricker
@mattfricker
Mar 31 2016 00:10

@gabrielsavard The semicolon after you close body needs to be removed

Remove the semicolons after the closing bracked ( } ) after body and .button

anthonygallina1
@anthonygallina1
Mar 31 2016 00:11
@gabrielsavard sure but the only class on button is button?
@gabrielsavard I see it now
Matt Green
@mattxgreen
Mar 31 2016 00:13
@notACodeMonkey1 So it's just asking you to return a function if only 1 arg is provided
write up some code for that case, and I'll take a look at it if you can't get it working
lizzieshipton
@lizzieshipton
Mar 31 2016 00:14
help Seek and Destroy
CamperBot
@camperbot
Mar 31 2016 00:14

: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

Gabriel Brunette-Savard
@gabrielsavard
Mar 31 2016 00:14
@mattfricker Thanks! I had been wondering for a long time
CamperBot
@camperbot
Mar 31 2016 00:14
gabrielsavard sends brownie points to @mattfricker :sparkles: :thumbsup: :sparkles:
:star: 66 | @mattfricker | http://www.freecodecamp.com/mattfricker
lizzieshipton
@lizzieshipton
Mar 31 2016 00:15
This message was deleted
CamperBot
@camperbot
Mar 31 2016 00:15

: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

Moshe Stauber
@notACodeMonkey1
Mar 31 2016 00:18

@mattxgreen This is what I have so far:

function add(a) {
//console.log("entering Func");

function addFirst(b){
var first = a;
return first + b;
}
var args = Array.prototype.slice.call(arguments);
if(args.length == 1){
if(typeof args[0] == 'number'){
return addFirst();
}
}else{
if(typeof args[0] == 'number' && typeof arg[1] == 'number'){
return args[0] + args[1];
}
}
return undefined;

}

add(2);

Justin
@daemedeor
Mar 31 2016 00:23
function add(a) {
    //console.log("entering Func");
    function addFirst(b){
        var first = a;
        return first + b;
    }
    var args = Array.prototype.slice.call(arguments);
    if(args.length == 1){
       if(typeof args[0] == 'number'){
           return addFirst();
      }
   }else{
       if(typeof args[0] == 'number' && typeof arg[1] == 'number'){
           return args[0] + args[1];
        }
    }
    return undefined;
}
add(2);
Moshe Stauber
@notACodeMonkey1
Mar 31 2016 00:24
@daemedeor Thanks!!
CamperBot
@camperbot
Mar 31 2016 00:24
notacodemonkey1 sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 137 | @daemedeor | http://www.freecodecamp.com/daemedeor
Justin
@daemedeor
Mar 31 2016 00:25
@notACodeMonkey1 what are you trying to do?
this seems very messy
Moshe Stauber
@notACodeMonkey1
Mar 31 2016 00:25
It is messy
Kevin Mulligan
@kmulligan
Mar 31 2016 00:26
Can someone help me with Where Art Thou?
Moshe Stauber
@notACodeMonkey1
Mar 31 2016 00:26
first i declare a function that i can return. Then im checking the length of the arguments "array" and returning based on length
Justin
@daemedeor
Mar 31 2016 00:27
@notACodeMonkey1 you’re also calling addFirst without any arguments?
Nazih Ibrahim
@nazihhizan
Mar 31 2016 00:27
Hello All :D
facing a problem in seek and destroy js challenge
my solution returns the expected answer for all test cases but it doesn't submit
maybe I am doing sth wrong
function destroyer(arr) {
  // Remove all the values
  var otherArgs = arguments.length - 1;

  for(var i = 1; i <= otherArgs; i++){
    arr = arr.filter(myFilter, arguments[i]);
  }
  return arr;
}

function myFilter(value) {
  return (this !== value);
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);              // [1, 1]
//destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3);           // [1, 5, 1]
//destroyer([3, 5, 1, 2, 2], 2, 3, 5);              // [1]
//destroyer([2, 3, 2, 3], 2, 3);                    // []
//destroyer(["tree", "hamburger", 53], "tree", 53); // ["hamburger"]
Kevin Mulligan
@kmulligan
Mar 31 2016 00:27
function where(collection, source) {
  var arr = [];
  var i=0;
  var length = collection.length;

  for (i;i<length;i++) {
  if (collection[i].hasOwnProperty("last") === true) {
    if (collection[i].last == "Capulet") {  if (collection[i].hasOwnProperty(Object.keys(source))) {

        return collection[i];
        }
  }
  }

  return Object.getOwnPropertyNames(collection[0]);

}

where([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Moisés Man
@moigithub
Mar 31 2016 00:30
@kmulligan if u dont use "" quotes... javascript will take it as variable... not as string
Kevin Mulligan
@kmulligan
Mar 31 2016 00:32
@moigithub so "collection[i]" ?
hasOwnProperty requires the property name...
syntax obj.hasOwnProperty(prop)
collection is an Array.. using indices like [i] u access to one of its elements.. which is an Object
Kevin Mulligan
@kmulligan
Mar 31 2016 00:33
@moigithub right, and when I do return Object.getOwnPropertyNames(collection[0]); I get ["first", "last"]`
getOwnPropertyNames is ANOTHER object method (totally different than hasOwnProperty)
according to its syntax Object.getOwnPropertyNames(obj)
it requires an OBJECT as input
again.. collection is an array.. and u accessing the element [0] to get the first object
Nazih Ibrahim
@nazihhizan
Mar 31 2016 00:36
This message was deleted
This message was deleted
Moisés Man
@moigithub
Mar 31 2016 00:37
```js
paste code on next line (shift enter if needed to add new lines)
```
Kevin Mulligan
@kmulligan
Mar 31 2016 00:39
@moigithub I guess I don't understand then. obj.hasOwnProperty(prop) if I put last into prop it doesn't work
And now I have to go rock a baby, I'm out
Nazih Ibrahim
@nazihhizan
Mar 31 2016 00:40
function destroyer(arr) {
  // Remove all the values
  var otherArgs = arguments.length - 1;

  for(var i = 1; i <= otherArgs; i++){
    arr = arr.filter(myFilter, arguments[i]);
  }
  return arr;
}

function myFilter(value) {
  return (this !== value);
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);              // [1, 1]
//destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3);           // [1, 5, 1]
//destroyer([3, 5, 1, 2, 2], 2, 3, 5);              // [1]
//destroyer([2, 3, 2, 3], 2, 3);                    // []
//destroyer(["tree", "hamburger", 53], "tree", 53); // ["hamburger"]
This code outputs the expected answer but it doesn't submit
Moisés Man
@moigithub
Mar 31 2016 00:42
@kmulligan if (collection[i].hasOwnProperty(Object.keys(source))) { this iswrong.. cuz hasOwnProperty requires a property name..BUT
Object.keys(source) returns an Array of properties
Justin
@daemedeor
Mar 31 2016 00:42
@nazihhizan sometimes refreshing the page
helps
Moisés Man
@moigithub
Mar 31 2016 00:43
@nazihhizan nvm.. u using "this" argument... re reading :)
Collyn1221
@Collyn1221
Mar 31 2016 00:44
I need help with this Selecting from many options with Switch Statements challenge. I'm not really sure what to do.
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case "alpha":
      break;
    case "beta":
      break;
    case "gamma":
      break;
    case "delta":
      break;

  }


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

// Change this value to test
myTest(1);
Diego Mayer
@Chrono79
Mar 31 2016 00:46
@Collyn1221 you need to asign the right value to answer and each case too
Nazih Ibrahim
@nazihhizan
Mar 31 2016 00:46
@moigithub that's the point
i am using this
Collyn1221
@Collyn1221
Mar 31 2016 00:47
@Chrono79 Thanks. I understand now.
Nazih Ibrahim
@nazihhizan
Mar 31 2016 00:47
This solution works perfectly but it doesn;t submit
CamperBot
@camperbot
Mar 31 2016 00:47
collyn1221 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 308 | @chrono79 | http://www.freecodecamp.com/chrono79
devonwilson1
@devonwilson1
Mar 31 2016 00:48
someone one want to help me finish this assignment "counting cards"?

var count = 0;

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

}

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');

Kevin Anderson
@LemonStain
Mar 31 2016 00:48
How do I input my code for review?
Nazih Ibrahim
@nazihhizan
Mar 31 2016 00:48
@devonwilson1
put your code inside
your code
Diego Mayer
@Chrono79
Mar 31 2016 00:48
@devonwilson1 why so many cases?
Nazih Ibrahim
@nazihhizan
Mar 31 2016 00:49
```js
devonwilson1
@devonwilson1
Mar 31 2016 00:49
i thought i need each of the possible outcomes written out not so?
someone just please help point me in correct direction
Moisés Man
@moigithub
Mar 31 2016 00:50
@devonwilson1 u have a count variable above
u need to increment OR decrement on the cases accordingly
devonwilson1
@devonwilson1
Mar 31 2016 00:50
yeah i do NOT understand what that means at all PLEASE help me understand
Justin
@daemedeor
Mar 31 2016 00:52
@nazihhizan well if everything is fine then try refreshing, sometimes the page breaks so it helps to refresh
Nazih Ibrahim
@nazihhizan
Mar 31 2016 00:52
@daemedeor
I did many times but it doesn't help
Justin
@daemedeor
Mar 31 2016 00:53
@nazihhizan could you link to the repo?
Kevin Anderson
@LemonStain
Mar 31 2016 00:53
I am working on JavaScript "Stand In Line" and for some reason 1 of the 4 objectives is not completing. Can someone assist with helping me?
PHPman
@dmitrikonnikov
Mar 31 2016 00:54
can someone help me with escape sequences in strings basic js
Kevin Anderson
@LemonStain
Mar 31 2016 00:55
@dmitrikonnikov I can try.
devonwilson1
@devonwilson1
Mar 31 2016 00:55
can anyone help me understand how to write out making the var count increment or decrement PLEASE PLEASE PLEASE
;KLADFLKJSDAFJLKADSF
Kevin Anderson
@LemonStain
Mar 31 2016 00:55
@devonwilson1 what lesson are you working on?
Matthew Fricker
@mattfricker
Mar 31 2016 00:55
@LemonStain Sure, what test is failing?
PHPman
@dmitrikonnikov
Mar 31 2016 00:55
@lemon stain
Kevin Anderson
@LemonStain
Mar 31 2016 00:55
@mattfricker queue([5,6,7,8,9], 1) should return 5
PHPman
@dmitrikonnikov
Mar 31 2016 00:56
i am trying to encode backslash tab tab carriage-return new line
Matthew Fricker
@mattfricker
Mar 31 2016 00:56
ok and can you paste your code?
Diego Mayer
@Chrono79
Mar 31 2016 00:56
@devonwilson1 check your private chat
PHPman
@dmitrikonnikov
Mar 31 2016 00:56
var myStr = \ \t \t \r \n;
Kevin Anderson
@LemonStain
Mar 31 2016 00:56

@mattfricker function queue(arr, item) {
// Your code here

return testArr.push(item),
testArr.shift(testArr[4]);

     // Change this line

}

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

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

@dmitrikonnikov try to use \ so you are encoding the backslask
PHPman
@dmitrikonnikov
Mar 31 2016 00:57
what do you mean?
Matthew Fricker
@mattfricker
Mar 31 2016 00:57
@LemonStain Once you return from a function, all of the lines after that return will not be executed
Kevin Anderson
@LemonStain
Mar 31 2016 00:57
@dmitrikonnikov the back slash starts the escape and the second backslash creates the backslash
PHPman
@dmitrikonnikov
Mar 31 2016 00:58
so only one backslash
Kevin Anderson
@LemonStain
Mar 31 2016 00:59
@dmitrikonnikov \ will create a backslash via escape \t is a tab
oh
you need to do a double backslash (only showing one when i type two here)
Karl Sanford
@karlsanford
Mar 31 2016 00:59

I came up with a working solution to remove all falsy values from an array using Array.filter, but its a clunky solution. Exercise = Falsy Bouncer

function myFilter(val){
return val != false && val !== null && !isNaN(val) || typeof val === "string" && val != false;
}

thoughts?

PHPman
@dmitrikonnikov
Mar 31 2016 01:00
the double backslash isnt working
Diego Mayer
@Chrono79
Mar 31 2016 01:01
@karlsanford yes
Kevin Anderson
@LemonStain
Mar 31 2016 01:01
@dmitrikonnikov do you have the name of the lesson on the Map?
Vik
@vvang044
Mar 31 2016 01:01
help chunky munkey
CamperBot
@camperbot
Mar 31 2016 01:01
no wiki entry for: chunky munkey
Diego Mayer
@Chrono79
Mar 31 2016 01:01
try returning the true ones
hi vvang
Vik
@vvang044
Mar 31 2016 01:01
hey whats up
PHPman
@dmitrikonnikov
Mar 31 2016 01:01
nothin much
Matthew Fricker
@mattfricker
Mar 31 2016 01:02
@LemonStain Were you able to figure out how to reorganize the return statement to get it to work?
Diego Mayer
@Chrono79
Mar 31 2016 01:02
@karlsanford like this:
if (value) return value;
Vik
@vvang044
Mar 31 2016 01:02
how is your coding come along
Kevin Anderson
@LemonStain
Mar 31 2016 01:02
@dmitrikonnikov you are trying to create a string that contains those espaces right? what must all strings be within?
Karl Sanford
@karlsanford
Mar 31 2016 01:02
@Chrono79 so is string: true, is number: true, instead of excluding false
PHPman
@dmitrikonnikov
Mar 31 2016 01:03
oh ""
Vik
@vvang044
Mar 31 2016 01:03
help chunkey monkey
CamperBot
@camperbot
Mar 31 2016 01:03
no wiki entry for: chunkey monkey
Kevin Anderson
@LemonStain
Mar 31 2016 01:03
@dmitrikonnikov :) let me know if that works
Karl Sanford
@karlsanford
Mar 31 2016 01:03
@Chrono79 will try
ZctrapCoding
@ZctrapCoding
Mar 31 2016 01:03

Hey im on this one
Escape Sequences in Strings
Quotes are not the only characters that can be escaped inside a string. Here is a table of common escape sequences:

Code Output
\' single quote
\" double quote
\ backslash
\n new line
\r carriage return
\t tab
\b backspace
\f form feed
Note that the backslash itself must be escaped in order to display as a backslash.

Instructions
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr

Run tests (ctrl + enter)
and my code is var myStr = "\\ \t \r \n";

Vik
@vvang044
Mar 31 2016 01:03
geez....i cant spell today
PHPman
@dmitrikonnikov
Mar 31 2016 01:03
yeet it worked
Kevin Anderson
@LemonStain
Mar 31 2016 01:03
@ZctrapCoding it calls for 2 tabs correct?
PHPman
@dmitrikonnikov
Mar 31 2016 01:03
thanks @LemonStain
CamperBot
@camperbot
Mar 31 2016 01:03
dmitrikonnikov sends brownie points to @lemonstain :sparkles: :thumbsup: :sparkles:
Vik
@vvang044
Mar 31 2016 01:03
help chunky monkey
CamperBot
@camperbot
Mar 31 2016 01:03

:point_right: algorithm chunky monkey [wiki]

Explanation

Our goal for this Algorithm is to split arr (first argument) into smaller chunks of arrays with the length provided by size (second argument). There are 4 green checks (objectives) our code needs to pass in order to complete this Algorithm:

  1. (['a', 'b', 'c', 'd'], 2) is expected to be [['a', 'b'], ['c', 'd']]
  2. ([0, 1, 2, 3, 4, 5], 3) is expected to be [[0, 1, 2], [3, 4, 5]]
  3. ([0, 1, 2, 3, 4, 5], 2) is expected to be [[0, 1], [2, 3], [4, 5]]
  4. ([0, 1, 2, 3, 4, 5], 4) is expected to be [[0, 1, 2, 3], [4, 5]]

Click More information under the Algorithm title and read the helpful links if you haven't yet.

:pencil: read more about algorithm chunky monkey on the FCC Wiki

:star: 187 | @lemonstain | http://www.freecodecamp.com/lemonstain
ZctrapCoding
@ZctrapCoding
Mar 31 2016 01:04
@LemonStain oh i didnt notice that xD
Karl Sanford
@karlsanford
Mar 31 2016 01:04
@Chrono79 damn you're smart ;)
@Chrono79 how do i give you brownie points? just joined yesterday...
Kevin Anderson
@LemonStain
Mar 31 2016 01:05
just say tahnks and mention the person
thanks *
Karl Sanford
@karlsanford
Mar 31 2016 01:05
thanks @Chrono79 !
CamperBot
@camperbot
Mar 31 2016 01:05
karlsanford sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 309 | @chrono79 | http://www.freecodecamp.com/chrono79
Karl Sanford
@karlsanford
Mar 31 2016 01:06
thanks @LemonStain !
CamperBot
@camperbot
Mar 31 2016 01:06
karlsanford sends brownie points to @lemonstain :sparkles: :thumbsup: :sparkles:
:star: 188 | @lemonstain | http://www.freecodecamp.com/lemonstain
Kevin Anderson
@LemonStain
Mar 31 2016 01:06
:) anytime
Diego Mayer
@Chrono79
Mar 31 2016 01:08
@karlsanford no problem
Kevin Anderson
@LemonStain
Mar 31 2016 01:08
How do I add my code in black background here?
Vik
@vvang044
Mar 31 2016 01:09
copy your code and paste it inbetween..... 3 ````
Kevin Anderson
@LemonStain
Mar 31 2016 01:09
''' like '''
CamperBot
@camperbot
Mar 31 2016 01:09
:bulb: to format code use backticks! ``` more info
Kevin Anderson
@LemonStain
Mar 31 2016 01:09
haha
Vik
@vvang044
Mar 31 2016 01:09
```
and end with the above....inbetween your code should be
your code..........................
blah.....it vanished
Kevin Anderson
@LemonStain
Mar 31 2016 01:11
side note: still having issues with "Stand in Line" JavaScript lesson ...

function queue(arr, item) {
// Your code here

return testArr.push(item),
testArr.shift(item); // Change this line
}
// Test Setup
var testArr = [1,2,3,4,5];

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

Matthew Fricker
@mattfricker
Mar 31 2016 01:11
@LemonStain All you have to do to pass that last is to move the return statement to the last line of the function - the placement of the return statement in your code above made it so the last line of your function was never executed.
Kevin Anderson
@LemonStain
Mar 31 2016 01:12
thanks @mattfricker ill try that
CamperBot
@camperbot
Mar 31 2016 01:12
lemonstain sends brownie points to @mattfricker :sparkles: :thumbsup: :sparkles:
:star: 68 | @mattfricker | http://www.freecodecamp.com/mattfricker
Zabe Sangary
@zabesangary
Mar 31 2016 01:12
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;       // Change this Line
var player = [testObj]; 
console.log(testObj);// Change this Line
can someone please look at my code
Matthew Fricker
@mattfricker
Mar 31 2016 01:14

@zabefloyd You access a property on objects like this - yourObject[yourProperty]

in this case, testObj is yourObject and playerNumber is yourProperty

bespinosa01
@bespinosa01
Mar 31 2016 01:15

```js
while (contacts.hasOwnProperty(firstName) === true &&(contact.hasOwnProperty(prop) === true)){

 if (contacts.hasOwnProperty(firstName) === false){
  return "No such contact";
}
else if (contacts.hasOwnProperty(prop)=== false) {
  return "No such property";
} 
return contacts[prop];

}

so Im having trouble figuring the profile lookup challenge
Vik
@vvang044
Mar 31 2016 01:16
@bespinosa01 have you thought about writing two If-statements and an else?
to make it easy
bespinosa01
@bespinosa01
Mar 31 2016 01:17
I've tried multiple approaches this was just my most recent
Zabe Sangary
@zabesangary
Mar 31 2016 01:18
@mattfricker
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;       // Change this Line
var player = testObj[16]; 
console.log(testObj);
where else do I need the bracket? thanks for the answer btw
Matthew Fricker
@mattfricker
Mar 31 2016 01:19
@zabefloyd Very good - I think they want you to input the variable name instead of the number being stored in playerNumber though
Zabe Sangary
@zabesangary
Mar 31 2016 01:20
Instructions
Use the playerNumber variable to lookup player 16 in testObj using bracket notation.
Vik
@vvang044
Mar 31 2016 01:20
have you written a for statement?
Matthew Fricker
@mattfricker
Mar 31 2016 01:21
@zabefloyd Yeah, so instead of putting the number directly in between the brackets try using the variable (playerNumber) that is referencing that number
Moisés Man
@moigithub
Mar 31 2016 01:21
@nazihhizan hope u see the PM..cuz i wrote (copy/paste) a lot
Zabe Sangary
@zabesangary
Mar 31 2016 01:22
@mattfricker Thanks! it worked
CamperBot
@camperbot
Mar 31 2016 01:22
zabefloyd sends brownie points to @mattfricker :sparkles: :thumbsup: :sparkles:
:star: 69 | @mattfricker | http://www.freecodecamp.com/mattfricker
Matthew Fricker
@mattfricker
Mar 31 2016 01:22
@zabefloyd any time
Kevin Anderson
@LemonStain
Mar 31 2016 01:25
@mattfricker still struggling here. with Stand in Line
Matthew Fricker
@mattfricker
Mar 31 2016 01:27
@LemonStain Have you made any updates? Can you post the code again?
Kevin Anderson
@LemonStain
Mar 31 2016 01:28

I did but it started to make other items fail - function queue(arr, item) {
// Your code here

testArr.push(item),
testArr.shift(item);

return item; // Change this line
}

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

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

Matthew Fricker
@mattfricker
Mar 31 2016 01:29
@LemonStain Alright, so all of your code is running now - but I believe the tests want you to return the item that you shift off of the array.
Nazih Ibrahim
@nazihhizan
Mar 31 2016 01:29
@moigithub
Thanks man saw the PM's it really helped
CamperBot
@camperbot
Mar 31 2016 01:29
nazihhizan sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 804 | @moigithub | http://www.freecodecamp.com/moigithub
Matthew Fricker
@mattfricker
Mar 31 2016 01:30
@LemonStain I do not believe the last line, which you are currently returning is not required - try deleting that last line of the function and returning the value that you are taking off the beginning of the array
Matthew Fricker
@mattfricker
Mar 31 2016 01:36
@LemonStain Did you get it?
Kevin Anderson
@LemonStain
Mar 31 2016 01:37
not yet - trying to break it down to understand where i am missing something
Hsin Chih Wang
@hsinwang5
Mar 31 2016 01:38
@LemonStain change the comma after testArr.push(item) to a semicolon
Matthew Fricker
@mattfricker
Mar 31 2016 01:38
@LemonStain Also, you want to be working with the parameter of the function, which is arr, not testArr
Robert Richey
@0x0936
Mar 31 2016 01:40
@LemonStain .shift() does not take any arguments MDN.
Micah Bales
@micahbales
Mar 31 2016 01:41
I feel like I'm really close on the Pig Latin algorithm challenge, but have an error with determining which type of conversion to do. Any ideas? Here's my code:
function translate(str) {

  var strArr = str.split('');
  var vowels = ["a", "e", "i", "o", "u"];
  var cons = 0;

  for (i = 0; i <= 1; i += 1) {
    if (vowels.indexOf(strArr[i]) !== -1) {
      cons += 1;  
    }
  }

  console.log(cons);

  if (cons === 2) { // double initial consonant

    return str.substr(2) + strArr[0] + strArr[1]+ "ay";

  } else if (cons === 1) { // single initial consonant

    return str.substr(1) + str.substr(0, 1) + "ay";

  } else { // initial vowel

    return str + "way";

  }  

}

translate("algorithm");
Kevin Anderson
@LemonStain
Mar 31 2016 01:46
I got the answer for the one i was failing but now the other two i had failed...

function queue(arr, item) {
// Your code here

item = arr.shift();
arr.push(item);

return item; // Change this line
}

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

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

Matthew Fricker
@mattfricker
Mar 31 2016 01:48
@micahbales you never declare i with var i = 0 in your for loop
Moisés Man
@moigithub
Mar 31 2016 01:48
@micahbales what this means ? (aka explain with simple words)
if (vowels.indexOf(strArr[i]) !== -1) {
Justin
@daemedeor
Mar 31 2016 01:48
@micahbales look up typeof
@mattfricker while yes he did forget it and its better to have it in, it wouldn’t make the code break
well in this case
as long as he’s careful
Micah Bales
@micahbales
Mar 31 2016 01:49
@moigithub it should mean, if the current index of the array contains a vowel
Matthew Fricker
@mattfricker
Mar 31 2016 01:49
@moigithub It is checking to see if index i of strArr is in the vowels array
Micah Bales
@micahbales
Mar 31 2016 01:49
+1 @mattfricker
Matthew Fricker
@mattfricker
Mar 31 2016 01:50
@daemedeor It would break in strict mode, which is used in most places.
Justin
@daemedeor
Mar 31 2016 01:50
@mattfricker fair enough, but this isn’t technically strict mode ;)
Moisés Man
@moigithub
Mar 31 2016 01:50
soo.. if the first character of the word passed in.. contains a vowel... u do this
cons += 1; <-- counting ... contants ?? or what that variable its for ?
@micahbales
Matthew Fricker
@mattfricker
Mar 31 2016 01:50
@daemedeor fair enough
Micah Bales
@micahbales
Mar 31 2016 01:50
@moigithub yes.
Moisés Man
@moigithub
Mar 31 2016 01:51
or u counting how many vowels it start with ??
Micah Bales
@micahbales
Mar 31 2016 01:51
@daemedeor I looked it up. Why would .typeof be helpful?
Justin
@daemedeor
Mar 31 2016 01:52
oh wait
@micahbales i lie sorry i just saw converstion
Micah Bales
@micahbales
Mar 31 2016 01:52
@moigithub No, I'm trying to figure out whether it starts with consonants.
@moigithub I increment "cons" if the index doesn't contain a vowel (therefore, contains a consonant)
Moisés Man
@moigithub
Mar 31 2016 01:53

sooo if u counting.. consonants...

    if (vowels.indexOf(strArr[i]) !== -1) {
      cons += 1;  
    }

this is wrong

vowels.indexOf("a") <-- returns a number >=0
so its !== -1
"its a vowel" !!!
if u wanna count consonants
Micah Bales
@micahbales
Mar 31 2016 01:54
do ===
Moisés Man
@moigithub
Mar 31 2016 01:54
should be === -1
yep :)
Micah Bales
@micahbales
Mar 31 2016 01:54
haha, nice. thanks, @moigithub
CamperBot
@camperbot
Mar 31 2016 01:54
micahbales sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
Justin
@daemedeor
Mar 31 2016 01:54
@micahbales the problem with counting constants is that the first loop is only run on the first letter
CamperBot
@camperbot
Mar 31 2016 01:54
:star: 805 | @moigithub | http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Mar 31 2016 01:55
well gtg
Justin
@daemedeor
Mar 31 2016 01:55
unless that was the purpose?
you could probably actually just use .shift() if you’re only getting the first letter (since its an array) or .slice(1)
haha
Micah Bales
@micahbales
Mar 31 2016 01:57
thx @daemedeor
CamperBot
@camperbot
Mar 31 2016 01:57
micahbales sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 141 | @daemedeor | http://www.freecodecamp.com/daemedeor
Vik
@vvang044
Mar 31 2016 02:11
help slasher flick
CamperBot
@camperbot
Mar 31 2016 02:11

:point_right: algorithm slasher flick [wiki]

Problem Explanation:

Return the remaining elements of an array after chopping off n elements from the head.

For example: slasher([1, 2, 3], 2); must return [3]

:pencil: read more about algorithm slasher flick on the FCC Wiki

Traplord Ses
@TrapSes
Mar 31 2016 02:15
Question on Make Object Properties Private:
Modify the Bike constructor to have a private property called gear and two public methods called getGear and setGear to get and set that value.
var Bike = function() {

  // Only change code below this line.
  var gear;
  this.setGear = function() {
  };
};
not sure how to code the getGear part
Diego Mayer
@Chrono79
Mar 31 2016 02:17
@TrapSes setGear isn't done yet too
Traplord Ses
@TrapSes
Mar 31 2016 02:18
@Chrono79 would it return gear;
Robert Richey
@0x0936
Mar 31 2016 02:19
@dagman looks great. love how you did those box shadows.
Diego Mayer
@Chrono79
Mar 31 2016 02:19
@TrapSes that would be the code inside getGear
setGear should have a param you should asign the value to gear
Islam Ibakaev
@dagman
Mar 31 2016 02:19
@0x0936 :smile:
Nicolas May
@hynso
Mar 31 2016 02:19
OOOMMMGGG... Finally finished the string permutation algorithm. Hardest problem I've ever faced. YIXE.
Islam Ibakaev
@dagman
Mar 31 2016 02:20
@hynso whats you code?
Traplord Ses
@TrapSes
Mar 31 2016 02:20
var Bike = function() {

  // Only change code below this line.
  var gear;
  this.setGear = function() {
  };
  this.getGear = function() {
    return gear;
  };
};
@Chrono79
Nicolas May
@hynso
Mar 31 2016 02:20
@dagman I'm on my phone now so it's harder to retrieve
Diego Mayer
@Chrono79
Mar 31 2016 02:20
@TrapSes setGear should have a param you should asign the value to gear
Islam Ibakaev
@dagman
Mar 31 2016 02:21
@hynso whats the name of bonfire?
Vik
@vvang044
Mar 31 2016 02:21
you are missing change .......this.setGear = function(change)
Nicolas May
@hynso
Mar 31 2016 02:21
"No repeats please"
ZctrapCoding
@ZctrapCoding
Mar 31 2016 02:22
http://codepen.io/Zctrap/pen/dMRZNd how is it looks good so far?
Kevin Anderson
@LemonStain
Mar 31 2016 02:22
WOHOOO! got the Stand in LIne challenge
Robert Richey
@0x0936
Mar 31 2016 02:22
@LemonStain great! :+1:
ZctrapCoding
@ZctrapCoding
Mar 31 2016 02:23
Does it look prefessional kinda?
Chris
@thoughtsofone
Mar 31 2016 02:23
Stuck on Sort Arrays with sort
ZctrapCoding
@ZctrapCoding
Mar 31 2016 02:23
oh wait wrong section xD
this isnt javascript...
Chris
@thoughtsofone
Mar 31 2016 02:24
array.sort(function(a, b){
return a + b;
}); isn't returning largest to smallest
Diego Mayer
@Chrono79
Mar 31 2016 02:24
@thoughtsofone try b - a
Chris
@thoughtsofone
Mar 31 2016 02:25
Thank you @Chrono79 !!!!!
CamperBot
@camperbot
Mar 31 2016 02:25
thoughtsofone sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 310 | @chrono79 | http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Mar 31 2016 02:25
no problem
Kent
@kenthub
Mar 31 2016 02:29
when accessing JSON values... what is difference in using the dot notation versus the bracket [] notation
Harvey S
@harveysanders
Mar 31 2016 02:31
@kenthub it’s more about accessing JS objects in general, not just JSON, but you can use variables with [] notation
Kent
@kenthub
Mar 31 2016 02:33
Ok on the profile lookup, in my first if I had to use dot notation to access firstName and all other places it used [] notation. Just trying to understand the difference to make sure I fully understand when/why
function lookUp(firstName, prop){
// Only change code below this line
for(var i = 0 ;i < contacts.length; i++){
  if(contacts[i].firstName === firstName){
    if(contacts[i][prop]){
      return contacts[i][prop];
    } else
      return "No such property";
  }
}
  return "No such contact";
// Only change code above this line
is it due to the fact I am trying to access the JS object in they array? and not the actual variable?
if that make sense!
Harvey S
@harveysanders
Mar 31 2016 02:37

@kenthub if you have var pizza = { toppings = [‘cheese’, ‘sauce', ‘pepperoni’], size=15, isReady=false }

you can access if it’s ready with pizza.isReady or pizza[‘isReady’]
but if you wanted to use a varible to hold a key like
var pizzaIsReady = ‘isReady’

you can’t do pizza.pizzaIsReady, becuase there is no key by thay name, but you can do pizza[pizzaIsReady]

@kenthub that was kind of a dumb example, but i hope it makes sense
@kenthub yes
Nicole S.
@nicolesteck
Mar 31 2016 02:39

OK, I'm working on the 'use objects for lookups' waypoint and i am so lost!

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

// Only change code below this line

var lookup = {
"alpha": "Adams",
"bravo" : "Boston",
"charlie" : "Chicago",
"delta" : "Denver",
"echo" : "Easy",
"foxtrot" : "Frank"

};
lookup.alpha;
// Only change code above this line
return result;
}

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

Harvey S
@harveysanders
Mar 31 2016 02:39
@kenthub prop is a variable name, not an actual property name in your object
Diego Mayer
@Chrono79
Mar 31 2016 02:40
@kenthub does your code work?
Harvey S
@harveysanders
Mar 31 2016 02:40
so you can't just do contacts[i].prop
@kenthub unless contacts[i] literally had a property named prop like {prop: ‘someProperty’}
Kent
@kenthub
Mar 31 2016 02:41
@harveysanders thanks I understand the difference now. Sometimes you just have to write it out and it comes to you. Accessing variables versus property names(keys)
CamperBot
@camperbot
Mar 31 2016 02:41
kenthub sends brownie points to @harveysanders :sparkles: :thumbsup: :sparkles:
:star: 384 | @harveysanders | http://www.freecodecamp.com/harveysanders
Harvey S
@harveysanders
Mar 31 2016 02:41
@kenthub no problem, i had trouble with that a first too
Kent
@kenthub
Mar 31 2016 02:42
@Chrono79 yes it works. I got stuck on it and it was due to the dot notation so I used the wiki for help
Arjun Narayanan
@anarayanan86
Mar 31 2016 02:42
man the zero-order indexing is a bear sometimes
Justin
@daemedeor
Mar 31 2016 02:43
@anarayanan86 wait till you go to another language that has 1 based indexing after you have done zero based indexing
This message was deleted
This message was deleted
Arjun Narayanan
@anarayanan86
Mar 31 2016 02:43
haha whatttt
Kent
@kenthub
Mar 31 2016 02:44
@daemedeor why would they do that!
Justin
@daemedeor
Mar 31 2016 02:44
btw… CSS is 1 based indexing
@kenthub no idea
Harvey S
@harveysanders
Mar 31 2016 02:44
@daemedeor that’s messed up
Arjun Narayanan
@anarayanan86
Mar 31 2016 02:44
i think R uses 1 based indexing
Justin
@daemedeor
Mar 31 2016 02:45
wait let me look at php again
maybe i’m wrong
i could’ve sworn there was one based indexing somewhere in php
Harvey S
@harveysanders
Mar 31 2016 02:46
@daemedeor no i don’t know, i was just saying that’s messed up if it is true
@daemedeor i don’t know anything about php
Justin
@daemedeor
Mar 31 2016 02:46
its a pain doing something in JS and then goign to CSS though
0 based indexing is the norm in a lot of C based languages
okay ignore what i said about php
i shouldn’t be giving it a bad rep when its undeserved
its already bad enough
Diego Mayer
@Chrono79
Mar 31 2016 02:47
@kenthub I used Object.hasOwnProperty(prop) there instead of Object[prop] but it works either way
Justin
@daemedeor
Mar 31 2016 02:48
@Chrono79 yups
Kent
@kenthub
Mar 31 2016 02:48
@Chrono79 I used it originally then scrapped it out of frustration :D
Justin
@daemedeor
Mar 31 2016 02:48
realistically you want the hasownprop though
you might ask why
Harvey S
@harveysanders
Mar 31 2016 02:49
@daemedeor to avoid inheritance issues?
Justin
@daemedeor
Mar 31 2016 02:49
yea
basically
Harvey S
@harveysanders
Mar 31 2016 02:49
@daemedeor word
Justin
@daemedeor
Mar 31 2016 02:49
well prototype issues
which amounts to inheritance in js
Harvey S
@harveysanders
Mar 31 2016 02:49
got ya
Paul Borawski
@iAmNawa
Mar 31 2016 02:50
will you guys please check out my website
farallonco.com
any advice would eb great
Justin
@daemedeor
Mar 31 2016 02:51
@iAmNawa you should put a black mask ontop of the bricks and make it less bright
otherwise its an alright site
@iAmNawa also your connect to start bootstrap?
also you should put the copyright and the breadcrumbs at the bottom of the page, smack dab in the middle
J. Clarke
@Jussic
Mar 31 2016 02:54
This message was deleted
CamperBot
@camperbot
Mar 31 2016 02:54
no wiki entry for: please write a function queue which takes an array arr and a number item as arguments add the number to the end of the array then remove the first element of array the queue function should then return the element that was removed function queuearr item return item 1 change this line test setupvar testarr 12345 display codeconsolelogbefore jsonstringifytestarrconsolelogqueuetestarr 1 modify this line to testconsolelogafter jsonstringifytestarr
Justin
@daemedeor
Mar 31 2016 02:54
hint you can make the a link in the header for the phone number actually use the phone number @iAmNawa
CamperBot
@camperbot
Mar 31 2016 02:54
Set a bonfire to talk about with bonfire name
escapeplan4
@escapeplan4
Mar 31 2016 02:55
@nicolesteck me too :worried:
Paul Borawski
@iAmNawa
Mar 31 2016 02:55
how @daemedeor
Justin
@daemedeor
Mar 31 2016 02:55
@iAmNawa to help you on your way: its a tel attribute ;)
its really simple but i figure you might remember it better that way
Paul Borawski
@iAmNawa
Mar 31 2016 02:55
i already used that
J. Clarke
@Jussic
Mar 31 2016 02:56
// Only change code above this line
Justin
@daemedeor
Mar 31 2016 02:56
hmmm
Lucky charm
@luckycharm223
Mar 31 2016 02:56
Paul Borawski
@iAmNawa
Mar 31 2016 02:56
<a href="tel://4158927760"><i class="fa fa-phone fa-fw"></i>(415)892-7760</a>
J. Clarke
@Jussic
Mar 31 2016 02:56
This message was deleted
CamperBot
@camperbot
Mar 31 2016 02:56
no wiki entry for: please function queuearr item return item 1 change this line test setupvar testarr 12345 display codeconsolelogbefore jsonstringifytestarrconsolelogqueuetestarr 1 modify this line to testconsolelogafter jsonstringifytestarr
Justin
@daemedeor
Mar 31 2016 02:56
@iAmNawa oh i lie XD good job
Paul Borawski
@iAmNawa
Mar 31 2016 02:57
Thanks! @daemedeor
CamperBot
@camperbot
Mar 31 2016 02:57
iamnawa sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
Justin
@daemedeor
Mar 31 2016 02:57
@Jussic
function queue(arr, item) {
    return item * 1; // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr))
CamperBot
@camperbot
Mar 31 2016 02:57
:star: 142 | @daemedeor | http://www.freecodecamp.com/daemedeor
Justin
@daemedeor
Mar 31 2016 02:57
huh its not an attribute
J. Clarke
@Jussic
Mar 31 2016 02:58
Lol @daemedeor yes I didn't know how to get it in the code box.... do you know what this is asking me to do?
Paul Borawski
@iAmNawa
Mar 31 2016 02:58
I really just wanted to see if my google analytics was working @daemedeor lol
Diego Mayer
@Chrono79
Mar 31 2016 02:58
@luckycharm223 Instructions
Call the process function with an argument of 7 and assign its return value to the variable processed.
Justin
@daemedeor
Mar 31 2016 02:59
@Jussic bascially add an item to the end of the array and slice off the first item of the original array
@iAmNawa so they’re not good design tips :(
Paul Borawski
@iAmNawa
Mar 31 2016 02:59
@daemedeor black mask?
Justin
@daemedeor
Mar 31 2016 03:00
@iAmNawa basically like a black div thats somewhat opaque behind the text
Paul Borawski
@iAmNawa
Mar 31 2016 03:00
i was just making a joke
Justin
@daemedeor
Mar 31 2016 03:00
cause the contrast is loooooow
you want higher contrast
a bit hard to read the text
Paul Borawski
@iAmNawa
Mar 31 2016 03:01
can you give me an example of which element in css to change?
Justin
@daemedeor
Mar 31 2016 03:02
background-color: rgba(0,0,0,.75); on a new div
essentially
or you could do it on the container div
i suppose
Lucky charm
@luckycharm223
Mar 31 2016 03:04
@Chrono79 I know I read the instructions
Paul Borawski
@iAmNawa
Mar 31 2016 03:04
and that would change the photot?
J. Clarke
@Jussic
Mar 31 2016 03:04
This message was deleted
Justin
@daemedeor
Mar 31 2016 03:05
Screen Shot 2016-03-30 at 11.04.38 PM.png
@iAmNawa this is just to highlight the difference
J. Clarke
@Jussic
Mar 31 2016 03:05
This message was deleted
Diego Mayer
@Chrono79
Mar 31 2016 03:06
@luckycharm223 so: processed = process(7);
Justin
@daemedeor
Mar 31 2016 03:06
@iAmNawa you can play around with the last number to kinda tweak a better looking picture
J. Clarke
@Jussic
Mar 31 2016 03:06
This message was deleted
Justin
@daemedeor
Mar 31 2016 03:06
though imo it should be another div that spans the entire size of the image
more consistent that way
or you make some space on the top
i’m just being laazy
Paul Borawski
@iAmNawa
Mar 31 2016 03:07
what about changing the text color? I like the brightness of the background, unless you think it should be changed?
J. Clarke
@Jussic
Mar 31 2016 03:07
This message was deleted
Diego Mayer
@Chrono79
Mar 31 2016 03:07
Jussic, use the ```in a blank line
Justin
@daemedeor
Mar 31 2016 03:07
@iAmNawa its hard because the bricks stand out too much, many of the other text colors that i can think of will be washed out
J. Clarke
@Jussic
Mar 31 2016 03:08
Guys could I have a bit of help with passing this challenge please
@Chrono79 thanks I'll try again
CamperBot
@camperbot
Mar 31 2016 03:08
jussic sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Diego Mayer
@Chrono79
Mar 31 2016 03:08
You can edit your message, the ... in the upper right corner
CamperBot
@camperbot
Mar 31 2016 03:08
:star: 311 | @chrono79 | http://www.freecodecamp.com/chrono79
J. Clarke
@Jussic
Mar 31 2016 03:08
function queue(arr, item) {
  // Your code here
  testArr.push(item);
  testArr.shift();

   return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Paul Borawski
@iAmNawa
Mar 31 2016 03:08
@daemedeor it’s just to show to the client anyway, I assume they will want one of their construction photos there
Justin
@daemedeor
Mar 31 2016 03:09
@iAmNawa you should still probably heighten the contrast
most construction pics will be too bright too most likely
same thing with the one on the bottom
it might actually make it worse
i’m personally a fan of smaller border radius’s on the photos but its not particuarly nessesary
maybe use the same border-shadow @iAmNawa on all the pics to be the same, consisntency is key
Diego Mayer
@Chrono79
Mar 31 2016 03:11
@Jussic you have 2 "errors" there
inside the function you should use arr not testArr
and you should return arr.shift() or item = arr.shift(); and the return item
Paul Borawski
@iAmNawa
Mar 31 2016 03:11
I did use all the same border shadow
J. Clarke
@Jussic
Mar 31 2016 03:12
This message was deleted
Justin
@daemedeor
Mar 31 2016 03:12
@iAmNawa oh i lie but you should use the same class, all photo instead of a photo2 class and a photo3 class
easier to maintain
@iAmNawa sorry XD
Lucky charm
@luckycharm223
Mar 31 2016 03:12
@Chrono79 it didn't work
Paul Borawski
@iAmNawa
Mar 31 2016 03:13
I’m having trouble changing the background opacity
Justin
@daemedeor
Mar 31 2016 03:13
@iAmNawa i mean box shadow but i’m a bit off, it was all the same
@iAmNawa rgba(0,0,0,.45);
just change the last number in the parentathese
Paul Borawski
@iAmNawa
Mar 31 2016 03:14
ok that border radius 5px looks a bit better?
Justin
@daemedeor
Mar 31 2016 03:14
bleh
yea
but like i said its a personal one
escapeplan4
@escapeplan4
Mar 31 2016 03:14

@nicolesteck I got it:function phoneticLookup(val) {
var result = "";

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

Justin
@daemedeor
Mar 31 2016 03:14
you didn’t have to XD
Diego Mayer
@Chrono79
Mar 31 2016 03:14
@Jussic got it? I edited my previous message
@luckycharm223 paste your code please
Mark Howard
@iheartkode
Mar 31 2016 03:16
.
J. Clarke
@Jussic
Mar 31 2016 03:17
@Chrono79 just saw it, I already passed it but thanks still :)
CamperBot
@camperbot
Mar 31 2016 03:17
jussic sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: jussic already gave chrono79 points
Paul Borawski
@iAmNawa
Mar 31 2016 03:17
yeah that’s not changing it @daemedeor you’re changing the background color but the background is a photo
Lucky charm
@luckycharm223
Mar 31 2016 03:17
'''
CamperBot
@camperbot
Mar 31 2016 03:17
:bulb: to format code use backticks! ``` more info
Justin
@daemedeor
Mar 31 2016 03:18
@iAmNawa oh because i’m not changing the img
Lucky charm
@luckycharm223
Mar 31 2016 03:19

''' // Example
var changed = 0;

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

changed = change(10);

// Setup
var processed = 0;

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

// Only change code below this line
var processed = process (7);
'''

CamperBot
@camperbot
Mar 31 2016 03:19
:bulb: to format code use backticks! ``` more info
Justin
@daemedeor
Mar 31 2016 03:20
@iAmNawa well more specifically you don’t put it on the intro-header div
Lucky charm
@luckycharm223
Mar 31 2016 03:20
'''
CamperBot
@camperbot
Mar 31 2016 03:20
:bulb: to format code use backticks! ``` more info
Kyle Morton
@kmorton1988
Mar 31 2016 03:20
@luckycharm223 use the backtick key, it's to the left of the "1" key
Diego Mayer
@Chrono79
Mar 31 2016 03:20
@luckycharm223 quit the var in "var processed = process (7);"
Paul Borawski
@iAmNawa
Mar 31 2016 03:20
i tried creating a new div that is the parent, didn’t work. @daemedeor
Justin
@daemedeor
Mar 31 2016 03:20
@iAmNawa you should make a new div that is a child
Lucky charm
@luckycharm223
Mar 31 2016 03:20
@kmorton1988
I'm on my phone
Kyle Morton
@kmorton1988
Mar 31 2016 03:21
oh.
umm.
`
copy that then?
Paul Borawski
@iAmNawa
Mar 31 2016 03:21
tried that as well, did nothing @daemedeor
Kyle Morton
@kmorton1988
Mar 31 2016 03:21
which phone?
Justin
@daemedeor
Mar 31 2016 03:21
@iAmNawa make the intro-header div relative, then make the new child div absolute, make the top: 0, left: 0, right: 0, bottom: 0
then put the background-color
Kyle Morton
@kmorton1988
Mar 31 2016 03:22
@iAmNawa what are you trying to change?
Paul Borawski
@iAmNawa
Mar 31 2016 03:23
the opacity of the bricks
farallonco.com
Justin
@daemedeor
Mar 31 2016 03:23
@kmorton1988 i’m trying to help him add a little contrast to his header image
the white text on the overly bright bricks provides too little contrast
its a bit hard to read
Kyle Morton
@kmorton1988
Mar 31 2016 03:23
why not add a background gradient to darken it?
Paul Borawski
@iAmNawa
Mar 31 2016 03:23
ok how
Justin
@daemedeor
Mar 31 2016 03:23
he made the background image the parent div
Kyle Morton
@kmorton1988
Mar 31 2016 03:24
background: img(URLTOIMG), lineargradient(rgba(0,0,0,.5),rbga(0,0,0,.5);
Lucky charm
@luckycharm223
Mar 31 2016 03:24
@kmorton1988 iPhone
Kyle Morton
@kmorton1988
Mar 31 2016 03:25
@luckycharm223 switch to the number keyboard, long-press the apostrophe, then drag to the far-left option.
Arjun Narayanan
@anarayanan86
Mar 31 2016 03:25
I'm having a problem with the "Chunky Monkey" challenge
not sure how to "loopify" my syntax if that makes any sense
Justin
@daemedeor
Mar 31 2016 03:25
i prefer an extra div, easier to manipulate haha
Arjun Narayanan
@anarayanan86
Mar 31 2016 03:26
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var final = [];
  for (i = 0; i < arr.length/size; i++) {
    int = [];
    first = arr.slice(0, size);
    remainder = arr.slice(size);
    final.push(first);
    int.push(remainder);
    remainder.slice(size);
    final.push(int);
  }
  return final;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Justin
@daemedeor
Mar 31 2016 03:26
also @kmorton1988 you’re missing a parens hehe
Kyle Morton
@kmorton1988
Mar 31 2016 03:26
ahh, you're right.
need a second ) at the end of that before the semi-colon
Justin
@daemedeor
Mar 31 2016 03:26
syntax syntax!
;)
Karl Sanford
@karlsanford
Mar 31 2016 03:27
@anarayanan86 you don't always have to increment by i++. You can use i = i + 2 or i = i + x
Justin
@daemedeor
Mar 31 2016 03:27
they got rid of c-style loops in swift T-T
Arjun Narayanan
@anarayanan86
Mar 31 2016 03:27
i had a feeling you had to change the incrementation
Justin
@daemedeor
Mar 31 2016 03:28
also @karlsanford you can do i+=2 or i+=x
Paul Borawski
@iAmNawa
Mar 31 2016 03:28
<div class="intro-header">
<div class="hello">
<div class="container">
.hello {
background-color: rgba(0,0,0,.45);
top: 0;
right: 0;
bottom: 0;
left: 0;
}
nothign happens
Justin
@daemedeor
Mar 31 2016 03:28
@iAmNawa gotta make the div positoned absolutely
Karl Sanford
@karlsanford
Mar 31 2016 03:28
@daemedeor thanks
CamperBot
@camperbot
Mar 31 2016 03:28
karlsanford sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 143 | @daemedeor | http://www.freecodecamp.com/daemedeor
Justin
@daemedeor
Mar 31 2016 03:29
@iAmNawa oh and make the intro-header positioned: relatively
before you note that break
Kyle Morton
@kmorton1988
Mar 31 2016 03:29
.hello {
  background: img(URLTOIMG), lineargradient(rgba(0,0,0,0.45),rgba(0,0,0,0.45));

}
Lucky charm
@luckycharm223
Mar 31 2016 03:29
Thank you for the help @Chrono79
CamperBot
@camperbot
Mar 31 2016 03:29
luckycharm223 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 312 | @chrono79 | http://www.freecodecamp.com/chrono79
Karl Sanford
@karlsanford
Mar 31 2016 03:29
@anarayanan86 play with that. you will also need to pick a beginning and end of your slice!
Justin
@daemedeor
Mar 31 2016 03:30
@kmorton1988 nooooooooo well his intro-header div is already the image
Kyle Morton
@kmorton1988
Mar 31 2016 03:30
ooooh.
well, if you change it to ^^, he can remove that bit from the div.
Justin
@daemedeor
Mar 31 2016 03:31
that is the one that is set background-image, if he goes your route then he doesn’t need the child div but i don’t like using lineargradient even though its mostly supported
if he goes my route, its a little bit more heavy but more widely supported
there’s many ways to skin a cat as they say though
i don’t care either way
Kyle Morton
@kmorton1988
Mar 31 2016 03:32
shrugs yeah, I hear ya.
I haven't seen a browser yet that won't properly display it.
Justin
@daemedeor
Mar 31 2016 03:32
opera
and IE 8/9
of course
well opera mini
Diego Mayer
@Chrono79
Mar 31 2016 03:34
@anarayanan86 I solved it with a for i++ but using Math.ceil, i+1 and othe juju like that
Justin
@daemedeor
Mar 31 2016 03:34
;)
which is to say… more or less perfect to use @kmorton1988 haha
Paul Borawski
@iAmNawa
Mar 31 2016 03:34
there is still a small gap that isn’t opaque
@daemedeor
Justin
@daemedeor
Mar 31 2016 03:34
yeah… there’s some padding issues
shrug
i would suggest getting rid of padding-bottom
then Everything Is AWESOME :D
Paul Borawski
@iAmNawa
Mar 31 2016 03:36
fixed it
thank you! @daemedeor
CamperBot
@camperbot
Mar 31 2016 03:37
iamnawa sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
Justin
@daemedeor
Mar 31 2016 03:37
but don’t you agree that its much easier to read now?
CamperBot
@camperbot
Mar 31 2016 03:37
:warning: iamnawa already gave daemedeor points
Justin
@daemedeor
Mar 31 2016 03:38
you can kinda play around with opacity a little. so its a bit brighter than the one i gave you
Paul Borawski
@iAmNawa
Mar 31 2016 03:40
yeah much easier to see
Justin
@daemedeor
Mar 31 2016 03:40
same general idea with the one down below
it was the white of the motar that was clashing with the words is why
Sumit Roy
@sroy8091
Mar 31 2016 03:42
why am i getting this erroe message? "You should be using bracket notation to read the value from myArray.
"
Justin
@daemedeor
Mar 31 2016 03:42
@sroy8091 instead of doing object.property you should be using object[“property”]
probably because property is a variable
Diego Mayer
@Chrono79
Mar 31 2016 03:43
g'nite people
Sumit Roy
@sroy8091
Mar 31 2016 03:43
my code is myArray[0][0]=8;
var myData = myArray[0][0];
my code is
myArray[0][0]=8;
var myData = myArray[0][0];
Justin
@daemedeor
Mar 31 2016 03:45
@sroy8091 could i see the context?
Matt Green
@mattxgreen
Mar 31 2016 03:45
Anyone know why I'm exceeding the stack size here:
function flatten() {
    var arrays = Array.prototype.slice.call(arguments);
    return arrays.reduce(function (flat, toFlatten) {
        return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
    }, []);
}

console.log(flatten([[2], [3], [4], [8, 5, 7]]));
Karl Sanford
@karlsanford
Mar 31 2016 03:45
@daemedeor would it object[property] if variable?
Justin
@daemedeor
Mar 31 2016 03:46
@karlsanford yea
@karlsanford or more like object[variable]
@mattxgreen i’m guessing because of toFlatten
because then you recursively call flatten
Matt Green
@mattxgreen
Mar 31 2016 03:47
It's only recurses while it's an array
Justin
@daemedeor
Mar 31 2016 03:48
yeah but look how many times you call toFlatten
Matt Green
@mattxgreen
Mar 31 2016 03:48
right, what's wrong w the code is the question ;)
Justin
@daemedeor
Mar 31 2016 03:48
toFlatten isn’t actually flattening the array
arrays.reduce the toFlatten will always be an array
even an empty one
so itll recurse and then keep giving an empty array till the end
Matt Green
@mattxgreen
Mar 31 2016 03:49
I see your point
@daemedeor thank you. Any ideas for a solution?
CamperBot
@camperbot
Mar 31 2016 03:50
mattxgreen sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 144 | @daemedeor | http://www.freecodecamp.com/daemedeor
Justin
@daemedeor
Mar 31 2016 03:50
@mattxgreen the easiest way while preserving your logic would be to add another test
Matt Green
@mattxgreen
Mar 31 2016 03:51
like check element 0 to be an array?
Justin
@daemedeor
Mar 31 2016 03:51
no that’ll cause a runtime error
if there are no elements in the array and you try to access the first index, it’ll pop a warning
Matt Green
@mattxgreen
Mar 31 2016 03:52
toFlatten[0] to be clear
Justin
@daemedeor
Mar 31 2016 03:52
yea
[][0] would break the code on runtime
Matt Green
@mattxgreen
Mar 31 2016 03:52
hmm
Justin
@daemedeor
Mar 31 2016 03:52
i’m only being coy to help you learn
there’s anothre way
Matt Green
@mattxgreen
Mar 31 2016 03:52
I'm in
Justin
@daemedeor
Mar 31 2016 03:53
if you can’t check the element what other properties do you have access to
Matt Green
@mattxgreen
Mar 31 2016 03:53
typeof, and it's methods
Justin
@daemedeor
Mar 31 2016 03:53
properties of arrays
not methods
Sumit Roy
@sroy8091
Mar 31 2016 03:54
@daemedeor myData should be equal to 8.
You should be using bracket notation to read the value from myArray.
Justin
@daemedeor
Mar 31 2016 03:55
@sroy8091 do you have the context?
Ramana Venkata
@vramana
Mar 31 2016 03:57
@mattxgreen Isn't the problem with your code the when you call flatten(toFlatten), arrays will be [toFlatten] ??
Justin
@daemedeor
Mar 31 2016 03:58
@vramana i’m already having him persue the code down, toFlatten will always be an array so Array.isArray() will always run the recursion
Sumit Roy
@sroy8091
Mar 31 2016 03:58
no
@daemedeor
Justin
@daemedeor
Mar 31 2016 03:58
that code should be right
but in order to … debug i need to see more of it
Matt Green
@mattxgreen
Mar 31 2016 03:59
@vramana I believe it is
Justin
@daemedeor
Mar 31 2016 03:59
@mattxgreen so what are the various properties of arrays? (you can look it up)
Ramana Venkata
@vramana
Mar 31 2016 04:00
This message was deleted
Matt Green
@mattxgreen
Mar 31 2016 04:02
@vramana @daemedeor I'm gonna take a think break on it
Justin
@daemedeor
Mar 31 2016 04:02
@mattxgreen okay ;}
Matt Green
@mattxgreen
Mar 31 2016 04:02
@vramana @daemedeor thanks for the help thus far
CamperBot
@camperbot
Mar 31 2016 04:02
mattxgreen sends brownie points to @vramana and @daemedeor :sparkles: :thumbsup: :sparkles:
:warning: mattxgreen already gave daemedeor points
:star: 239 | @vramana | http://www.freecodecamp.com/vramana
Matt Green
@mattxgreen
Mar 31 2016 04:10
it came to me:
    function concatAll() {
        var arrays = Array.prototype.slice.call(arguments);
        function flatten(a){
            return a.reduce(function (flat, toFlatten) {
                return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
            }, []);
        }
        return flatten(arrays);
    }
Justin
@daemedeor
Mar 31 2016 04:10
@mattxgreen i don’t see a differnce?
oh wait i do
Matt Green
@mattxgreen
Mar 31 2016 04:11
it's subtle
Justin
@daemedeor
Mar 31 2016 04:11
no
it’ll still break
NPeyralans
@NPeyralans
Mar 31 2016 04:11
Any hints on the first algorithms challenge. I saw some hints in the source code, but tried it and tithing worked
Matt Green
@mattxgreen
Mar 31 2016 04:11
@daemedeor why?
Justin
@daemedeor
Mar 31 2016 04:11
@mattxgreen stack calls again
you didn’t really fix the underlying problem
which is toFlatten will always be an array
Matt Green
@mattxgreen
Mar 31 2016 04:12
no, it won't
when you put an array into reduce it iterates the elements
Justin
@daemedeor
Mar 31 2016 04:13
oooh
wait i got parameters wrong
you’re right XD
maybe i should stop for the night then
good night :D
Matt Green
@mattxgreen
Mar 31 2016 04:15
@daemedeor my prob was assigning the arguments into an array everytime, so I had to subarray
Arjun Narayanan
@anarayanan86
Mar 31 2016 04:16
@karlsanford im still lost...but thanks anyway
CamperBot
@camperbot
Mar 31 2016 04:16
anarayanan86 sends brownie points to @karlsanford :sparkles: :thumbsup: :sparkles:
:star: 277 | @karlsanford | http://www.freecodecamp.com/karlsanford
Matt Green
@mattxgreen
Mar 31 2016 04:16
I'm sure there's a better way, but that's the way I figured out
Ramana Venkata
@vramana
Mar 31 2016 04:18
@mattxgreen I wrote the same solution as yours just now.
function flatten() {
    var args = [].slice.call(arguments); 


    function flatArray(array, acc) {
        if (acc === undefined) {
            acc = []
        }

        if (array.length === 0) {
            return acc 
        }

        var x = array[0]
        var xs =    array.slice(1)

        return flatArray(xs, acc.concat(Array.isArray(x) ? flatArray(x): x))

    }

    return flatArray(args)
}
Matt Green
@mattxgreen
Mar 31 2016 04:28
@vramana heh... your single comment is what led me to my solution
Ramana Venkata
@vramana
Mar 31 2016 04:30
@mattxgreen I effectively wrote reduce in the more general way. Sometimes the reduce syntax irks me.
I find it easy to think in terms of an array & an accumalator
Matt Green
@mattxgreen
Mar 31 2016 04:33
@vramana This helped me really understand reduce: http://www.macwright.org/2015/01/03/reduce-juice.html
Ramana Venkata
@vramana
Mar 31 2016 04:34
@mattxgreen How would you implement reduce in a recursive way??
That is what my solution is more or less about.
Matt Green
@mattxgreen
Mar 31 2016 04:35
my solution uses reduce recursively
Ramana Venkata
@vramana
Mar 31 2016 04:35
I am talking about implementing reduce itself.
Matt Green
@mattxgreen
Mar 31 2016 04:36
i'm not quite sure what you mean
Ramana Venkata
@vramana
Mar 31 2016 04:40
@mattxgreen write a recursive function reduce that works similar to Array.prototye.reduce. reduce(array, fn, initialValue)
Matt Green
@mattxgreen
Mar 31 2016 04:44
ah, I see what you mean... not sure that I'm up to that challenge tonight
Ramana Venkata
@vramana
Mar 31 2016 04:45
It's okay. I can think about it when you are free.
Markus Kiili
@Masd925
Mar 31 2016 05:12
@mattxgreen Why are you slicing arguments, when steamroller gets only one argument passed (nested array).
Matt Green
@mattxgreen
Mar 31 2016 05:13
@Masd925 what's steamroller?
Markus Kiili
@Masd925
Mar 31 2016 05:14
@mattxgreen I looked like you were solving steamroller challenge.
Matt Green
@mattxgreen
Mar 31 2016 05:15
@Masd925 naw, different one, and I need to concat, and flatten x number of arrays
Markus Kiili
@Masd925
Mar 31 2016 05:15
@mattxgreen ok.
Matt Green
@mattxgreen
Mar 31 2016 05:15
but I'll go solve steamroller with what I have ;)
Matt Green
@mattxgreen
Mar 31 2016 05:21
This message was deleted
naw, I should refactor
Markus Kiili
@Masd925
Mar 31 2016 05:22
@mattxgreen You can do without the inner function.
Matt Green
@mattxgreen
Mar 31 2016 05:22
I saw it as soon as I posted it
Markus Kiili
@Masd925
Mar 31 2016 05:23
@mattxgreen Then it becomes the standard reduce solution.
Matt Green
@mattxgreen
Mar 31 2016 05:23
function steamroller(a) {
    return a.reduce(function(p,c){
      return p.concat( Array.isArray(c) ? steamroller(c) : c);
    },[]);
}
Markus Kiili
@Masd925
Mar 31 2016 05:24
@mattxgreen There is also a (even one-liner) recursive solution that shifts and steamrolls the first element.
Matt Green
@mattxgreen
Mar 31 2016 05:25
I"ll bite
@Masd925 is it an array.concat?
Spencer Kuzara
@kodaxx
Mar 31 2016 05:28
Anyone here feel like helping me with a JS project? Just something I've been programming on the side - not sure why it isn't working
Markus Kiili
@Masd925
Mar 31 2016 05:28
@mattxgreen Yes, it needs concat.
Matt Green
@mattxgreen
Mar 31 2016 05:28
one sec
@Masd925 not getting it
this is my best try:
function steamroller(a){
  return [].concat.apply([], a);
}
@kodaxx if it's not a huge undertaking, I'll take a glance
Spencer Kuzara
@kodaxx
Mar 31 2016 05:33
Sure @mattxgreen I'll message you as to not crowd this room - but it's not too big really
Matt Green
@mattxgreen
Mar 31 2016 05:33
k
Markus Kiili
@Masd925
Mar 31 2016 05:33
@mattxgreen You have to check if the first element is an array and then shift it and steamroll it if needed.
Matt Green
@mattxgreen
Mar 31 2016 05:34
@Masd925 I think I got it
@Masd925 maybe not
Markus Kiili
@Masd925
Mar 31 2016 05:36
@mattxgreen There are a couple of pitfalls to avoid.
Matt Green
@mattxgreen
Mar 31 2016 05:41
seems like I need 2 args for the function
Markus Kiili
@Masd925
Mar 31 2016 05:43
@mattxgreen No.
Spencer Kuzara
@kodaxx
Mar 31 2016 05:44
Thanks @mattxgreen you're a genius! I mean it :smile: :clap:
CamperBot
@camperbot
Mar 31 2016 05:44
kodaxx sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:star: 425 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
Markus Kiili
@Masd925
Mar 31 2016 05:45
@kodaxx There are no geniuses here. Some just have thinner skull.
Matt Green
@mattxgreen
Mar 31 2016 05:47
@Masd925 Can you translate that?
:p
Markus Kiili
@Masd925
Mar 31 2016 05:48
@mattxgreen A polite way of saying that some have thicker skull.
Matt Green
@mattxgreen
Mar 31 2016 05:48
I see...
Elbert Cortez
@trip16661
Mar 31 2016 05:51
Guys
what am i missing ?
function destroyer(arr) {


    arr[0].filter(function(the){
          the !== arr[1];       
    });




  // Remove all the values
  return arr ;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Markus Kiili
@Masd925
Mar 31 2016 05:52
@trip16661 The only parameter arr only catches the first argument [1, 2, 3, 1, 2, 3]. You need arguments object for the extra arguments.
Elbert Cortez
@trip16661
Mar 31 2016 05:53
am i not saying that in the arr[1 ?
or mby im confused? cuz i saw on the webpage that arguments can be treated kind of the same way that arrays
Markus Kiili
@Masd925
Mar 31 2016 05:55
@trip16661 arguments[0] is the same as arr. arguments[1] is 2 etc.
Elbert Cortez
@trip16661
Mar 31 2016 05:56
oh so i have to specifically note "arguments"
i thought it was sort of a blueprint
Markus Kiili
@Masd925
Mar 31 2016 05:57
@trip16661 It is a special object inside every function.
Elbert Cortez
@trip16661
Mar 31 2016 06:00
it says can not read property '0' of undefined
Matt Green
@mattxgreen
Mar 31 2016 06:00
@trip16661 did you type-o it like @Masd925
Elbert Cortez
@trip16661
Mar 31 2016 06:01
yes
Matt Green
@mattxgreen
Mar 31 2016 06:01
hehe
Reza Farshbaf
@grfarshbaf
Mar 31 2016 06:01
I am stuck with Chunky Monkey
Markus Kiili
@Masd925
Mar 31 2016 06:02
@trip16661 Post your code please.
Matt Green
@mattxgreen
Mar 31 2016 06:02
@Masd925 he said he type-o'd it... that should be the source of the prob
arguements[0] --> arguments[0]
Elbert Cortez
@trip16661
Mar 31 2016 06:03
function destroyer(arr) {


    arr.arguments[0].filter(function(the){
          the === arr.arguments[1];       
    });




  // Remove all the values
  return arr ;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
like this
Markus Kiili
@Masd925
Mar 31 2016 06:04
@trip16661 It should be arr = arr.filter(... or return arr.filter(...
Elbert Cortez
@trip16661
Mar 31 2016 06:05
it anyways runs an error
Markus Kiili
@Masd925
Mar 31 2016 06:05
@trip16661 There is no arr.arguments[i]. Just arguments[i]
Matt Green
@mattxgreen
Mar 31 2016 06:06
and you need to return in your .filter
Markus Kiili
@Masd925
Mar 31 2016 06:06
@trip16661 The filter callback function has its own arguments object. You have to store destroyers arguments on a variable in order to use it inside another function.
Elbert Cortez
@trip16661
Mar 31 2016 06:11
like
function destroyer(arr) {

    var argumentOne = arguments[1];
    arr = arguments[0].filter(function(the){
          the === argumentOne;       
    });




  // Remove all the values
  return arr ;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Markus Kiili
@Masd925
Mar 31 2016 06:14
@trip16661 You should store arguments first with var args=arguments; and then loop the arguments (from args) inside the filter callback. That way it will work on any number of passed arguments.
Matt Green
@mattxgreen
Mar 31 2016 06:14
I think this is what you need: return (the !== argumentOne);
Elbert Cortez
@trip16661
Mar 31 2016 06:16
i thought of that before but for some strange reason it said that you can not loop inside of a function or something D:
Markus Kiili
@Masd925
Mar 31 2016 06:20
@trip16661 You can loop inside a function, but declaring function inside a loop might not be good.
Elbert Cortez
@trip16661
Mar 31 2016 06:26
function destroyer(arr) {

    var args = arguments;

  arr = args[0].filter(function(the){
          for (a = 1; a < args.length;a++){}
      return the !== args[a]; 

    });




  // Remove all the values
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
i feel so close but so far away xDD
it return the arrray as nothing happen
Matt Green
@mattxgreen
Mar 31 2016 06:26
@Masd925 Thanks for the help... I gotta get to bed, you wanna give me that one-liner before I do?
CamperBot
@camperbot
Mar 31 2016 06:26
mattxgreen sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1258 | @masd925 | http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Mar 31 2016 06:29
@mattxgreen
function steamroller(arr) {
  return arr.length ? (Array.isArray(arr[0]) ? steamroller(arr.shift()) : [arr.shift()]).concat(steamroller(arr)) : [];
}
Matt Green
@mattxgreen
Mar 31 2016 06:29
I dunno if a double ternary counts as a one liner ;)
I'll look at it tomorrow, g'night
Abdulmalik Ibrahim
@melik19
Mar 31 2016 06:45
a should be assigned to b with =
Elbert Cortez
@trip16661
Mar 31 2016 06:47
function destroyer(arr) {

    var args = arguments;

  arr = args[0].filter(function(the){
          for (a = 1; a < args.length;a++){
      return the !== args[a]; 
      }
    });




  // Remove all the values
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
I have no idea how to return more than one value it's only destrying the 2 since the loop stops after the return D:
Abdulmalik Ibrahim
@melik19
Mar 31 2016 06:47
blob
V1ad1m1r
@V1ad1m1r
Mar 31 2016 06:48
js
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line

  result= "The " + myAdjective + myNoun + myVerb + myAdverb;
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("cat ", "little ", "hit ", "slowly");
why is the function working, but the task not showing complete?
Elbert Cortez
@trip16661
Mar 31 2016 06:48
asign the a to b
so the things inside of a to b
Abdulmalik Ibrahim
@melik19
Mar 31 2016 06:49
i did
var a = b;
doesnt work
Elbert Cortez
@trip16661
Mar 31 2016 06:50
a = b (you are asigning the things inside of b to a)
not the other way
read the instruction carrefully
kirbyedy
@kirbyedy
Mar 31 2016 06:50
@V1ad1m1r it is not correct, you need spaces between
Elbert Cortez
@trip16661
Mar 31 2016 06:51
and remember to leave spaces on =
V1ad1m1r
@V1ad1m1r
Mar 31 2016 06:51
@kirbyedy there are spaces in each of the strings... do I need a specific variable for a space?
kirbyedy
@kirbyedy
Mar 31 2016 06:51
no just the " "
V1ad1m1r
@V1ad1m1r
Mar 31 2016 06:52
i see. it took it . Thanks mate!!!
Markus Kiili
@Masd925
Mar 31 2016 06:52
@trip16661 You can return false if you find a match with the and args[i], but you can return true only after you have checked all the args and no match is found.
Elbert Cortez
@trip16661
Mar 31 2016 06:54
not sure if i got it D:
I'm really sorry being this dumb you are such a nice person for keep explaining it to me D:
I feel bad D:
Markus Kiili
@Masd925
Mar 31 2016 06:58
@trip16661 No need to feel bad. You will crack it.
Elbert Cortez
@trip16661
Mar 31 2016 07:00
I don't understand what you said before returning false if i find a match ?
Markus Kiili
@Masd925
Mar 31 2016 07:01
@trip16661 Inside the callback you are checking if the arr element (the) is the same as any args[i]. If you find a match (the===args[i]), you tell filter to remove that element by returning false. After you have checked all the args, you can return true (after the loop).
Elbert Cortez
@trip16661
Mar 31 2016 07:03
how can i make it false? it will return true and it will keep that argument
Markus Kiili
@Masd925
Mar 31 2016 07:04
@trip16661 if (the===args[a]) return false;
Elbert Cortez
@trip16661
Mar 31 2016 07:05
oh it worked
Markus Kiili
@Masd925
Mar 31 2016 07:06
@trip16661 Nice!
Elbert Cortez
@trip16661
Mar 31 2016 07:06
but why it worked? if that statement return true doesn't mean that it should return that value only?
applying filter rules?
Markus Kiili
@Masd925
Mar 31 2016 07:07
@trip16661 It will reach return true only if there is no return false made in the loop. That happens if there is no equivalent argument to the arr element the.
Elbert Cortez
@trip16661
Mar 31 2016 07:09
@Masd925 thanks a lot man
CamperBot
@camperbot
Mar 31 2016 07:09
trip16661 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1259 | @masd925 | http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Mar 31 2016 07:09
@trip16661 You're wellcome.
Zach
@Moose1551
Mar 31 2016 07:17
Am I anywhere near being correct for the "Record Collection" challenge?
function update(id, prop, value) {
if (value !== "" && prop !== "tracks") {
  return (value === prop);
} else if (prop === "tracks" && value !== "") {
  return tracks.push(value);
} else if (value === "") {
  delete collection.prop;
}

  return collection;
}
Markus Kiili
@Masd925
Mar 31 2016 07:19
@Moose1551 You first have to figure out how to access one specific record with the given id.
Jayanth Kanive
@jkanive
Mar 31 2016 07:22
Hi, has anyone solved the “Exact Change” problem ?
MichaelTsang
@MichaelTsang
Mar 31 2016 07:25
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
i am stuck
kirbyedy
@kirbyedy
Mar 31 2016 07:25
you have the symbols on the left in the table, just apply them @MichaelTsang
new line is \n... and so on
MichaelTsang
@MichaelTsang
Mar 31 2016 07:27
var myStr="\n"; it's not working the console shows var myStr="\n";
kirbyedy
@kirbyedy
Mar 31 2016 07:27
you have to do all the signs
backslash tab tab carriage-return new-line
in that order
Jackson Bates
@JacksonBates
Mar 31 2016 07:28
@Moose1551 I struggled with that one - trying a few approaches with bracket
kirbyedy
@kirbyedy
Mar 31 2016 07:28
all of them
MichaelTsang
@MichaelTsang
Mar 31 2016 07:29
yeah
Jackson Bates
@JacksonBates
Mar 31 2016 07:29
@Moose1551 oops, sent too soon :) -- using some bracket notation helped me figure it out
MichaelTsang
@MichaelTsang
Mar 31 2016 07:29
thank u
helpful
Jayanth Kanive
@jkanive
Mar 31 2016 07:34
for some reason “Exact Change” problem is not accepting my solution even though it is giving the right answer
has anyone faced this issue ?
Markus Kiili
@Masd925
Mar 31 2016 07:35
@jkanive Post the code please.
Jayanth Kanive
@jkanive
Mar 31 2016 07:36
its really long
Markus Kiili
@Masd925
Mar 31 2016 07:36
@jkanive No problem.
Jackson Bates
@JacksonBates
Mar 31 2016 07:37
@Moose1551 also, look again at how you accessed the glove box contents in a previous problem - the solution for accessing properties a couple of layers deep is in there...
Jayanth Kanive
@jkanive
Mar 31 2016 07:38
var logging = false;

function logData(str){
    if (logging){
        console.log(str);
    }
}

var cRegister = {
    total : 0,
    register : {
        HUNDRED : 0,
        TWENTY : 0,
        TEN : 0,
        FIVE : 0,
        ONE : 0,
        QUARTER : 0,
        DIME : 0,
        NICKEL : 0,
        PENNY : 0,
        status : "",    
    },
    change :{
        HUNDRED : 0,
        TWENTY : 0,
        TEN : 0,
        FIVE : 0,
        ONE : 0,
        QUARTER : 0,
        DIME : 0,
        NICKEL : 0,
        PENNY : 0,    
    },
    setTotal : function(){
        register.forEach(function(a){
            total = Number((total + a[1]).toFixed(2));
        });
    },
    removeCash : function(arr){    
        logData("removeCash " + arr[0] + " " + arr[1]);
        this.register[arr[0]] = Number((this.register[arr[0]] - arr[1]).toFixed(2));
        this.total = Number((this.total - arr[1]).toFixed(2));
        this.change[arr[0]]   = Number((this.change[arr[0]] + arr[1]).toFixed(2));
        if(this.total === 0){
            this.register.status = "Closed";
        }
        if(arr[1] === "PENNY" && this.register.PENNY < 0 ){
            this.register.status = "Insufficient Funds";
        }  
        logData(JSON.stringify(this.change));    
    },
    setRegistry : function(arr){
        logData(JSON.stringify(this.register));
        //this.total = 1;
        logData(this.total);
        for (var i = 0; i < arr.length; i++) {
            this.total = Number((this.total+arr[i][1]).toFixed(2));
            if(arr[i][0] === "ONE HUNDRED"){
                this.register.HUNDRED = arr[i][1];
            }else{
                this.register[arr[i][0]]=arr[i][1];
            }
        }

        if(this.total > 0){
            this.register.status = "Open";
        }else if(total === 0){
            this.register.status = "Closed";    
        }
        logData(JSON.stringify(this.register));
        logData(this.total);
    },
    buildCArray : function(){
        var cArray = [];
        var curr = Object.keys(this.change);
        for (var i = 0; i < curr.length; i++) { 
            if(curr[i] === "HUNDRED"){
                if(this.change.HUNDRED > 0){
                    cArray.push(["ONE HUNDRED",Number(this.change.HUNDRED.toFixed(2))]);
                }
            }else{
                if(this.change[curr[i]] > 0){
                cArray.push([curr[i], Number(this.change[curr[i]].toFixed(2))]);
            }
            }

        }
        return cArray;
    },
    getChange : function(price, cash){
        var cValue = cash - price;
        logData("cValue : " + cValue);
        while(cValue > 0){
            //logData(cValue);
            if (cValue >= 100 && this.register.HUNDRED > 0){
                this.removeCash(["HUNDRED",100]);
                cValue = Number((cValue - 100).toFixed(2));
            }else
                if (cValue >= 20 && this.register.TWENTY > 0){
                this.removeCash(["TWENTY",20]);
                cValue = Number((cValue - 20).toFixed(2));
            }else
                if (cValue >= 10 && this.register.TEN > 0) {
                this.removeCash(["TEN",10]);
                cValue = Number((cValue - 10).toFixed(2));
            }else
                if (cValue >= 5 && this.register.FIVE > 0) {
                this.removeCash(["FIVE",5]);
                cValue = Number((cValue - 5).toFixed(2));
            }else
                if (cValue >= 1 && this.register.ONE > 0){
                this.removeCash(["ONE",1]);
                cValue = Number((cValue - 1).toFixed(2));
            }else
                if (cValue >= 0.25 && this.register.QUARTER > 0){
                logData("QUARTER" + cValue);
                this.removeCash(["QUARTER",0.25]);
                cValue = Number((cValue - 0.25).toFixed(2));
            }else
                if (cValue >= 0.10 && this.register.DIME > 0){
                this.removeCash(["DIME",0.10]);
                cValue = Number((cValue - 0.10).toFixed(2));
            }else
                if (cValue >= 0.05 && this.register.NICKEL > 0){
                this.removeCash(["NICKEL",0.05]);
                cValue = Number((cValue - 0.05).toFixed(2));
            }else    
                if (cValue >= 0.01 && this.register.PENNY > 0){
                this.removeCash(["PENNY",0.01]);
                cValue = Number((cValue - 0.01).toFixed(2));
                }


            if(this.register.status === "Closed" || this.register.status === "Insufficient Funds" ){    
              if(this.register.status === "Closed" && cValue > 0){
                    this.register.status = "Insufficient Funds";
                }
                break;
            }    
        }
        return ((this.register.status === "Closed" || this.register.status === "Insufficient Funds")? this.register.status : this.buildCArray());
    }
};


function checkCashRegister(price, cash, cid) {

  logData(cid);
  cRegister.setRegistry(cid);
  //logData(cRegister.getChange(price, cash));
  return cRegister.getChange(price, cash);

}
checkCashRegister(19.50, 20.00, [["PENNY", 0.50], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]);
Markus Kiili
@Masd925
Mar 31 2016 07:40
@jkanive Variables need to be declared inside functions, so FCC can test properly.
Vinayak Savadi
@Winayak
Mar 31 2016 07:40

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()
{
var gear;

this.getGear = function(gear)
{
return gear;
};
this.setGear = function(gear)
{
return this.gear ;
}; // Only change code below this

};

var myCar = new Car();

var myBike = new Bike();

Jayanth Kanive
@jkanive
Mar 31 2016 07:41
@Masd925 what do you mean ?
Vinayak Savadi
@Winayak
Mar 31 2016 07:41
i have stuck in challenge of making object properties private can anyone help me to get out from this?
Jayanth Kanive
@jkanive
Mar 31 2016 07:41
this has never been an issue in the past problems @Masd925
Markus Kiili
@Masd925
Mar 31 2016 07:42
@jkanive var logging is global. If it is used on calculations, that is a problem on FCC.
Jayanth Kanive
@jkanive
Mar 31 2016 07:42
hmmm interesting...
what about var cRegister
function logData(str){
  var logging = false;
    if (logging){
        console.log(str);
    }
}
it is still having issues
should I take care of
var cRegister
Markus Kiili
@Masd925
Mar 31 2016 07:45
@jkanive That is a problem too. Try to stuff all variables inside the main function.
Coy Sanders
@coymeetsworld
Mar 31 2016 07:45
@Winayak your setGear function needs fixing
you're not returning the gear, you're setting it (as the function name implies)
MichaelTsang
@MichaelTsang
Mar 31 2016 07:52
You should be using bracket notation to read the value from myArray
how
Map : Access MultiDimensional Arrays With Indexes
MichaelTsang
@MichaelTsang
Mar 31 2016 08:02
anybody help..
myData should be equal to 8.
You should be using bracket notation to read the value from myArray.
step 1 is OK
but i don't know how to solve step 2
Codemzy
@codemzy
Mar 31 2016 08:03
@MichaelTsang can you post your code?
MichaelTsang
@MichaelTsang
Mar 31 2016 08:08

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

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

Jayanth Kanive
@jkanive
Mar 31 2016 08:09
@Masd925 Thanks… you are right about the variable declaration
CamperBot
@camperbot
Mar 31 2016 08:09
jkanive sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1260 | @masd925 | http://www.freecodecamp.com/masd925
Jayanth Kanive
@jkanive
Mar 31 2016 08:09
I was able to close that problem with some minor changes...
Thanks once again @Masd925
CamperBot
@camperbot
Mar 31 2016 08:09
jkanive sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: jkanive already gave masd925 points
Codemzy
@codemzy
Mar 31 2016 08:10
@MichaelTsang you need to select 8 from the existing array... so you see myArray is an array of arrays... so first look at the array that contains 8... its the third array in... so myArray[2]
Danilo
@sennator
Mar 31 2016 08:10

function myTest(val) {
var answer = "";
// Only change code below this line
switch (answer){
case "a":
answer ="apple";
break;
case "b":
answer ="bird";
break;
case "c":
answer ="cat";
break;
default:
answer ="stuff";
}
// Only change code above this line
return answer;
}

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

Codemzy
@codemzy
Mar 31 2016 08:11
@MichaelTsang then look where 8 is in that array... its the second number in that third... array... which you would get with [1] (because arrays start at 0)... so if you put that together...
myArray[2][1] would select the number 8
Danilo
@sennator
Mar 31 2016 08:11
why isn't it working?
MichaelTsang
@MichaelTsang
Mar 31 2016 08:11
helpful
:D
Codemzy
@codemzy
Mar 31 2016 08:11
@MichaelTsang :thumbsup:
@sennator switch (answer) you need to be doing the switch on val not on answer
Coy Sanders
@coymeetsworld
Mar 31 2016 08:12
@sennator i think first you need to switch on val, not answer
and second need to change the value in myTest, since 1 will go straight to default
Danilo
@sennator
Mar 31 2016 08:14
still not working :)
MichaelTsang
@MichaelTsang
Mar 31 2016 08:14
@codemzy BTW your personal page is awesome, like it so much
Coy Sanders
@coymeetsworld
Mar 31 2016 08:14
what part is not working?
Codemzy
@codemzy
Mar 31 2016 08:15
@MichaelTsang oh thanks!! I only just finished that this week! Thanks for the feedback :thumbsup:
CamperBot
@camperbot
Mar 31 2016 08:15
codemzy sends brownie points to @michaeltsang :sparkles: :thumbsup: :sparkles:
:star: 173 | @michaeltsang | http://www.freecodecamp.com/michaeltsang
Danilo
@sennator
Mar 31 2016 08:15
@coymeetsworld myTest("a") should have a value of "apple"
myTest("b") should have a value of "bird"
myTest("c") should have a value of "cat"
myTest("d") should have a value of "stuff"
myTest(4) should have a value of "stuff"
Coy Sanders
@coymeetsworld
Mar 31 2016 08:16
which fail? also can you post your code after the changes?
Danilo
@sennator
Mar 31 2016 08:17
all failed :D

function myTest(val) {
var answer = "";
// Only change code below this line
switch (val){
case "a":
val ="apple";
break;
case "b":
val ="bird";
break;
case "c":
val ="cat";
break;
default:
val ="stuff";
}
// Only change code above this line
return answer;
}

// Change this value to test
myTest("a");

MichaelTsang
@MichaelTsang
Mar 31 2016 08:18
return val not answer
Coy Sanders
@coymeetsworld
Mar 31 2016 08:18
ok just in the switch statement you were supposed to replace answer with val
dkennell
@dkennell
Mar 31 2016 08:18
How's it going, fam. I'm working on the Seek and Destroy challenge, I'm a bit stuck. Any suggestions?
function filterArgs(array) {
  for (i = 1; i < args.length; i++) {
    if (array.indexOf(args[i]) !== -1) {
      return false;
    }
    else {return true;}
  }
}

function destroyer(arr) {
  // Remove all the values
  args = arguments;
  return arr.filter(filterArgs);
}


destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Danilo
@sennator
Mar 31 2016 08:19
@MichaelTsang @coymeetsworld thanks guys
CamperBot
@camperbot
Mar 31 2016 08:19
sennator sends brownie points to @michaeltsang and @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 429 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
:star: 175 | @michaeltsang | http://www.freecodecamp.com/michaeltsang
MichaelTsang
@MichaelTsang
Mar 31 2016 08:19
@sennator var answer = ""; change to var val="" and change return answer; to eturn val;
Coy Sanders
@coymeetsworld
Mar 31 2016 08:19
you could do it that way, but then you wouldn't use the answer variable @MichaelTsang @sennator
no @MichaelTsang that won't work :)
you should only modify answer, not val
if you modify val and then switch on it then you'll never get what you want
Francisco Franco
@frenktico
Mar 31 2016 08:36

guys simple doubt here:

/* Na linha 2, declare uma variavel myName e atribua a ela seu nome.*/
var myName ="Francisco";
/* Na linha 4, use console.log para exibir a variavel myName.*/
console.log(myName);
/* Na linha 7, mude o valor de myName para ser apenas as primeiras 2 letras do seu nome.*/
"myName".substring(0,2);
/* Na linha 9, use console.log para exibir a variável myName.*/
console.log(myName);

The code is correctly returning myName on the first formula/function but on the second one I should be able to have as a result on the first and the second letter of my Name. Where did I miss something?

Niko Salonen
@nikosalonen
Mar 31 2016 08:40
"myName".substring(0,2);
"myName" is a string
Francisco Franco
@frenktico
Mar 31 2016 08:41
:/
I still don't see where exactly, you mean on the 4th line of code?
@nikosalonen without quotes it does return the full nume instead of the first two letters which is what I'm looking forward.
The substring() method returns a subset of a string between one index and another, or through the end of the string.
MichaelTsang
@MichaelTsang
Mar 31 2016 08:43
@dkennell hey , here's a solution may help

function destroyer(arr) {
var args = Array.prototype.slice.call(arguments);
args.splice(0,1);
return arr.filter(function(element) {
return args.indexOf(element) === -1;
});
}

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

Niko Salonen
@nikosalonen
Mar 31 2016 08:44
so you have to assign it
MichaelTsang
@MichaelTsang
Mar 31 2016 08:44
@dkennell The first line will turn the arguments variable into a full array instead of the limited array it currently it.
Next I remove the first argument since I don't need, since I only want the other arguments passed besides the first which is the array we are going to compare against.
The use the filter() to filter out the elements that are on the array and keep the ones that are not.
@dkennell if u don't understand these func , u can google for help
Francisco Franco
@frenktico
Mar 31 2016 08:46
Thank you @nikosalonen
I have updated the last line to be console.log(myName.substring(0,2));
I'm still not aware of how the javascript language reads what we are writing but I'll get used to. Thanks again!
CamperBot
@camperbot
Mar 31 2016 08:46
frenktico sends brownie points to @nikosalonen :sparkles: :thumbsup: :sparkles:
:star: 383 | @nikosalonen | http://www.freecodecamp.com/nikosalonen
dkennell
@dkennell
Mar 31 2016 08:52
@MichaelTsang Okay, I'm googling. Thanks, Mike
CamperBot
@camperbot
Mar 31 2016 08:52
dkennell sends brownie points to @michaeltsang :sparkles: :thumbsup: :sparkles:
:star: 178 | @michaeltsang | http://www.freecodecamp.com/michaeltsang
dkennell
@dkennell
Mar 31 2016 08:56
@MichaelTsang Okay, I've actually read a lot about .prototype, and I don't understand it at all. What does Array.prototype.slice.call do?
@MichaelTsang I've tried to understand it many times before.
MichaelTsang
@MichaelTsang
Mar 31 2016 08:59
seperate some arg has length property into array
@dkennell
This message was deleted

var a={length:2,0:'first',1:'second'};
Array.prototype.slice.call(a);// ["first", "second"]

var a={length:2};
Array.prototype.slice.call(a);// [undefined, undefined]

dkennell
@dkennell
Mar 31 2016 09:01
This message was deleted
@MichaelTsang Oh, interesting.
@MichaelTsang So, .slice cuts it up into pieces for the array... what does .call do?
MichaelTsang
@MichaelTsang
Mar 31 2016 09:03
so , the default array can seperate into [1, 2, 3, 1, 2, 3] and 2 and 3
dkennell
@dkennell
Mar 31 2016 09:05
Okay, but I still don't understand how we can use .call on a if a is not a function.
MichaelTsang
@MichaelTsang
Mar 31 2016 09:06
call means it uses the args from parent func , destroyer(arr) arr is what we need
something like "this" ..
i can't descrip well..
dkennell
@dkennell
Mar 31 2016 09:10
Okay, I think I understand
Don't worry, you're explaining very well. :)
You're from China?
MichaelTsang
@MichaelTsang
Mar 31 2016 09:11
yeah
dkennell
@dkennell
Mar 31 2016 09:11
Cool, I live in Hangzhou
MichaelTsang
@MichaelTsang
Mar 31 2016 09:12
@dkennell wow , welcome to China ~ have fun with us
:D
dkennell
@dkennell
Mar 31 2016 09:13
Thanks, I will! :smile:
Hsin Chih Wang
@hsinwang5
Mar 31 2016 09:14
@dkennell From what I understand, for example Array.prototype.slice.call([1, 2, 3, 4], 1, 3) is just a generic way to call [1, 2, 3, 4].slice(1, 3)
Markus Kiili
@Masd925
Mar 31 2016 09:35
@hsinwang5 Calling methods from the prototype is sometimes safer, because properties can be overwritten. With these array literals there is no difference.
Hsin Chih Wang
@hsinwang5
Mar 31 2016 09:40
@Masd925 I don't understand what you mean, can you give me an example of how a property would be overwritten by a function invocation?
Markus Kiili
@Masd925
Mar 31 2016 09:41
@dkennell With .call() you can call array methods on an array-like objects that have .length and small enough numeric keys ('0', '1' etc).
Hsin Chih Wang
@hsinwang5
Mar 31 2016 09:41
@Masd925 that wouldn't be overwritten if you used call?
Markus Kiili
@Masd925
Mar 31 2016 09:42
@hsinwang5 I wasn't talking about overwriting. Just using call.
@hsinwang5 Here is an example:
var arr = [1,2,3,4,5];
arr.slice(1,3); // [2,3]
arr.slice=console.log;
arr.slice(1,3); prints"1 3", returns undefined. Doesn't work anymore
Array.prototype.slice.call(arr,1,3); // [2,3] .  Works
MichaelTsang
@MichaelTsang
Mar 31 2016 09:50
@Masd925 interesting , learn a lot
Hsin Chih Wang
@hsinwang5
Mar 31 2016 09:51
what is arr.slice=console.log doing? It assigns a new function to arr's slice() method? or just undefined?
@Masd925
Markus Kiili
@Masd925
Mar 31 2016 09:51
@hsinwang5 Assings console.log function to arr objects .slice property.
@hsinwang5 So slicing on arr is no longer working and you must call it from the Array prototype.
Hsin Chih Wang
@hsinwang5
Mar 31 2016 09:53
ok makes sense
Markus Kiili
@Masd925
Mar 31 2016 09:54
@hsinwang5 That is more of a problem with objects than arrays. There calling form Object.prototype is often used.
Gamal Anwer
@GamalAnwer
Mar 31 2016 09:54
hey guys quick question
in escape sequnce in string
var myStr = " \b \t \t \r \n "; // Change this line
is not working
any idea?
" \ \t \t \r \n "
kirbyedy
@kirbyedy
Mar 31 2016 09:56
@GamalAnwer did you follow the request from the task ?
MichaelTsang
@MichaelTsang
Mar 31 2016 09:56
@GamalAnwer backslash tab tab carriage-return new-line
Gamal Anwer
@GamalAnwer
Mar 31 2016 09:56
yes
Hsin Chih Wang
@hsinwang5
Mar 31 2016 09:56
thanks @Masd925
CamperBot
@camperbot
Mar 31 2016 09:56
hsinwang5 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1261 | @masd925 | http://www.freecodecamp.com/masd925
Gamal Anwer
@GamalAnwer
Mar 31 2016 09:57
@MichaelTsang im i missing smth?
kirbyedy
@kirbyedy
Mar 31 2016 09:57
@GamalAnwer backslash
the first one is not correct
MichaelTsang
@MichaelTsang
Mar 31 2016 09:57
backslash is \ not \b
Gamal Anwer
@GamalAnwer
Mar 31 2016 09:57
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr @kirbyedy
MichaelTsang
@MichaelTsang
Mar 31 2016 09:57
double \
Gamal Anwer
@GamalAnwer
Mar 31 2016 09:57
var myStr = " \ \t \t \r \n "; // Change this line
kirbyedy
@kirbyedy
Mar 31 2016 09:57
1 more \ at the start
Gamal Anwer
@GamalAnwer
Mar 31 2016 09:58
im writing it here but not showing
kirbyedy
@kirbyedy
Mar 31 2016 09:58
you have to escape the \ with a \ :D
so \ and ... no spaces between
Gamal Anwer
@GamalAnwer
Mar 31 2016 09:58
yes i did that
kirbyedy
@kirbyedy
Mar 31 2016 09:59
This message was deleted
var myStr = "\\ \t \t \r \n";
Gamal Anwer
@GamalAnwer
Mar 31 2016 09:59
how to insert code here?
kirbyedy
@kirbyedy
Mar 31 2016 10:00
` your code
and again `
Gamal Anwer
@GamalAnwer
Mar 31 2016 10:00
' var myStr = " \ \t \t \r \n "; // Change this line '
Mithlesh Upadhyay
@csegate2
Mar 31 2016 10:00
function destroyer(arr) {
  var args = Array.prototype.slice.call(arguments);
  args.splice(0,1);
  return arr.filter(function(element) {
    return args.indexOf(element) === -1;
  });
}
Can you explain this code in comment , please?
MichaelTsang
@MichaelTsang
Mar 31 2016 10:01
i just post it several minutes ago..
Mithlesh Upadhyay
@csegate2
Mar 31 2016 10:01
I choose this room to sleep, here!
kirbyedy
@kirbyedy
Mar 31 2016 10:01
@GamalAnwer not the ' you have to use ` ...the tick... somewhere left on your keyboard where the number 1 is
MichaelTsang
@MichaelTsang
Mar 31 2016 10:02
@csegate2 The first line will turn the arguments variable into a full array instead of the limited array it currently it.
Next I remove the first argument since I don't need, since I only want the other arguments passed besides the first which is the array we are going to compare against.
The use the filter() to filter out the elements that are on the array and keep the ones that are not.
Gamal Anwer
@GamalAnwer
Mar 31 2016 10:02
smth is wrong with me
MichaelTsang
@MichaelTsang
Mar 31 2016 10:02
@csegate2 from github , not my stuff , you can reference it
Gamal Anwer
@GamalAnwer
Mar 31 2016 10:02
thanks @kirbyedy @MichaelTsang
CamperBot
@camperbot
Mar 31 2016 10:02
gamalanwer sends brownie points to @kirbyedy and @michaeltsang :sparkles: :thumbsup: :sparkles:
kirbyedy
@kirbyedy
Mar 31 2016 10:02
@GamalAnwer no its not, just be patient :)
CamperBot
@camperbot
Mar 31 2016 10:02
:star: 188 | @michaeltsang | http://www.freecodecamp.com/michaeltsang
:star: 779 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
Gamal Anwer
@GamalAnwer
Mar 31 2016 10:03
what i did wrong was putting a space before the \
kirbyedy
@kirbyedy
Mar 31 2016 10:04
:)
Markus Kiili
@Masd925
Mar 31 2016 10:05
@MichaelTsang Array.prototype.slice.call(arguments,1) would do the same without needing to splice.
MichaelTsang
@MichaelTsang
Mar 31 2016 10:06
@Masd925 oh , means u could put anything there?
Markus Kiili
@Masd925
Mar 31 2016 10:07
@MichaelTsang By putting the ,1 there, it ignores the first argument.
MichaelTsang
@MichaelTsang
Mar 31 2016 10:08
@Masd925 but Array.prototype.slice.call(arguments,1) this func needs an array, what does ,1 do
Markus Kiili
@Masd925
Mar 31 2016 10:11
@MichaelTsang I mean that
var args = Array.prototype.slice.call(arguments);
  args.splice(0,1);
does the same as
var args = Array.prototype.slice.call(arguments,1);
Danilo
@sennator
Mar 31 2016 10:12
how do you put your code in console
?
on chat
Codemzy
@codemzy
Mar 31 2016 10:12
wiki format
CamperBot
@camperbot
Mar 31 2016 10:12

: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

Codemzy
@codemzy
Mar 31 2016 10:12
@sennator :point_up_2: