These are chat archives for FreeCodeCamp/HelpJavaScript

29th
Feb 2016
Blauelf
@Blauelf
Feb 29 2016 00:00
@matthew3454 This code for each of the four subarrays (the number of subarrays is somewhat hardcoded in the initialization of largest) stores a number that is supposed to be the largest number of that subarray so far, initially set to 0. Then it loops through the array, and for each subarray compares one element after the other with the so-far largest for that subarray, if found larger, replacing it.
bitgrower
@bitgrower
Feb 29 2016 00:00
an array can be composed of anything ... it can contain numbers, strings, objects, arrays ... whatever it contains, the addressing INTO that element of an array is basically how you would address it if it wasn't a member of an array ...
alpox
@alpox
Feb 29 2016 00:01
I'm out
Cya guys
bitgrower
@bitgrower
Feb 29 2016 00:01
cya @alpox
Paul Brown
@paulbwd
Feb 29 2016 00:01
@DavOnGit well yeah.. lol
Davide
@DavOnGit
Feb 29 2016 00:03
@paulbwd :+1:
96street
@96street
Feb 29 2016 00:06
@bitgrower i'm abit confused, firstly how do I iterate through the sub arrays?
Paul Brown
@paulbwd
Feb 29 2016 00:06
I dont think the AJAX section on here is freecodecamps finest hour tho, first of all there was very little explanations and the challenges before the quote machine were simply a copy and paste in job.. then they say right go off and build this quote machine, with no help at all, so i had to spend the day looking at online tutorials but its been fun to complete.
96street
@96street
Feb 29 2016 00:06
function largestOfFour(arr) {

  largest = [0, 0, 0, 0];



  return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
I know a for loop is required but not sure what to do
bitgrower
@bitgrower
Feb 29 2016 00:07
@96street -- with a for loop
demipixel
@demipixel
Feb 29 2016 00:07
@bitgrower :clap:
Paul Brown
@paulbwd
Feb 29 2016 00:07
@same way you u iterate through any array (think nested)
DavH27
@DavH27
Feb 29 2016 00:07
thanks for the useful tool on that link, @bitgrower
CamperBot
@camperbot
Feb 29 2016 00:07
davh27 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 660 | @bitgrower | http://www.freecodecamp.com/bitgrower
Blauelf
@Blauelf
Feb 29 2016 00:08
@96street There is a challenge for accessing subarrays you might have completed: http://www.freecodecamp.com/challenges/nesting-for-loops
Norman Dela Cruz
@dcnr
Feb 29 2016 00:08
@96street if you understood this http://www.freecodecamp.com/challenges/nesting-for-loops then you could easily solve that
Blauelf
@Blauelf
Feb 29 2016 00:08
lol @dcnr :D
Norman Dela Cruz
@dcnr
Feb 29 2016 00:08
lol @Blauelf
woah
lool
96street
@96street
Feb 29 2016 00:09
will have a look
Norman Dela Cruz
@dcnr
Feb 29 2016 00:09
@bitgrower heya, still stick sick?
Davide
@DavOnGit
Feb 29 2016 00:10
@paulbwd wikipedia api for me was a nightmare, i hate their documentation :warning:
96street
@96street
Feb 29 2016 00:10
so do I need to set the array as a variable so i can refer to it? like: arr = [[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]];
so then i can do: ( i = 0; i < arr.length: arr++)
Paul Brown
@paulbwd
Feb 29 2016 00:11
I know im kind of dreading these next few .. I hope they get easier @DavOnGit lol
96street
@96street
Feb 29 2016 00:11
( i = 0; i < arr.length: i++)**
?
Ovelny
@Ovelny
Feb 29 2016 00:12
@96street No, you can just iterate through the original array, which is arr.
Norman Dela Cruz
@dcnr
Feb 29 2016 00:12
@paulbwd if it gets easier, you're doing it wrong! :D
Ovelny
@Ovelny
Feb 29 2016 00:13
No need to set another variable with the same array.
96street
@96street
Feb 29 2016 00:13
oh shit ok @Ovelny
can someone explain this thouroughly? this my main problem:
for (var i=0; i < arr.length; i++) {
  for (var j=0; j < arr[i].length; j++) {
    console.log(arr[i][j]);
  }
}
Jacob Schumer
@jacobschumer
Feb 29 2016 00:14
I feel ashamed of how I completed the palindrome test
96street
@96street
Feb 29 2016 00:14
so the variable i is iterating through the sub arrays?
and j through the objects of each sub-array?
Blauelf
@Blauelf
Feb 29 2016 00:15
@96street Your outer loop iterates over the array. arr[i] are the individual subarrays.
Ovelny
@Ovelny
Feb 29 2016 00:15
@96street Eaxctly
Jacob Schumer
@jacobschumer
Feb 29 2016 00:15
I basically ended up trading between var copy1 and var copy2 removing special characters with the .replace method
Ovelny
@Ovelny
Feb 29 2016 00:15
*Exactly
I had a hard time to understand that first too :)
bitgrower
@bitgrower
Feb 29 2016 00:15
LOL @jacobschumer -- I wouldn't worry about it too much -- as you learn, you can ALWAYS go back and revise your answers, you know ...
:point_up: February 28, 2016 3:58 PM @96street
Marek Slabicki
@thaniri
Feb 29 2016 00:17
can anyone nudge me in the right direction here? i've run into an infinite loop
function mutation(arr) {

  var q = arr[0].split(""); //[h,e,l,l,o]
  var r = arr[1].split(""); //[h,e,y]

  if (q.length > r.length){
    for(i = 0; i < q.length; i++){ // 5 times
      for(i = 0; i < r.length; i++){ // 3 times

      }
    }
  }


  return "hi";
}

mutation(["hello", "hey"]);
//compare arr0 to arr1 three times. Pass h over the array, then pass e over the array, then y.
bitgrower
@bitgrower
Feb 29 2016 00:17
@thaniri -- if you use indexOf you can probably eliminate one of your loops :)
Norman Dela Cruz
@dcnr
Feb 29 2016 00:18
@thaniri you only need to see if all of arr[1] is in arr[0] right? So you only really need one loop! You can use the Array.indexOf function to loop up each of your arr[1] characters in arr[0] :D
96street
@96street
Feb 29 2016 00:18
j < arr[i].length : can some just sum this code up? I kind of know what it does but wanna hear it clearly
matthew3454
@matthew3454
Feb 29 2016 00:18
@Blauelf I appreciate your help. And, I'm still pretty clueless , but it makes a little more sense now. Thanks
CamperBot
@camperbot
Feb 29 2016 00:18
matthew3454 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: matthew3454 already gave blauelf points
bitgrower
@bitgrower
Feb 29 2016 00:19

@96street -- have you tried seeing how the code operates in the pythontutor.com/javascript.html animations ?

Programmers just have words, which may or may not be precise & perfect -- but when you see what the code is actually doing, it is better than a 1000 programmer words ... go back and forth between the concepts & the animations ...

Norman Dela Cruz
@dcnr
Feb 29 2016 00:19
@96street arr[i] is your sub-array so it means "while j is less than the length of the sub-array"
Ovelny
@Ovelny
Feb 29 2016 00:20
@bitgrower That's a cool tool btw, thank you ! Will bookmark that.
CamperBot
@camperbot
Feb 29 2016 00:20
ovelny sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 661 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 29 2016 00:21
yeah, that's a real find, @Ovelny -- thanks
96street
@96street
Feb 29 2016 00:21
yeah @bitgrower. @Ovelny ok so it iterates the length of the sub-array, but when does it actually log the highest number?
bitgrower
@bitgrower
Feb 29 2016 00:23

j < arr[i].length

j is an index that is being incremented to point to the actual elements in the subarray ... arr[i] is pointing to ONE particular element in the first array "dimension" ...

arr[i].length is "how many elements are in the subarray located in the 1st array at position i"

@96street ... you have to do a comparison ... so, if you start, you initialize your largest variable to 0 ... because you are going to compare each element of each subarray to that number ...
96street
@96street
Feb 29 2016 00:27
i know that arr[i].length is how many elements in the chosen subarray - and that the largest number is 0 to begin with - but which bit of code actually identifies the biggest number?
j < arr[i].length is just iterating through the sub array but not choosing the biggest number
Norman Dela Cruz
@dcnr
Feb 29 2016 00:28
@96street it's not there yet, you've yet to code it
bitgrower
@bitgrower
Feb 29 2016 00:29
if (largest > ??? )
largest = ???;
96street
@96street
Feb 29 2016 00:29
oh that makes sense
does that code go in the for loop? or outside?]
bitgrower
@bitgrower
Feb 29 2016 00:31
@96street -- stop panicking, take a deep breath and THINK ABOUT IT ....
tia
@tvdeleon24
Feb 29 2016 00:31
hey guys need some help with "counting cards"

this is my code so far: var count = 0;

function cc(card) {
// Only change code below this line
if (card=>2 || card<=6); {
count=+1;
return "5 Bet";
}
// Only change code above this line
}

96street
@96street
Feb 29 2016 00:33
isn't it: if(i > largest) largest =i; ?
@bitgrower
not the other way around
bitgrower
@bitgrower
Feb 29 2016 00:33
what does i represent, @96street ?
adamboyer
@adamboyer
Feb 29 2016 00:33
@moigithub lol I just read your message, I would not have the patience for that!
Norman Dela Cruz
@dcnr
Feb 29 2016 00:33
thanks @bitgrower
CamperBot
@camperbot
Feb 29 2016 00:33
dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 662 | @bitgrower | http://www.freecodecamp.com/bitgrower
96street
@96street
Feb 29 2016 00:33
j imean
j = the objects in the sub-array
if(j > largest) largest = j; ?
bitgrower
@bitgrower
Feb 29 2016 00:34
okay ... you need to understand a bit more about variables, the content of the variables, and how variables address the content ...
myArray = [] -- now points to a place in memory ...
myArray[i] -- means nothing, because "i" has no value atm (in my little scenario here)
96street
@96street
Feb 29 2016 00:35
isn't j the numbers inside the sub-arrays?
ok keep going
bitgrower
@bitgrower
Feb 29 2016 00:35
you're getting ahead of the story, @96street :)
:()
96street
@96street
Feb 29 2016 00:36
yep im following you
bitgrower
@bitgrower
Feb 29 2016 00:36
so ... let's say for grins, the interpreter names the location 0 in memory myArray (it almost never would, but that's a completely different story for a completely different time) ...
96street
@96street
Feb 29 2016 00:37
grins?
bitgrower
@bitgrower
Feb 29 2016 00:37
if I have numbers ... they are going to be allocated 1 byte per number...
@96street -- for sake of argument ...
96street
@96street
Feb 29 2016 00:37
i don't know what that means
byte?
bitgrower
@bitgrower
Feb 29 2016 00:38
byte ?
you don't know what a byte is ?
96street
@96street
Feb 29 2016 00:38
i'm a beginner at javascript, no
bitgrower
@bitgrower
Feb 29 2016 00:38
@96street --- STOP ... STOP whatever you are doing -- and go watch the videos in FCC at the bottom of the map ...
without them, you don't have the background for this to make sense to you ... especially if you don't know what a byte is ...
96street
@96street
Feb 29 2016 00:39
which videos? And do i need to know this to code javascript?
bitgrower
@bitgrower
Feb 29 2016 00:40
yes ... this is basic computer background you need to know ...
without it, you won't have the foundation necessary ...
96street
@96street
Feb 29 2016 00:40
ok wheres the vid?
Paul Brown
@paulbwd
Feb 29 2016 00:41
this weather app challenge is going to be fun :)
bitgrower
@bitgrower
Feb 29 2016 00:41
go to http://freecodecamp.com/96street and click on "map" ... a sidebar will show up on the left ... scroll down until you see something that says "Video Challenges" ... that's where the video challenges are ...
96street
@96street
Feb 29 2016 00:43
but i've just been going through the course in order, wouldn't they of put those videos earlier if they wanted us to learn it before these javascript exercises?
bitgrower
@bitgrower
Feb 29 2016 00:45

@96street -- people come from a variety of backgrounds ... there are LOTS of resources here on FCC ... and I don't know of anyone who hasn't gone outside of what's available on FCC to complete the challenges ... that's why they say "read, research, ask" ... part of the "game" is learning how to find the information you need ...

...so, based on your level of knowledge, I'm letting you know exactly where you can find the information you need right now to help you move foward ...

specifically, you want the "Computer basics" video challenges ...
Rami
@RNwebdk
Feb 29 2016 00:50
What is the syntax error on line 17 guys ? i better rest after this
// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line

var gloveBoxContents = "glove box"; // Change this line
myStorage.car.inside[gloveBoxContents];
last line
bitgrower
@bitgrower
Feb 29 2016 00:52
well ... what are you doing with the last line ?
Tyler Moeller
@TylerMoeller
Feb 29 2016 00:52
@RNwebdk set the last line to a variable, then return the variable.
bitgrower
@bitgrower
Feb 29 2016 00:52
would it make sense to have a variable in there ?
Tyler Moeller
@TylerMoeller
Feb 29 2016 00:53
^^
IrishAlex
@IrishAlex
Feb 29 2016 00:54
@RNwebdk how do you copy and paste your code like this with the background? or is it just a screenshot?
Rami
@RNwebdk
Feb 29 2016 00:54
this is not a function, sorry if i wasn't clear, i'm trying to get the "glove box" in my object on line 17
Tyler Moeller
@TylerMoeller
Feb 29 2016 00:54
help format
CamperBot
@camperbot
Feb 29 2016 00:54

:point_right: code formatting [wiki]

Inline code

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

Code Block

```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 ⏎]

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

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

Rami
@RNwebdk
Feb 29 2016 00:54
@IrishAlex was about to tell you, but camperbot is so awesome
Tyler Moeller
@TylerMoeller
Feb 29 2016 00:55
lol :)
bitgrower
@bitgrower
Feb 29 2016 00:55
thanks @camperbot
CamperBot
@camperbot
Feb 29 2016 00:55
bitgrower sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star: 1279 | @camperbot | http://www.freecodecamp.com/camperbot
Rami
@RNwebdk
Feb 29 2016 00:56
I get Error on line 17 saying "Expected an assignment or function call and insted saw an expression
bitgrower
@bitgrower
Feb 29 2016 00:56
@RNwebdk -- that's why it helps to paste in the entire piece of code ... :)
Mike Sakata
@mgsakata
Feb 29 2016 00:57
@RNwebdk what are you trying to do with the glove box contents?
bitgrower
@bitgrower
Feb 29 2016 00:57
@RNwebdk -- that error totally makes sense ... and it tells you EXACTLY the problem ... your expression creates an address in memory, but then does nothing with it ...
Rami
@RNwebdk
Feb 29 2016 00:57
@bitgrower it is all the code m8
Mike Sakata
@mgsakata
Feb 29 2016 00:57
@RNwebdk which challenge is this?
Tyler Moeller
@TylerMoeller
Feb 29 2016 00:57
@RNwebdk I think you want to do something like this:
var gloveBoxContents = "glove box"; // Change this line
var result = myStorage.car.inside[gloveBoxContents];
return result;
Rami
@RNwebdk
Feb 29 2016 00:57
challenge name is Accessing Nested Objects in JSON
Mike Sakata
@mgsakata
Feb 29 2016 00:58
@RNwebdk or you can shorten it to return myStorage.car.inside[gloveBoxContents];
Brian
@sludge256
Feb 29 2016 00:58
fairly certain that challenge checks the value of the variable
not what's returned
bitgrower
@bitgrower
Feb 29 2016 00:58
yeah, there is no return statement ...
Mike Sakata
@mgsakata
Feb 29 2016 00:58
@RNwebdk yeah there is no return.
Tyler Moeller
@TylerMoeller
Feb 29 2016 00:59
should have written \\ do something with result
Mike Sakata
@mgsakata
Feb 29 2016 00:59
@RNwebdk you set gloveBoxContents to the value in the object.
bitgrower
@bitgrower
Feb 29 2016 00:59
you are VERY close to a solution @RNwebdk
Mike Sakata
@mgsakata
Feb 29 2016 01:00
@RNwebdk yeah, just think about how you would access the value in the "glove box" and you are assigning that to the gloveBoxContents variable.
bitgrower
@bitgrower
Feb 29 2016 01:00

instructions/test case 1: "gloveBoxContents should equal "maps"

So, you need to set the variable gloveBoxContents to the address in the expression on troublesome line ...

IrishAlex
@IrishAlex
Feb 29 2016 01:00

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

// Only change code below this line
function update(id, prop, value) {
delete collection.id2.type1;

return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");

woops
Mike Sakata
@mgsakata
Feb 29 2016 01:00
lol
Tyler Moeller
@TylerMoeller
Feb 29 2016 01:01
so close :)
IrishAlex
@IrishAlex
Feb 29 2016 01:01
haha im retarded
Tyler Moeller
@TylerMoeller
Feb 29 2016 01:01
hint: you can edit your comment
CamperBot
@camperbot
Feb 29 2016 01:01
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
bitgrower
@bitgrower
Feb 29 2016 01:01
we all have the opportunity to feel retarded -- it's part of programming ...
96street
@96street
Feb 29 2016 01:01
@bitgrower thanks. i'm having a look at the video challenges now and they see helpful
CamperBot
@camperbot
Feb 29 2016 01:01
96street sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 663 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 29 2016 01:02
awesome ... :)
IrishAlex
@IrishAlex
Feb 29 2016 01:02
so i just need tags around my code for it to paste?
<>?
bitgrower
@bitgrower
Feb 29 2016 01:03
well ... if you call js & tags ...
ugh ...
no ... not those kind ...
explain format
CamperBot
@camperbot
Feb 29 2016 01:03

:point_right: code formatting [wiki]

Inline code

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

Code Block

```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 ⏎]

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

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

bitgrower
@bitgrower
Feb 29 2016 01:03
that way, like @camperbot says ... @IrishAlex
Norman Dela Cruz
@dcnr
Feb 29 2016 01:04
@IrishAlex
Try typing it out like this:
```js (shift+enter)(paste code)(enter)
IrishAlex
@IrishAlex
Feb 29 2016 01:05
This message was deleted
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) {
  delete collection.id[2].type[1];


  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
ah nice one!
@dcnr @bitgrower @camperbot cheers
bitgrower
@bitgrower
Feb 29 2016 01:07
which challenge is this ?
IrishAlex
@IrishAlex
Feb 29 2016 01:07
Now could someone tell me what exactly I've done wrong here?
its challenge 220 record collection
Norman Dela Cruz
@dcnr
Feb 29 2016 01:07
@IrishAlex cheeers! :beer:
bitgrower
@bitgrower
Feb 29 2016 01:08
@IrishAlex -- the number is your brownie points ... so just refer to challenges by name ... :)
IrishAlex
@IrishAlex
Feb 29 2016 01:08
The last part of the question....."if the value is blank delete that prop"
I chose the second last ID since it had no value and tried to delete it. Maybe I don't fully understand the question/what is being asked.
Anyone help a guy out? I don't wanna look at the solution you have up :)
bitgrower
@bitgrower
Feb 29 2016 01:10
yeah ... just looking at the problem, my solution, what you are trying to do ... :)
Moisés Man
@moigithub
Feb 29 2016 01:10
u missing the if instruction part where u specify the condition
bitgrower
@bitgrower
Feb 29 2016 01:10
so you have the rest of checks done, @IrishAlex ?
freeman-g
@freeman-g
Feb 29 2016 01:11
Anybody know if there is a bug with the Exact Change challenge? I think I'm passing the tests, but they are showing as failed.
bitgrower
@bitgrower
Feb 29 2016 01:11
...it helps to see what you've been successful with ...
@freeman-g -- are you comparing the results using console.log to what the test case says is the result ?
freeman-g
@freeman-g
Feb 29 2016 01:12
I ran the tests in the console window and looked at the result on the left hand side under the help button
Moisés Man
@moigithub
Feb 29 2016 01:12
also.. id[2] is wrong id is not an array.. but a variable/argument @IrishAlex
IrishAlex
@IrishAlex
Feb 29 2016 01:12
I Understand that it's an if question but what I don't understand is the last part of the question...."if the value is blank then delete that prop"......I'm trying to delete that property...problem solved surely? lol
bitgrower
@bitgrower
Feb 29 2016 01:12
you need to address the property correctly in order to delete it ...
Mike Sakata
@mgsakata
Feb 29 2016 01:13
@freeman-g I completed that yesterday and there didn't seem to be any bugs
bitgrower
@bitgrower
Feb 29 2016 01:13
id is a variable ... .and I don't see what type is ?
Mike Sakata
@mgsakata
Feb 29 2016 01:13
@freeman-g which test case is failing?
IrishAlex
@IrishAlex
Feb 29 2016 01:13
But if the id's values are the numbers associated with the albums then why wont it set it as that value?
Norman Dela Cruz
@dcnr
Feb 29 2016 01:14
@IrishAlex
var myObj = {
  thePropertyName: "the Value";
};
  • Using . you are directly using the property name itself
    var result = myObj.thePropertyName; // the Value
  • Using [] there are two ways:
    1. Directly access by quoting the property name:
      var result = myObj["thePropertyName"]; // the Value
    2. Using a variable as property name by not quoting
      var prop = "thePropertyName";
      var result = myObj[prop]; // the Value
      here prop is the variable that holds the name of your object property
IrishAlex
@IrishAlex
Feb 29 2016 01:14
id's are 2458,2468 correct no?
bitgrower
@bitgrower
Feb 29 2016 01:14
@IrishAlex -- have you successfully done the other parts of the challenge, or are you working on this part first ?
freeman-g
@freeman-g
Feb 29 2016 01:15
Almost all the tests are failing. For example the tests for Insufficient Funds are failing but the output shows Insufficient Funds.
bitgrower
@bitgrower
Feb 29 2016 01:15
break it down ... create an expression, set it to a variable, and look at it with console.log ...
Jacob Schumer
@jacobschumer
Feb 29 2016 01:15
is there a way to use the .replace method with a variable parameter?
Rami
@RNwebdk
Feb 29 2016 01:16
thanks for the help @mgsakata @sludge256 @bitgrower @TylerMoeller
CamperBot
@camperbot
Feb 29 2016 01:16
rnwebdk sends brownie points to @mgsakata and @sludge256 and @bitgrower and @tylermoeller :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Feb 29 2016 01:16
@jacobschumer -- that's not a very specific question ...
CamperBot
@camperbot
Feb 29 2016 01:16
:star: 379 | @tylermoeller | http://www.freecodecamp.com/tylermoeller
:star: 1702 | @sludge256 | http://www.freecodecamp.com/sludge256
:star: 664 | @bitgrower | http://www.freecodecamp.com/bitgrower
:star: 320 | @mgsakata | http://www.freecodecamp.com/mgsakata
bitgrower
@bitgrower
Feb 29 2016 01:16
you're welcome @RNwebdk ...
Mike Sakata
@mgsakata
Feb 29 2016 01:16
@freeman-g could you paste your code in here and share the link that is generated when its saved? Then I can take a look and see what's happening.
freeman-g
@freeman-g
Feb 29 2016 01:16
Here's my solution with a call that should produce insufficient funds...but the tests are still failing
Mike Sakata
@mgsakata
Feb 29 2016 01:16
Rami
@RNwebdk
Feb 29 2016 01:16
i really need some sleep now. it was a stupid error, that means sleep
Jacob Schumer
@jacobschumer
Feb 29 2016 01:16
basically I want to do string.replace( x, y), but of course it literally searches for x and replaces it with 7 @bitgrower
y*
bitgrower
@bitgrower
Feb 29 2016 01:16
@jacobschumer -- you may want to visit the mozilla developer network page on .reduce -- look at the examples ...
freeman-g
@freeman-g
Feb 29 2016 01:17
var units = [
  ["PENNY", 0.01],
  ["NICKEL", 0.05],
  ["DIME", 0.10],
  ["QUARTER", 0.25],
  ["ONE", 1.00],
  ["FIVE", 5.00],
  ["TEN", 10.00],
  ["TWENTY", 20],
  ["ONE HUNDRED", 100.00]
];
var change = {};

function drawer(price, cash, cid) {

  var changeAmount = cash - price;

  var change = getChange(cash - price, cid);

  if (insufficientFunds(changeAmount, change)) {
    return "Insufficient Funds";
  }

  return formatChange(change);
}

function formatChange(change) {
  var changeArr = [];
  for (i = 8; i >= 0; i--) {
    var unit = units[i][0];
    if (change[unit]) {
      changeArr.push([unit,change[unit]]);
    }
  }

  return changeArr;

}

function getChange(amount, cid) {

  for (i = 8; i >= 0; i--) {

    var unitAmount = units[i][1];
    var cidAmount = cid[i][1];
    var key = cid[i][0];
    var changeAmount = change[key];

    if (unitAmount <= amount && cidAmount > 0) {
      amount = (amount -= unitAmount).toPrecision(12);
      if (changeAmount) {
        change[key] += unitAmount;
      } else {
        change[key] = unitAmount;
      }
      cid[i][1] -= unitAmount;
      getChange(amount, cid);
    }

  }

  return change;

}

function isEmpty(cid) {

  for (i = 0; i < cid.length; i++) {
    if (cid[i][1] > 0) {
      return false;
    }
  }
  return true;
}

function insufficientFunds(changeAmount, change) {

  var sum = 0;
  for (var key in change) {
    if (change.hasOwnProperty(key)) {
      sum += change[key];
    }
  }

  if (sum < changeAmount) {
    return true;
  } else {
    return false;
  }
}

drawer(19.50, 20.00, [["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1.00], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]);
the above call produces "Insufficient Funds" in the output bar, but the tests still fail
Norman Dela Cruz
@dcnr
Feb 29 2016 01:18
@freeman-g don't use global variables with FCC editor/tester
IrishAlex
@IrishAlex
Feb 29 2016 01:18
@bitgrower I'll get back to ya in half an hour when I figure it out :)
freeman-g
@freeman-g
Feb 29 2016 01:18
So I have to solve this without Global Variables?
bitgrower
@bitgrower
Feb 29 2016 01:18
first, @jacobschumer , remember that if you are using string.replace, you need to use a variable assignment to capture the results, as strings cannot be changed "in place" ... (like, say, arrays can)... but I really reommend you check out the MDN page on .reduce ... look at the examples ... review the previous challenges which have used .reduce, etc ...
Mike Sakata
@mgsakata
Feb 29 2016 01:20
@freeman-g you can solve it with a Global Variable for the units, but you shouldn't need it where you are using change = {};
@freeman-g
i get the correct Insufficient funds for the sample drawer you included.
freeman-g
@freeman-g
Feb 29 2016 01:20
It's b/c I recursively populate change and didn't really want the caller to have send an empty change object
Rami
@RNwebdk
Feb 29 2016 01:21
So is freeCodeCamp gonna have some PHP challenges in the future ?
bitgrower
@bitgrower
Feb 29 2016 01:21
doesn't seem too likely @RNwebdk ...
freeman-g
@freeman-g
Feb 29 2016 01:21
Should I see if the tests will pass without the global vars?
Mike Sakata
@mgsakata
Feb 29 2016 01:21
@freeman-g One issue might be that you have a "change" global variable, then are also using it in function scope occassionally.
I mean as an agurment
argument
freeman-g
@freeman-g
Feb 29 2016 01:23
yeah, I just noticed that
Norman Dela Cruz
@dcnr
Feb 29 2016 01:23
@freeman-g it's just that using vars outside your functions in the FCC editor/test borks the other tests, you might pass one but not the rest
freeman-g
@freeman-g
Feb 29 2016 01:23
ok, I will refactor it...thanks
Jacob Schumer
@jacobschumer
Feb 29 2016 01:23
@bitgrower I'm totally lost...I'm trying to do the capitalize each first letter challenge. Here's what I want to do, and I can't make sense of a way for .reduce to help me from the MDN page:
function titleCase(str) {
  var splArray = str.split(" ");
 for (var i = 0; i <  splArray.length; i++){
    var cool = splArray[i].charAt(0).toUpperCase();
    splArray[i].replace(.charAt(0), cool);
  }
  return splArray;
}
Rami
@RNwebdk
Feb 29 2016 01:24
@bitgrower it's just that i love the examples here on freecodecamp, it's much better then Codeacademy, makes you think and solve and learn faster...
Norman Dela Cruz
@dcnr
Feb 29 2016 01:25
@jacobschumer .charAt needs to be attached to a string where it will be getting it's char :P
@jacobschumer "hello".charAt(0); // h
Mike Sakata
@mgsakata
Feb 29 2016 01:26
@bitgrower you don't necessarily need the methods they suggest
@bitgrower but you could use something like map or forEach to loop through an array without needing a "for" loop
freeman-g
@freeman-g
Feb 29 2016 01:27
@dcnr and @mgsakata getting rid of the global change object solved my problem...thanks!
CamperBot
@camperbot
Feb 29 2016 01:27
freeman-g sends brownie points to @dcnr and @mgsakata :sparkles: :thumbsup: :sparkles:
:star: 321 | @mgsakata | http://www.freecodecamp.com/mgsakata
Mike Sakata
@mgsakata
Feb 29 2016 01:27
@bitgrower your splArray[i].replace(.charAt(0), cool); has a .charAt(0) not being called on anything
CamperBot
@camperbot
Feb 29 2016 01:27
:star: 744 | @dcnr | http://www.freecodecamp.com/dcnr
Jacob Schumer
@jacobschumer
Feb 29 2016 01:28
@dcnr thanks...I think I'm just screwed re this strategy
CamperBot
@camperbot
Feb 29 2016 01:28
jacobschumer sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 745 | @dcnr | http://www.freecodecamp.com/dcnr
Jacob Schumer
@jacobschumer
Feb 29 2016 01:28
@mgsakata yeah, I'm to replace the character at 0 regardless of what it is and can't figure out how to do that.
Mike Sakata
@mgsakata
Feb 29 2016 01:29
oh @bitgrower sorry i keep replying to the wrong person. Lol.
@jacobschumer you can try something simple like taking the capitalized character and then appending the rest of the string starting from index 1
Norman Dela Cruz
@dcnr
Feb 29 2016 01:31

@jacobschumer you can also access string characters through bracket notation

var word = "hello";
word = word[0].toUpperCase();

word is now H

Mike Sakata
@mgsakata
Feb 29 2016 01:32
@dcnr good point. I always forget that one.
Jacob Schumer
@jacobschumer
Feb 29 2016 01:32
@dcnr wow I forgot lol...thanks
CamperBot
@camperbot
Feb 29 2016 01:32
jacobschumer sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:warning: jacobschumer already gave dcnr points
Norman Dela Cruz
@dcnr
Feb 29 2016 01:32
@mgsakata yeah I don't find much use for it too
@jacobschumer but it's one of the ways to do this exercise :D
@jacobschumer just remember to get the rest of the word
Mike Sakata
@mgsakata
Feb 29 2016 01:33
@dcnr only issue is that it only returns the single upper case value. He still needs the rest fo the word
Norman Dela Cruz
@dcnr
Feb 29 2016 01:33
yeah
Jacob Schumer
@jacobschumer
Feb 29 2016 01:33
oh yeah I was getting the single upper case value before through the charat method
so I'll just have to append it to the rest
Tyler Moeller
@TylerMoeller
Feb 29 2016 01:34
when would msg be different than data in this call?
$.ajax({url: url})
  .done(function(msg) {
  console.log(msg);
})
  .fail(function(err) {
  console.log(err);
})
  .always(function(data) {
  console.log(data);
});
Mike Sakata
@mgsakata
Feb 29 2016 01:35
@TylerMoeller not sure what you mean?
@TylerMoeller you are specifying the argument in each of the callbacks, so essentially you could call them anything
Tyler Moeller
@TylerMoeller
Feb 29 2016 01:35
from what I understand, .done() happens when the request to the URL is complete (success). .always() happens after an error, so they are the same. I think...
and if so...why use .done()?
Mike Sakata
@mgsakata
Feb 29 2016 01:37
@TylerMoeller always, as it implies always gets run. So if there is an error, the data argument you specified would be the same as the err argument in the fail callback
@TylerMoeller you don't necessarily need the done callback either. You could handle both a successful and error case in always.
from the jQuery docs for ajax.
Tyler Moeller
@TylerMoeller
Feb 29 2016 01:38
@mgsakata ahhh, so console.log(data) would have both the success and error in it?
Mike Sakata
@mgsakata
Feb 29 2016 01:38
n response to a successful request, the function's arguments are the same as those of .done(): data, textStatus, and the jqXHR object. For failed requests the arguments are the same as those of .fail(): the jqXHR object, textStatus, and errorThrown. Refer to deferred.always() for implementation details.
@TylerMoeller yes. Depending on the result of the ajax call
it would be the success data or the error data.
Tyler Moeller
@TylerMoeller
Feb 29 2016 01:39
@mgsakata right, okay. it can't be evaluated twice. Either success or error
Thanks @mgsakata that helps clear it up
CamperBot
@camperbot
Feb 29 2016 01:39
tylermoeller sends brownie points to @mgsakata :sparkles: :thumbsup: :sparkles:
:star: 322 | @mgsakata | http://www.freecodecamp.com/mgsakata
Mike Sakata
@mgsakata
Feb 29 2016 01:40
@TylerMoeller No problem.
Was wondering if anyone had any feedback on my solution for the permutations with repeating characters challenge? Here is a link with comments. https://jsfiddle.net/L1tm09xv/. And another without comments cluttering things. https://jsfiddle.net/fene2vgy/
apklip
@apklip
Feb 29 2016 01:44
What am I doing wrong for the counting cards lesson?

var count = 0;

function cc(card) {
// Only change code below this line
if (card >= 2 && card <= 6) {
count = 1;
return card + ' ' + 'Bet';
} else if (card >= 7 && card <= 9) {
count = 0;
return card + ' ' + 'Hold';
} else {
count = -1;
return card + ' ' + 'Hold';
}

return count;
// 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');

Norman Dela Cruz
@dcnr
Feb 29 2016 01:45
@DarkPigeons your first if statement count = 1 should be count += 1 and your else if I think, you just do nothing, instead of setting count to 0.
Mike Sakata
@mgsakata
Feb 29 2016 01:45
@DarkPigeons for one, you aren't updating the count value
yup, like @dcnr says
Norman Dela Cruz
@dcnr
Feb 29 2016 01:46
@DarkPigeons your else too should be count -= 1 instead of setting it to -1
apklip
@apklip
Feb 29 2016 01:46
I was doing that before. I decided to try that instead.
I changed it back and it still doesn't work.
Mike Sakata
@mgsakata
Feb 29 2016 01:47
@DarkPigeons also the result should include the count value as opposed to the card
Norman Dela Cruz
@dcnr
Feb 29 2016 01:48
oh yeah nice catch @mgsakata
apklip
@apklip
Feb 29 2016 01:48
@mgsakata which result? the last one or the conditional ones?
Norman Dela Cruz
@dcnr
Feb 29 2016 01:50
@DarkPigeons you're supposed to return count instead of card in your return strings
apklip
@apklip
Feb 29 2016 01:50
All of them?
Mike Sakata
@mgsakata
Feb 29 2016 01:50
yeah
apklip
@apklip
Feb 29 2016 01:51
The example output says different
"5 Bet"
"-3 Hold"
Mike Sakata
@mgsakata
Feb 29 2016 01:51
also you don't need ' ' + 'Hold'; you could just do +' Hold';
apklip
@apklip
Feb 29 2016 01:51
Ill try it though
@mgsakata Yeah, I had a var there before. nice catch, but not really required for the problem.
Mike Sakata
@mgsakata
Feb 29 2016 01:52
@DarkPigeons what do you mean the output says different? I'm confused. The number in the example output is the count
apklip
@apklip
Feb 29 2016 01:53
@mgsakata @dcnr Sorry guys, I just realized what I was doing wrong. Thanks for the help.
CamperBot
@camperbot
Feb 29 2016 01:53
darkpigeons sends brownie points to @mgsakata and @dcnr :sparkles: :thumbsup: :sparkles:
:star: 323 | @mgsakata | http://www.freecodecamp.com/mgsakata
:star: 746 | @dcnr | http://www.freecodecamp.com/dcnr
apklip
@apklip
Feb 29 2016 01:53
I thought the count var was limited to 1, 0, -1
Norman Dela Cruz
@dcnr
Feb 29 2016 01:53

@DarkPigeons yeah the instructions said to return count :D

The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
Example Output
"-3 Hold"
"5 Bet"

@DarkPigeons no prob, thanks too
CamperBot
@camperbot
Feb 29 2016 01:54
dcnr sends brownie points to @darkpigeons :sparkles: :thumbsup: :sparkles:
:star: 211 | @darkpigeons | http://www.freecodecamp.com/darkpigeons
apklip
@apklip
Feb 29 2016 01:54
Haha, thanks. I was just being really stupid for a few minutes.
Bye guys. :).
Norman Dela Cruz
@dcnr
Feb 29 2016 01:54
:ship:
Jacob
@SilentBrainiac
Feb 29 2016 02:06
Hi guys, can you help me, I can't understand why the following code doesn't work:
function largestOfFour(arr) {
return arr.reduce(function(finalArr, subArr){
return finalArr.push(Math.max.apply(null, subArr));
},[]);
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
if I use finalArr.concat(Math.max.apply(null, subArr)) it works fine
Moisés Man
@moigithub
Feb 29 2016 02:16
@SilentBrainiac u returning finalArr.pushinside ur callback
which in the next iteration.. whatever u return from callback will be stored on finalArr variable.. so next time.. finalArr will be 1
Mike Sakata
@mgsakata
Feb 29 2016 02:17
@SilentBrainiac why are you using reduce? If you are planning on returning the largest value in each array, as opposed to a sum?
Moisés Man
@moigithub
Feb 29 2016 02:17
if u check the documentation for Array.push method.. u will see what its returning.. (and its not an array )
@SilentBrainiac
J Lee
@SoYuMatic
Feb 29 2016 02:18
good day guys
I cheated and took a saturday off
lol
Norman Dela Cruz
@dcnr
Feb 29 2016 02:19
@SoYuMatic as long as you come back lol! :cake:
Nick Robson
@nickrobson
Feb 29 2016 02:23
@SilentBrainiac Consider using Array#map.
J Lee
@SoYuMatic
Feb 29 2016 02:25
what is the #map notation? I've never seen that before
Norman Dela Cruz
@dcnr
Feb 29 2016 02:26
@SilentBrainiac it's a good solution but return finalArr instead of the push :P
Jacob
@SilentBrainiac
Feb 29 2016 02:26
got it, thanks guys
Norman Dela Cruz
@dcnr
Feb 29 2016 02:28
@SoYuMatic I really don't know where it's from but I see it in javadocs and I think it's something like Class#method
Jacob
@SilentBrainiac
Feb 29 2016 02:28
I missed that push returns the new length of the array and not array itself
Norman Dela Cruz
@dcnr
Feb 29 2016 02:28
yeah thought of it too at first
Lindsay
@98Problems
Feb 29 2016 02:38
What part of the function does the inequality operator go in? I'm on the "comparison with the inequality operator" challenge and I don't understand where to put the !=
Norman Dela Cruz
@dcnr
Feb 29 2016 02:41
@98Problems != is used if you want to (loosely)^{(loosely)} compare if one is not equal to the other. For example 'a' != 'b' would be true. So you need to look for the values you want to compare.
Lindsay
@98Problems
Feb 29 2016 02:42
if (val) // change this line
I'm not sure how to use it with val
Norman Dela Cruz
@dcnr
Feb 29 2016 02:43
@98Problems then change that line, what are you supposed to compare val with? :D
use my example above
Lindsay
@98Problems
Feb 29 2016 02:43
Am I replacing val or adding to it?
Norman Dela Cruz
@dcnr
Feb 29 2016 02:44
@98Problems you are comparing val to something else, like my example above. I compared 'a' with 'b'.
'a' != 'b'
Lindsay
@98Problems
Feb 29 2016 02:44
okay, I get it. Thanks a lot!
Norman Dela Cruz
@dcnr
Feb 29 2016 02:44
awesome! :D
Jacob Schumer
@jacobschumer
Feb 29 2016 02:48
Anyone have any advice as to why this code doesn't allow for .shift?
function largestOfFour(arr) {
  var result = [];
  for (var i = 0; i < arr.length; i++){
    arr[i].sort(function (a,b){
      return b-a;
    }, []);
  }
  for (var j = 0; j< arr.length; j++){
    result.push(arr[i].shift());

  }
  return result;
}
The top half works but the second for loop is the issue.
Mike Sakata
@mgsakata
Feb 29 2016 02:50
@jacobschumer look at the iterator in the 2nd loop
Andrew Schmidthuber
@calicode
Feb 29 2016 02:50
do you want to be doing .push(arr[j] ?
Jacob Schumer
@jacobschumer
Feb 29 2016 02:51
...I'm a dumbastt
Thanks @calicode @mgsakata
CamperBot
@camperbot
Feb 29 2016 02:51
jacobschumer sends brownie points to @calicode and @mgsakata :sparkles: :thumbsup: :sparkles:
:star: 324 | @mgsakata | http://www.freecodecamp.com/mgsakata
:star: 342 | @calicode | http://www.freecodecamp.com/calicode
Mike Sakata
@mgsakata
Feb 29 2016 02:51
anyone else think the description of the conditions for Friendly Date Ranges is poorly written?
Norman Dela Cruz
@dcnr
Feb 29 2016 02:51
@jacobschumer what's the empty array for in your sort arguments?
Jacob Schumer
@jacobschumer
Feb 29 2016 02:52
@dcnr I don't remember...it might be a remnant from when I was trying something else?
Norman Dela Cruz
@dcnr
Feb 29 2016 02:53
@jacobschumer I think that's from a reduce:P You don't need that in a sort. I think it's ignored anyway
Jacob Schumer
@jacobschumer
Feb 29 2016 02:54
@dcnr oh yeah, I initially flattened the array because I thought they were asking for the highest number among the 4 arrays
Norman Dela Cruz
@dcnr
Feb 29 2016 02:55
@jacobschumer I see! It would look like what SilentBrainiac did just a few posts up :point_up:
novlem
@m3lv0n
Feb 29 2016 02:56
thanks @Rafase282 for your help with Checkpoint: Word Blanks
CamperBot
@camperbot
Feb 29 2016 02:56
m3lv0n sends brownie points to @rafase282 :sparkles: :thumbsup: :sparkles:
:star: 1016 | @rafase282 | http://www.freecodecamp.com/rafase282
Aldo Solorzano
@Aldosolorzano
Feb 29 2016 02:58

I'M STUCK HERE, HERE'S THE typeERROR: cannot set property 'artist' of undefined.
For the given id in collection:

If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop.

If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.

If value is blank, delete that prop.

Always return the entire collection object

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

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

else if(value === ""){

}
return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");

Kyle Roach
@iRoachie
Feb 29 2016 02:59
help format
CamperBot
@camperbot
Feb 29 2016 02:59

:point_right: code formatting [wiki]

Inline code

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

Code Block

```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 ⏎]

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

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

can anyone explain the difference between friendly(["2016-12-01", "2017-02-03"]) should return ["December 1st","February 3rd"]
Nick Robson
@nickrobson
Feb 29 2016 03:00
// Probably the simplest solution to Largest of Four
function largestOfFour(arr) {
   return arr.map(a => Math.max(...a));
}
Mike Sakata
@mgsakata
Feb 29 2016 03:00
and friendly(["2017-03-01", "2017-05-05"]) should return ["March 1st, 2017","May 5th"]
?
why the heck does the second test expect a year but not the 1st? or vice versa?
Nick Robson
@nickrobson
Feb 29 2016 03:01
@mgsakata The next December 1st is 2016, and the next March 1st is 2016 (not 2017!).
if it's the next one to occur, you shouldn't include the year, otherwise include it.
Mike Sakata
@mgsakata
Feb 29 2016 03:01
@nickrobson both are within 1 year of each other
Nick Robson
@nickrobson
Feb 29 2016 03:02
Yes, but when is the next March 1st date to occur?
Is it in 2016 or 2017?
The question is asking for the 2017 one, which is NOT the next March 1st to occur.
Mike Sakata
@mgsakata
Feb 29 2016 03:03
I'm confused. It's supposed to be a range. So March 1st to May 5th is self explanatory isn't it?
Nick Robson
@nickrobson
Feb 29 2016 03:03
No.
Because that implies March 1st, 2016 to May 5th, 2016
When it's clearly asking for 2017.
Mike Sakata
@mgsakata
Feb 29 2016 03:03
From the description.

Do not display information that is redundant or that can be inferred by the user: if the date range ends in less than a year from when it begins, do not display the ending year. If the range ends in the same month that it begins, do not display the ending year or month.

Additionally, if the date range begins in the current year and ends within one year, the year should not be displayed at the beginning of the friendly range.

Nick Robson
@nickrobson
Feb 29 2016 03:03
Yeah, that's exactly what I'm saying lol.
if the date range ends in less than a year from when it begins, do not display the >>>ending<<< year
Mike Sakata
@mgsakata
Feb 29 2016 03:04
But there is this part: Additionally, if the date range begins in the current year and ends within one year, the year should not be displayed at the beginning of the friendly range.
Nick Robson
@nickrobson
Feb 29 2016 03:04
You still need the starting year.
Yes, but March 1st, 2017 is NOT this year.
Mike Sakata
@mgsakata
Feb 29 2016 03:04
It specifically says don't include the year at the beginning of the date range
J Lee
@SoYuMatic
Feb 29 2016 03:05
challenge profile-lookup
Nick Robson
@nickrobson
Feb 29 2016 03:05
wiki profile
CamperBot
@camperbot
Feb 29 2016 03:05

:point_right: checkpoint profile lookup [wiki]

Checkpoint: Profile Lookup

Instructions

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

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

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

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

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

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

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

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

Nick Robson
@nickrobson
Feb 29 2016 03:05
@mgsakata You're skipping over the part where it says if the range starts in the CURRENT year.
Mike Sakata
@mgsakata
Feb 29 2016 03:05
@nickrobson AHhhhh now I see what you are saying. Damn grammar.
I was getting hung up on the year difference as opposed to what the starting year was in reference to this year.
Thanks @nickrobson
CamperBot
@camperbot
Feb 29 2016 03:06
mgsakata sends brownie points to @nickrobson :sparkles: :thumbsup: :sparkles:
:star: 410 | @nickrobson | http://www.freecodecamp.com/nickrobson
J Lee
@SoYuMatic
Feb 29 2016 03:06
on the profile lookup, how do I make the array read the prop argument from the same array as the firstName argument?
Nick Robson
@nickrobson
Feb 29 2016 03:07
No problem, @mgsakata .
@SoYuMatic You need to iterate through every element in the array and check their firstName property.
When you find a matching one, you'll be using that same object to get the property.
J Lee
@SoYuMatic
Feb 29 2016 03:08
so I do need to iterate! ok thanks
Nick Robson
@nickrobson
Feb 29 2016 03:08
Well, you can do it this way, but don't.
(code coming)
Norman Dela Cruz
@dcnr
Feb 29 2016 03:10
you can use find but it's terribly slow :(
Nick Robson
@nickrobson
Feb 29 2016 03:10
function lookup(contacts,  firstName, prop) {
   var c = contacts.find(a => a.firstName === firstName);
   return c ? c.hasOwnProperty(prop) ? c[prop] : "No such property" : "No such contact";
}
Don't do that, kids! ^
J Lee
@SoYuMatic
Feb 29 2016 03:11
but its so compact
and so much prettier than mine
well, let me get the solution first, then lets streamline the code afterwards!
Nick Robson
@nickrobson
Feb 29 2016 03:12
that ain't pretty ;-;
J Lee
@SoYuMatic
Feb 29 2016 03:13
are double ternaries frown upon?
or.. i dont even know what the => is
i see a=> used a lot but i have no idea
Norman Dela Cruz
@dcnr
Feb 29 2016 03:13

they're totally fine!

function update(id, prop, value) {
  return value
    ? prop === 'tracks'
        ? (collection[id].tracks.push(value), collection)
        : (collection[id][prop] = value, collection)
    : (delete collection[id][prop], collection);
}

it can be made readable somewhat

Mike Sakata
@mgsakata
Feb 29 2016 03:13
=> is ES6 for a function
function(a){} is the same as, a=>{}
Nick Robson
@nickrobson
Feb 29 2016 03:13
a => a.firstName === firstName
is shorthand for
function (a) { return a.firstName === firstName; }
perhaps you can see why it's used? xD
Mike Sakata
@mgsakata
Feb 29 2016 03:14
Its super handy for callbacks, since it doesn't require a return
Nick Robson
@nickrobson
Feb 29 2016 03:15
and for code minification
;)
J Lee
@SoYuMatic
Feb 29 2016 03:15
i just learned what a callback was yesterday lol
Norman Dela Cruz
@dcnr
Feb 29 2016 03:15
mind the lexically bound this though
J Lee
@SoYuMatic
Feb 29 2016 03:15
a function that is a parameter... right?
i also dunno what this is either
not specifically
Nick Robson
@nickrobson
Feb 29 2016 03:15
this refers to the object the JavaScript is currently being executed in
for example,
Array.prototype.showThis = function() {
   console.log(this);
};
[0,1,2].showThis(); // prints "[0, 1, 2]" to console
J Lee
@SoYuMatic
Feb 29 2016 03:17
so this has only local scope?
Nick Robson
@nickrobson
Feb 29 2016 03:17
Put it this way.
This message was deleted
This message was deleted
This message was deleted
that was wrong, sorry
J Lee
@SoYuMatic
Feb 29 2016 03:19
what isn't an object in JS besides values and parameters
Mike Sakata
@mgsakata
Feb 29 2016 03:19
parameters?
Nick Robson
@nickrobson
Feb 29 2016 03:19
functions aren't..
basically
in JS, everything is an object except for numbers, strings, booleans, null, undefined
arrays technically aren't, but they can behave like objects
Mike Sakata
@mgsakata
Feb 29 2016 03:20
yeah, parameters can be objects
arguments is also funky. Its like an array in that its iterable, but has no other array methods
Nick Robson
@nickrobson
Feb 29 2016 03:21
essentially, this refers to whatever object the function belongs to
J Lee
@SoYuMatic
Feb 29 2016 03:21
I like that definition
Nick Robson
@nickrobson
Feb 29 2016 03:21
Array.prototype.showThis = function() {
   console.log(this);
};
[0,1,2].showThis(); // prints "[0, 1, 2]" to console
[1,2,3].showThis(); // prints "[1, 2, 3]" to console
That hopefully helps..
J Lee
@SoYuMatic
Feb 29 2016 03:22
why do you put prototype in there?
u dont need it right?
Mike Sakata
@mgsakata
Feb 29 2016 03:22
not unless you want to add methods directly to Array or other objects
he was adding showThis function to all Arrays
J Lee
@SoYuMatic
Feb 29 2016 03:23
so whats the difference if you weren't to prototype the array?
how does the computer compute differently then?
Nick Robson
@nickrobson
Feb 29 2016 03:23
By using Array.prototype.showThis, it means I don't need to go:
var a = [0, 1, 2];
a.showThis = function() {
   console.log(this);
};
a.showThis();
var b = [1, 2, 3];
b.showThis = function() {
   console.log(this);
};
b.showThis();
See how much easier it is to do it the other way? :)
J Lee
@SoYuMatic
Feb 29 2016 03:24
o ok, so array.prototype is sort of a generic label in this case
Nick Robson
@nickrobson
Feb 29 2016 03:25
It means "add showThis to all arrays" (both ones that have already been made, and any that haven't been made yet)
Mike Sakata
@mgsakata
Feb 29 2016 03:26
Yep. You have to be careful with prototype that you don't accidentally overwrite any existing functions. Unless of course that's your purpose.
Nick Robson
@nickrobson
Feb 29 2016 03:26
Using prototype you can actually go:
var a = [0, 1, 2];
Array.prototype.showThis = function() {
   console.log(this);
};
a.showThis(); // still prints "[0, 1, 2]"
Some functions are commonly added.
For example, uniq.
Mike Sakata
@mgsakata
Feb 29 2016 03:27
Would be nice if they just added it into ES6
And also some union functions
J Lee
@SoYuMatic
Feb 29 2016 03:28
  var i=0;
  while(i < contacts.length){
      if(contacts[i][firstName] === firstName && contacts[i][prop] === prop){
        i++;
      return contacts[i][prop];
        }
doesn't that break my loop?
is that even right?
its part 1 of the equation i guess
Mike Sakata
@mgsakata
Feb 29 2016 03:29
you need the i++ outside of the condition statement
otherwise it may never increment
Jacob Schumer
@jacobschumer
Feb 29 2016 03:29
It looks to me like since i = 0 this while loop won't run
because to add to i you need to get in the loop
Mike Sakata
@mgsakata
Feb 29 2016 03:29
ah yes, that too
Jacob Schumer
@jacobschumer
Feb 29 2016 03:29
err sorry
Mike Sakata
@mgsakata
Feb 29 2016 03:29
oh sorry, no, it should run, just won't stop
Jacob Schumer
@jacobschumer
Feb 29 2016 03:30
right
read >
J Lee
@SoYuMatic
Feb 29 2016 03:31
  var i=0;
  while(i < contacts.length){
      if(contacts[i][firstName] === firstName && contacts[i][prop] === prop){
      return contacts[i][prop];
      }  i++;
why am i using a while and an if
cant i just use an if?
Mike Sakata
@mgsakata
Feb 29 2016 03:32
looks better
Nick Robson
@nickrobson
Feb 29 2016 03:32
You usually use:
Array.prototype.uniq = Array.prototype.uniq || function() {
   return this.reduce((p, c) => {
      if (p.indexOf(c) < 0) p.push(c);
      return p;
   }, []);
};
Took me a while to debug my (broken) code.
J Lee
@SoYuMatic
Feb 29 2016 03:33
yeah that's beyond my scope for now, i wanna take baby steps. I'll get around to learning all the array methods eventually
Nick Robson
@nickrobson
Feb 29 2016 03:33
:)
Mike Sakata
@mgsakata
Feb 29 2016 03:33
interesting. I need to read up a bit more on reduce. Thought it only returned a sum, but looks like it is being used to build up the array with unique values
Nick Robson
@nickrobson
Feb 29 2016 03:34
Array.prototype.uniq = Array.prototype.uniq || function() {
   return Array.from(new Map(this.map(a=>[a,1])).keys());
};
Just thought of that, which also works.
It's a tad cleaner, too.
No idea which would be faster, though.
J Lee
@SoYuMatic
Feb 29 2016 03:35
i just learned about map yesterday too
although it was to use with ...
to split array for the largestof4 array value thing
Nick Robson
@nickrobson
Feb 29 2016 03:35
ah, that might have been me saying it. xD
bitgrower
@bitgrower
Feb 29 2016 03:35
@bitgrower but you could use something like map or forEach to loop through an array without needing a "for" loop
...ummm don't know what you are referring to, @mgsakata ... I wasn't in here asking for help ... :)
Nick Robson
@nickrobson
Feb 29 2016 03:35
function largestOfFour(arr) {
   return arr.map(a => Math.max(...a));
};
@bitgrower Add a new line between those two lines :)
J Lee
@SoYuMatic
Feb 29 2016 03:36
yeah but the guys name was demipixel, i remember cuz he schooled me for like 3 hours, was awesome
Mike Sakata
@mgsakata
Feb 29 2016 03:36
@bitgrower yeah, i kept responding to your name by accident. Sorry about that.
Nick Robson
@nickrobson
Feb 29 2016 03:36
ah right
I think I was talking to him about it, and it's one of the faster/fastest ways
and also it's a really small solution which is nice.
Brian van Vlymen
@arduino731
Feb 29 2016 03:37
hint shopping list
CamperBot
@camperbot
Feb 29 2016 03:37
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Caleb Martin
@caleb272
Feb 29 2016 03:37
Screen Shot 2016-02-18 at 5.36.01 PM guys
Nick Robson
@nickrobson
Feb 29 2016 03:37
var largestOfFour=a=>a.map(a=>Math.max(...a));
bitgrower
@bitgrower
Feb 29 2016 03:37
@nickrobson -- yeah, um ... whoever you meant that message to go to, it wasn't me ...
Caleb Martin
@caleb272
Feb 29 2016 03:37
i
Screen Shot 2016-02-18 at 5.36.01 PM.png
Nick Robson
@nickrobson
Feb 29 2016 03:38
@bitgrower It was.. your quote ran onto your message..
bitgrower
@bitgrower
Feb 29 2016 03:38
y'all have to be really, really, really careful on gitter's auto-complete ...
Mike Sakata
@mgsakata
Feb 29 2016 03:38
although I would think that arrays with for loops would be quicker without needing to define new functions. However, perhaps the arrow notation is quicker?
Caleb Martin
@caleb272
Feb 29 2016 03:38
Screen Shot 2016-02-28 at 8.36.51 PM.png
Nick Robson
@nickrobson
Feb 29 2016 03:38

@bitgrower but you could use something like map or forEach to loop through an array without needing a "for" loop
...ummm don't know what you are referring to, @mgsakata ... I wasn't in here asking for help ... :)

vs

@bitgrower but you could use something like map or forEach to loop through an array without needing a "for" loop

...ummm don't know what you are referring to, @mgsakata ... I wasn't in here asking for help ... :)

sorry for the pings btw
Caleb Martin
@caleb272
Feb 29 2016 03:38
i broke FCC if i run this code it kills my connection to it and i need to know how to erase my code to restart the challenge so it doesn’t disconnect me
Nick Robson
@nickrobson
Feb 29 2016 03:39
lolol
bitgrower
@bitgrower
Feb 29 2016 03:39
now you have me completely confused, @nickrobson ...
Nick Robson
@nickrobson
Feb 29 2016 03:39
help auto
CamperBot
@camperbot
Feb 29 2016 03:39

:point_right: disable code auto run [wiki]

By default, the Free Code Camp site automatically loads and runs your last recorded solution. If you have accidentally created an infinite loop or other irrecoverable error or simply don't trust the code, you can disable code auto-run by putting the following in your URL:
run=disabled

Example:

URL: http://www.freecodecamp.com/challenges/Algorithm-meet-Algorithm#?solution=function%20meetBonfire(argument)

No-Run URL: http://www.freecodecamp.com/challenges/Algorithm-meet-Algorithm#?run=disabled&solution=function%20meetBonfire(argument)

:pencil: read more about disable code auto run on the FCC Wiki

Caleb Martin
@caleb272
Feb 29 2016 03:39
Screen Shot 2016-02-28 at 8.36.51 PM.png
h\
help
CamperBot
@camperbot
Feb 29 2016 03:39

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

Basic Commands:

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

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Caleb Martin
@caleb272
Feb 29 2016 03:39
me
Nick Robson
@nickrobson
Feb 29 2016 03:39
@caleb272 I sent the help article! :)
Monty
@webdev8183
Feb 29 2016 03:39
@bitgrower, any advice on solving mutation, I cannot seem to wrangle a solution that works fully on that challenge. I can get indexOf to work on most of the test cases, but when I try to add an else to return false for the 2 failures, it never passes the other test cases again, its kind of got me stumped, what I could really use is an online editor to echo my output too, I tried jsfiddle but it doesn't give me option to console.log output, any recommendations?
Nick Robson
@nickrobson
Feb 29 2016 03:39
help auto
CamperBot
@camperbot
Feb 29 2016 03:39

:point_right: disable code auto run [wiki]

By default, the Free Code Camp site automatically loads and runs your last recorded solution. If you have accidentally created an infinite loop or other irrecoverable error or simply don't trust the code, you can disable code auto-run by putting the following in your URL:
run=disabled

Example:

URL: http://www.freecodecamp.com/challenges/Algorithm-meet-Algorithm#?solution=function%20meetBonfire(argument)

No-Run URL: http://www.freecodecamp.com/challenges/Algorithm-meet-Algorithm#?run=disabled&solution=function%20meetBonfire(argument)

:pencil: read more about disable code auto run on the FCC Wiki

Caleb Martin
@caleb272
Feb 29 2016 03:40
thanks
bitgrower
@bitgrower
Feb 29 2016 03:40
hey @webdev8183 -- can you post your code ?
Monty
@webdev8183
Feb 29 2016 03:41
i restarted it since i wasn't getting anywhere and now none of it is passing anything lol
Caleb Martin
@caleb272
Feb 29 2016 03:41
thanks @nickrobson
CamperBot
@camperbot
Feb 29 2016 03:41
caleb272 sends brownie points to @nickrobson :sparkles: :thumbsup: :sparkles:
:star: 411 | @nickrobson | http://www.freecodecamp.com/nickrobson
Monty
@webdev8183
Feb 29 2016 03:42

anyway here is what I have so far.. ```js
function mutation(arr){
var size=arr.length;
var source=arr[0];
var searchterm= arr1.toLowerCase;
var test1=arr[0].split('').toLowerCase;
var test2=arr1.split('').toLowerCase;

console.log(searchterm);

if (source.indexOf(searchterm,source)!==-1){
return true;
}

}
mutation(["hello", "hey"]);
```

J Lee
@SoYuMatic
Feb 29 2016 03:44
ok, this is how clueless I am... lol
function lookUp(firstName, prop){
  var i=0;
  while(i < contacts.length){
    if (contacts[i][firstName]===false){
      return "No such contact";
    } else if (contacts[i][prop]===false){
      return "No such property";
    } else if(contacts[i][firstName] === firstName && contacts[i][prop] === prop){
      return contacts[i][prop];
    }i++;
  }
bitgrower
@bitgrower
Feb 29 2016 03:44
@webdev8183 -- edit your message and put a carriage return after "anyway here is what I have so far.." and you'll get the syntax coloring, etc...
Monty
@webdev8183
Feb 29 2016 03:45
ok second try
```js

function mutation(arr){
var size=arr.length;
var source=arr[0];
var searchterm= arr[1].toLowerCase;
var test1=arr[0].split('').toLowerCase;
var test2=arr[1].split('').toLowerCase;

console.log(searchterm);

if (source.indexOf(searchterm,source)!==-1){
return true;
}

}
mutation(["hello", "hey"]);
```

meh what am I doing wrong, I thought it was backticks js shift+enter paste code backticks again..
J Lee
@SoYuMatic
Feb 29 2016 03:46
can someone tell me what I am doing wrong? I return a blank
bitgrower
@bitgrower
Feb 29 2016 03:47
well, dang, I though that should have worked @webdev8183 ...
demipixel
@demipixel
Feb 29 2016 03:47
@webdev8183 toLowerCase is a function
So you have to have () after it
bitgrower
@bitgrower
Feb 29 2016 03:47
okay ... so ... copy and paste from the ```js thru the end of the message into a new message ...
Monty
@webdev8183
Feb 29 2016 03:48

```jsfunction mutation(arr){
var size=arr.length;
var source=arr[0];
var searchterm= arr[1].toLowerCase;
var test1=arr[0].split('').toLowerCase();
var test2=arr[1].split('').toLowerCase();

// console.log(searchterm);
if (source.indexOf(searchterm,source)!==-1){
return true;
}

}
mutation(["hello", "hey"]);
```

demipixel
@demipixel
Feb 29 2016 03:48
@webdev8183 You're missing the last one
also you can't .toLowerCase() after you split
You have to do it before you split
bitgrower
@bitgrower
Feb 29 2016 03:49
LOL one more time, @webdev8183 ... copy & paste ... but put a carriage return after the ```js
@dcnr -- what's your handy one-liner for formatting ... ?
Norman Dela Cruz
@dcnr
Feb 29 2016 03:51
Oh man hold on mobile code formatting is awful!
Monty
@webdev8183
Feb 29 2016 03:52

```js
function mutation(arr){
var size=arr.length;
var source=arr[0];
var searchterm= arr1.toLowerCase();
var test1=arr[0].toLowerCase().split('');
var test2=arr1.toLowerCase().split('');

// console.log(searchterm);
if (source.indexOf(searchterm,source)!==-1){
return true;
}

}
mutation(["hello", "hey"]);

```js

function mutation(arr){
var size=arr.length;
var source=arr[0];
var searchterm= arr1.toLowerCase();
var test1=arr[0].toLowerCase().split('');
var test2=arr1.toLowerCase().split('');

// console.log(searchterm);
if (source.indexOf(searchterm,source)!==-1){
return true;
}

}
mutation(["hello", "hey"]);

Nick Robson
@nickrobson
Feb 29 2016 03:52
Don't put js at the end.
Duuuuude
Norman Dela Cruz
@dcnr
Feb 29 2016 03:52
Do it like ```js (shift + enter) (paste code) (enter)
Nick Robson
@nickrobson
Feb 29 2016 03:52
```js at the start
``` at the end
Kenny
@Kennpow
Feb 29 2016 03:52

hey guys :) a tad rusty on my JS and cant figure out how to add my chars together lol

function rot13(str) { // LBH QVQ VG!
var i = 0;

do
{
var cyp = str.charCodeAt(i);
var trans = cyp - 13;
var end = String.fromCharCode(trans);
var ret = [];
ret.push(end);
i++;
return ret;
} while (i <= str.length);

return str;
}

Nick Robson
@nickrobson
Feb 29 2016 03:52
both need a new line each
```js
code
```
close enough
Kenny
@Kennpow
Feb 29 2016 03:53
function rot13(str) { // LBH QVQ VG!
  var i = 0;

 do
    {
  var cyp = str.charCodeAt(i);
  var trans = cyp - 13;
  var end = String.fromCharCode(trans);
  var ret = [];
      ret.push(end);
      i++;
      return ret;
  }  while (i <= str.length);

  return str;
}
there we are
bitgrower
@bitgrower
Feb 29 2016 03:53

:point_up: February 28, 2016 7:52 PM

@bitgrower approved formatting instructions ...

Nick Robson
@nickrobson
Feb 29 2016 03:54
you need ``` at the end >.>
bitgrower
@bitgrower
Feb 29 2016 03:54
it auto adds it @nickrobson ...
Nick Robson
@nickrobson
Feb 29 2016 03:54
not always :|
bitgrower
@bitgrower
Feb 29 2016 03:54
okay ... you're right ...
J Lee
@SoYuMatic
Feb 29 2016 03:55
am i completely misunderstanding the assignment? I don't get it...
Nick Robson
@nickrobson
Feb 29 2016 03:55
@Kennpow First of all, I don't recommend using a do-while loop. Use a regular for loop.
bitgrower
@bitgrower
Feb 29 2016 03:55
function mutation(arr){
var size=arr.length;
var source=arr[0];
var searchterm= arr1.toLowerCase();
var test1=arr[0].toLowerCase().split('');
var test2=arr1.toLowerCase().split('');
// console.log(searchterm);
if (source.indexOf(searchterm,source)!==-1){
return true;
}
}
mutation(["hello", "hey"]);
Kenny
@Kennpow
Feb 29 2016 03:55
@nickrobson i did originally, just tried different ones
Nick Robson
@nickrobson
Feb 29 2016 03:55
You also need to check if the character is a letter first before shifting it.
bitgrower
@bitgrower
Feb 29 2016 03:55
@webdev8183 's code in my last post ...
Kenny
@Kennpow
Feb 29 2016 03:55
@nickrobson happened to end on do while ha
@nickrobson not too sure on how to do that part. do non-characters have a certain value range?
bitgrower
@bitgrower
Feb 29 2016 03:56
hmmm @webdev8183 ... I never use indexOf with two parameters ...
Monty
@webdev8183
Feb 29 2016 03:57
'''js
CamperBot
@camperbot
Feb 29 2016 03:57
:bulb: to format code use backticks! ``` more info
Nick Robson
@nickrobson
Feb 29 2016 03:57
@Kennpow Hint: 'A' = 65, 'Z' = 90.
Monty
@webdev8183
Feb 29 2016 03:57

function mutation(arr) {
//arr.tostring();
var i,
word1="", //first word
word2="", //second word
result='',//temporary for result of substring
result2='',
result3='',
size=arr.length; //how big is the array?

word1=arr[size-1];
word2=arr[0];
if(arr1.indexOf(arr[0])>-1){
result2=arr1.indexOf(arr[0])===-1;
result2="hey".indexOf(arr[0]);
return result2;
}

if(arr[1].indexOf(arr[0]===-1))
{
return true;

}
}

mutation(["hello", "neo"]);
```

Kenny
@Kennpow
Feb 29 2016 03:57
@nickrobson thanks :D that helps
CamperBot
@camperbot
Feb 29 2016 03:57
kennpow sends brownie points to @nickrobson :sparkles: :thumbsup: :sparkles:
:star: 413 | @nickrobson | http://www.freecodecamp.com/nickrobson
bitgrower
@bitgrower
Feb 29 2016 03:57
@webdev8183 -- I would ALSO recommend COMMENTING your code, so we can see what your thinking is ...
Nick Robson
@nickrobson
Feb 29 2016 03:57
@Kennpow (and 'B' = 66, 'C' = 67, etc)
Dustin
@glenohumeral13
Feb 29 2016 03:58
whoops i meant push not pop
Nick Robson
@nickrobson
Feb 29 2016 03:58
wiki mutation
CamperBot
@camperbot
Feb 29 2016 03:58

:point_right: algorithm mutations [wiki]

Problem Explanation:

  • Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array..
:pencil: read more about algorithm mutations on the FCC Wiki
bitgrower
@bitgrower
Feb 29 2016 03:59
@glenohumeral13 -- you need 2, just 2 array functions ... you can solve it in two lines ... just follow closely the instructions for the challenge -- and the information on the 2 array function MDN pages ...
J Lee
@SoYuMatic
Feb 29 2016 03:59
  var i=0;
  while(i < contacts.length){
    if (contacts[i][firstName]===false){  // if contacts.first name doesn't exist, 
      return "No such contact";
    } else if (contacts[i][prop]===false){ // if contacts.prop doesn't exist,
      return "No such property";
    } else if(contacts[i][firstName] === firstName && contacts[i][prop] === prop){ // if contacts.firstName = argument firstName ...
      return contacts[i][prop];
    }i++;
  }
Dustin
@glenohumeral13
Feb 29 2016 03:59
@bitgrower 2 array function MDN pages?
Nick Robson
@nickrobson
Feb 29 2016 03:59
@glenohumeral13 You're removing the first element, and then removing the second element too!
There should only be one arr.shift() call!
Dustin
@glenohumeral13
Feb 29 2016 04:00
@nickrobson but then how do i return the element that was removed?
bitgrower
@bitgrower
Feb 29 2016 04:00
okay you are using shift & push ... and you go to Mozilla Developer Network (MDN) and look up the description of those methods ... see how they work ...
Nick Robson
@nickrobson
Feb 29 2016 04:00
@glenohumeral13 arr.shift() returns that element.
Brian van Vlymen
@arduino731
Feb 29 2016 04:00
whats wrong with this code http://www.freecodecamp.com/challenges/local-scope-and-functions I tried declared inside the function as
```
var myVar = 5;
var myVar = 5;
Monty
@webdev8183
Feb 29 2016 04:00
cries bitterly over formatting not working
demipixel
@demipixel
Feb 29 2016 04:01
@arduino731 did you read the comments on the problem?
Dustin
@glenohumeral13
Feb 29 2016 04:01
@bitgrower i know what shift and push do. shift removes the first element of an array and then push adds something to the end of the array. what else would i need to know?
Nick Robson
@nickrobson
Feb 29 2016 04:01
@webdev8183 It's not working because you're not doing it right. :P
bitgrower
@bitgrower
Feb 29 2016 04:01
give it a bit of a rest ... and I'll wager you'll have great insight and be able to do it easily next time you come around ...
Nick Robson
@nickrobson
Feb 29 2016 04:01
@glenohumeral13 That's all you need.
bitgrower
@bitgrower
Feb 29 2016 04:01
lol .. .duh @nickrobson rub it in
Nick Robson
@nickrobson
Feb 29 2016 04:01
function queue(arr, item) {
   arr.push(item);
   return arr.shift();
}
Brian van Vlymen
@arduino731
Feb 29 2016 04:01
@demipixel it said "Instructions
Declare a local variable myVar inside myFunction"
Monty
@webdev8183
Feb 29 2016 04:02
I have been told I could screw up a one car funeral, so you are no doubt correct.
demipixel
@demipixel
Feb 29 2016 04:02
@arduino731 No, the comments
@arduino731 Those are things with two slashes before them in the code
Dustin
@glenohumeral13
Feb 29 2016 04:02
@nickrobson yeah, but then if i just return .shift() then do i actually remove the first element?
Nick Robson
@nickrobson
Feb 29 2016 04:02
@glenohumeral13 The shift() function removes the first element and returns it.
Brian van Vlymen
@arduino731
Feb 29 2016 04:02
duh me @demipixel
Dustin
@glenohumeral13
Feb 29 2016 04:03
@nickrobson ah, so it only needs to be one step?
Nick Robson
@nickrobson
Feb 29 2016 04:03
@glenohumeral13 Yes!
I posted working code above, btw. :)
J Lee
@SoYuMatic
Feb 29 2016 04:03
Hey demipixel~ could I get your help again?
Dustin
@glenohumeral13
Feb 29 2016 04:03
@nickrobson ok, thanks!!
CamperBot
@camperbot
Feb 29 2016 04:03
glenohumeral13 sends brownie points to @nickrobson :sparkles: :thumbsup: :sparkles:
:star: 414 | @nickrobson | http://www.freecodecamp.com/nickrobson
Nick Robson
@nickrobson
Feb 29 2016 04:03
@SoYuMatic Ask and you shall receive.
J Lee
@SoYuMatic
Feb 29 2016 04:03
http://www.freecodecamp.com/challenges/profile-lookup
  var i=0;
  while(i < contacts.length){
    if (contacts[i][firstName]===false){
      return "No such contact";
    } else if (contacts[i][prop]===false){
      return "No such property";
    } else if(contacts[i][firstName] === firstName && contacts[i][prop] === prop){
      return contacts[i][prop];
    }i++;
  }
demipixel
@demipixel
Feb 29 2016 04:04
@SoYuMatic Yes
Brian Tong
@brtong
Feb 29 2016 04:04

@brtong
hello chat could someone explain to me why I cant seem to get the prompt for not found in the testing challenge
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty("checkProp")=== true);
{return myObj[checkProp];}

return "Not Found"; }

// Test your code by modifying these values
checkObj("gift");

J Lee
@SoYuMatic
Feb 29 2016 04:04
i return a blank
demipixel
@demipixel
Feb 29 2016 04:04
@SoYuMatic Alright, so
bitgrower
@bitgrower
Feb 29 2016 04:04
how ya doin' @webdev8183 ... ?
demipixel
@demipixel
Feb 29 2016 04:04
@SoYuMatic first ya probably want i++ on a new line :P
L Yeh
@PhotoGeek1
Feb 29 2016 04:05

question about arrays. Can we not use variables as part of an array name?

For example:

  arr1=[1,2,3];
  i=1;
  var arrLoop = arr[i];
  return arrLoop;

returns ReferenceError: arr is not defined.

demipixel
@demipixel
Feb 29 2016 04:05
@SoYuMatic Hopefully the following will help you:
Nick Robson
@nickrobson
Feb 29 2016 04:05
@SoYuMatic Think of how this is flowing.
1) It passes in the first contact into the loop.
2) The first contact's name is NOT false.
3) It returns "No such contact".
Brian Tong
@brtong
Feb 29 2016 04:05

hello chat could someone explain to me why I cant seem to get the prompt for not found in the testing challenge

```

// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty("checkProp")=== true);
{return myObj[checkProp];}
return "Not Found"; }
// Test your code by modifying these values
checkObj("gift");
```

Nick Robson
@nickrobson
Feb 29 2016 04:05
Is that the expected behaviour? (no, it isn't!)
J Lee
@SoYuMatic
Feb 29 2016 04:06
it doesn't even return that!
demipixel
@demipixel
Feb 29 2016 04:06
@SoYuMatic
var obj = {
  "hello": 3,
  "puppy": 4
}
var hello = "puppy";

obj.hello == 3;
obj["hello"] == 3;
obj[hello] == 4;
Brian Tong
@brtong
Feb 29 2016 04:06
hello chat could someone explain to me why I cant seem to get the prompt for not found in the testing challenge
```
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty("checkProp")=== true);
{return myObj[checkProp];}
return "Not Found"; }
// Test your code by modifying these values
checkObj("gift");
Nick Robson
@nickrobson
Feb 29 2016 04:06
Plus you're actually accessing the contact's property called whatever the firstName variable is equal to.
Brian Tong
@brtong
Feb 29 2016 04:07
var myObj = { gift: "pony", pet: "kitten", bed: "sleigh" }; function checkObj(checkProp) { // Your Code Here if (myObj.hasOwnProperty("checkProp")=== true); {return myObj[checkProp];} return "Not Found"; } // Test your code by modifying these values checkObj("gift");
demipixel
@demipixel
Feb 29 2016 04:07
@brtong It's
```js
<code>
```
Nick Robson
@nickrobson
Feb 29 2016 04:07
How'd you put that without the code box? :c
demipixel
@demipixel
Feb 29 2016 04:07
Magic
Brian Tong
@brtong
Feb 29 2016 04:08
thanks
Nick Robson
@nickrobson
Feb 29 2016 04:08
teach me your ways
Brian Tong
@brtong
Feb 29 2016 04:08
@demipixel thank you
CamperBot
@camperbot
Feb 29 2016 04:08
brtong sends brownie points to @demipixel :sparkles: :thumbsup: :sparkles:
:star: 74 | @demipixel | http://www.freecodecamp.com/demipixel
demipixel
@demipixel
Feb 29 2016 04:08
lurn 2 program m8 @nickrobson
Nick Robson
@nickrobson
Feb 29 2016 04:08
:c
demipixel
@demipixel
Feb 29 2016 04:08
if u knew how to program u could guess ;)
Brian Tong
@brtong
Feb 29 2016 04:09
js <var myObj = { gift: "pony", pet: "kitten", bed: "sleigh" }; function checkObj(checkProp) { // Your Code Here if (myObj.hasOwnProperty("checkProp")=== true); {return myObj[checkProp];} return "Not Found"; } // Test your code by modifying these values checkObj("gift");>
Nick Robson
@nickrobson
Feb 29 2016 04:09
btw @demipixel
var lookup=(c,f,p)=>{var a=c.find(a=>a.firstName===f);return a?a.hasOwnProperty(p)?a[p]:"No such property":"No such contact"};
J Lee
@SoYuMatic
Feb 29 2016 04:09
ok so I was confusing name/value and variable names
demipixel
@demipixel
Feb 29 2016 04:10
@nickrobson We do that AFTER they understand
Not to confuse them more
Nick Robson
@nickrobson
Feb 29 2016 04:10
That's jibberish.
demipixel
@demipixel
Feb 29 2016 04:10
@SoYuMatic yeah
@SoYuMatic there's contact.firstName and then there's the firstName variable
@nickrobson that's not the most compact btw
Brian Tong
@brtong
Feb 29 2016 04:11
``` (shift+enter for line break)
var code = "formatted";
```
Nick Robson
@nickrobson
Feb 29 2016 04:11
can't see any shorter way
Brian Tong
@brtong
Feb 29 2016 04:12
``````js <var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty("checkProp")=== true);
{return myObj[checkProp];}
return "Not Found"; }
// Test your code by modifying these values
checkObj("gift");>```
Nick Robson
@nickrobson
Feb 29 2016 04:12
I know this passes the test, though.
var lookup=(c,f,p)=>{var a=c.find(a=>a.firstName===f);return a?a[p]||"No such property":"No such contact"};
Brian Tong
@brtong
Feb 29 2016 04:12

```var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty("checkProp")=== true);
{return myObj[checkProp];}

return "Not Found"; }

// Test your code by modifying these values
checkObj("gift");
```

J Lee
@SoYuMatic
Feb 29 2016 04:12
so i made them all arr.name since we have the name of the .. names
bitgrower
@bitgrower
Feb 29 2016 04:13
@webdev8183 ... ???
J Lee
@SoYuMatic
Feb 29 2016 04:13
and the firstName when i just write firstName should be the parameter
Nick Robson
@nickrobson
Feb 29 2016 04:13
@brtong ``` needs to be on its OWN line
```js
LIKE THESE ^ v
```
Brian Tong
@brtong
Feb 29 2016 04:14

```

test

demipixel
@demipixel
Feb 29 2016 04:14
More like this:
```js
<code>
```
Brian Tong
@brtong
Feb 29 2016 04:14
test
got it lol
now i need help with the actual code :P
bitgrower
@bitgrower
Feb 29 2016 04:15
YAY!!!! congrats @brtong
demipixel
@demipixel
Feb 29 2016 04:15
@nickrobson You can compact it more
Nick Robson
@nickrobson
Feb 29 2016 04:15
how so?
demipixel
@demipixel
Feb 29 2016 04:16
@nickrobson
var lookup=(c,f,p)=>f=c.find(a=>a.firstName===f)?f[p]||"No such property":"No such contact";
Brian Tong
@brtong
Feb 29 2016 04:16
anyways i cant seem to get the return for not found
Nick Robson
@nickrobson
Feb 29 2016 04:16
Ah, yes.
Brian Tong
@brtong
Feb 29 2016 04:17
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
if (myObj.hasOwnProperty("checkProp")=== true);
{return myObj[checkProp];}


return "Not Found"; }


// Test your code by modifying these values
checkObj("gift");
demipixel
@demipixel
Feb 29 2016 04:17
I feel like we should make a list of all of the shortest possible FCC answers
Nick Robson
@nickrobson
Feb 29 2016 04:17
yeah xD
J Lee
@SoYuMatic
Feb 29 2016 04:17
var stuff = [ name: bob, color : red ]

function x(name, color)
stuff[n].name === name
Is saying if (assume i have a while look counting through n, and there are more arrays)
on the n th array, stuff.name ( of the name/value pair) is equal to the name parameter being called in function x??
Nick Robson
@nickrobson
Feb 29 2016 04:18
and it has to be
var lookup=(c,f,p)=>(f=c.find(a=>a.firstName===f))?f[p]||"No such property":"No such contact";
need those brackets
demipixel
@demipixel
Feb 29 2016 04:19
Oh yeah
@SoYuMatic yeah
@SoYuMatic Although why don't you use for loops?
Nick Robson
@nickrobson
Feb 29 2016 04:19
There's probably a clever way to use "No such " and combine it with "property" or "contact"
demipixel
@demipixel
Feb 29 2016 04:19
for (var n = 0; n < arr.length; n++) {}
J Lee
@SoYuMatic
Feb 29 2016 04:20
aren't all loops sorta more or less the same?
Brian Tong
@brtong
Feb 29 2016 04:20
@nickrobson @demipixel any input on what could cause the "not found" from showing up on mine?
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
if (myObj.hasOwnProperty("checkProp")=== true);
{return myObj[checkProp];}


return "Not Found"; }


// Test your code by modifying these values
checkObj("gift");
demipixel
@demipixel
Feb 29 2016 04:20
While loops are kinda built for when you don't know when it's gonna end
In a for-loop, you know it's gonna take arr.length loops
@brtong You're looking for the property "checkProp"
You want to look for the property stored in checkProp
Arya
@beingmojo
Feb 29 2016 04:22
Hi, can someone help me with this code;
for some reason second test is not passing,
`Return Largest Numbers in Arrays
function largestOfFour(arr) {
    // You can do this!
    var max=0;
    var max_arr=[];
    for(var i=0; i<arr.length; i++){
        for(var j=0; j<arr[i].length; j++){
            if(arr[i][j] > max ){
                max = arr[i][j];
                max_arr[i]=max;
            }
        }
    }
    return max_arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Nick Robson
@nickrobson
Feb 29 2016 04:22
var lookup=(c,f,p)=>(f=c.find(a=>a.firstName===f))&&f[p]||'No such '+(f?'property':'contact');
same length but could maybe be shortened
bitgrower
@bitgrower
Feb 29 2016 04:22
@brtong -- what @demipixel said ... you don't put quotes around a parameter name ...
Brian Tong
@brtong
Feb 29 2016 04:23
so remove the quotations around parameter name...and stick to just brackets
demipixel
@demipixel
Feb 29 2016 04:23
@nickrobson No need for ===
== is fine
Nick Robson
@nickrobson
Feb 29 2016 04:23
well
unless firstName is "1" and obj.firstName is 1
xD
J Lee
@SoYuMatic
Feb 29 2016 04:24
@demipixel I still get a blank return.
function lookUp(firstName, prop){
// Only change code below this line
  for(i=0;i < contacts.length; i++){  //counting through arrays
    if (contacts[i].firstName===false){  //checking if array's key exists
      return "No such contact";               // if not, return statement.  Same for the next for prop.
    } else if (contacts[i].prop===false){
      return "No such property";
    } else if(contacts[i].firstName === firstName && contacts[i].prop === prop){ // if the value of the key is the same as param for both
      return contacts[i].prop;               // return that value property of the array
    }
  }
demipixel
@demipixel
Feb 29 2016 04:24
@SoYuMatic You're checking if contact[i]'s first name is false?
J Lee
@SoYuMatic
Feb 29 2016 04:25
yeah, seeing if it exists or not
demipixel
@demipixel
Feb 29 2016 04:25
ah
I think you may want to do:
if (!contacts[i].firstName)
Nick Robson
@nickrobson
Feb 29 2016 04:26
@SoYuMatic You want to return "No such contact" after the loop ends!
Not inside it..
The only reason it would leave the loop should be if it hasn't found a matching contact.
You're also using contacts[i]["prop"] instead of getting the property called "the value of prop"
Brian Tong
@brtong
Feb 29 2016 04:27
myObj still does not return the vale "Not Found" for missing properties....
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
if (myObj.hasOwnProperty(checkProp)=== true);
{return myObj[checkProp];}


return "Not Found"; }


// Test your code by modifying these values
checkObj("bed");
*value
Nick Robson
@nickrobson
Feb 29 2016 04:28
@CodeVeni Sorry for the slow reply, but you need to move var max = 0; inside the first loop!
demipixel
@demipixel
Feb 29 2016 04:28
@nickrobson I think that's as compact as it gets assuming we're abiding by the official rules that
  • You must have var before an undeclared variable
  • You must have a semicolon after a line
Nick Robson
@nickrobson
Feb 29 2016 04:28
(except for the last return)
Well, I'm happy with this @demipixel :3
var lookup=(c,f,p)=>(f=c.find(a=>a.firstName===f))?f[p]||"No such property":"No such contact";
I think we should make an FCC golf github repo haha
Arya
@beingmojo
Feb 29 2016 04:29
@nickrobson thank you
CamperBot
@camperbot
Feb 29 2016 04:29
codeveni sends brownie points to @nickrobson :sparkles: :thumbsup: :sparkles:
:star: 415 | @nickrobson | http://www.freecodecamp.com/nickrobson
demipixel
@demipixel
Feb 29 2016 04:29
@nickrobson omg yes
But before we do it with official answers
I want people to try doing it drunk first
Nick Robson
@nickrobson
Feb 29 2016 04:29
haha
Arya
@beingmojo
Feb 29 2016 04:29
@nickrobson but why did that affect the answer
Nick Robson
@nickrobson
Feb 29 2016 04:30
@CodeVeni Previously you were keeping the maximum across all of the arrays.
For example, in:
[ [5,6,7,8], [1,2,3,4] ]
It first found the largest value in the first array was 8.
Then when it went to the second array, the max variable still contained the number 8.
So the second array's "maximum" was set to 8!
@demipixel d'ya wanna set it up?
We could also just petition for a FreeCodeCamp/Golf repo haha
Caleb Martin
@caleb272
Feb 29 2016 04:32
haha
J Lee
@SoYuMatic
Feb 29 2016 04:34
ok i am gonna redo the whole JSON section cuz
cuz im mad
demipixel
@demipixel
Feb 29 2016 04:36
@nickrobson Sent something to @sludge256 in the main room, hopefully he'll see it
Nick Robson
@nickrobson
Feb 29 2016 04:37
Nice! :)
bitgrower
@bitgrower
Feb 29 2016 04:37
why not just set up the room ?
just do it ...
demipixel
@demipixel
Feb 29 2016 04:38
@bitgrower Then it wouldn't be an official FreeCodeCamp room
bitgrower
@bitgrower
Feb 29 2016 04:38
sometimes things become official by being unofficial first ...
demipixel
@demipixel
Feb 29 2016 04:38
Moving everybody would be a pain :(
bitgrower
@bitgrower
Feb 29 2016 04:38
and, if they are popular enough, and meet the goals of FCC ...
demipixel
@demipixel
Feb 29 2016 04:39
It doesn't hurt to wait for @sludge to respond
bitgrower
@bitgrower
Feb 29 2016 04:39
excuse me ... ? Why would that be a pain ?
demipixel
@demipixel
Feb 29 2016 04:39
@bitgrower The would be like telling everybody in this room to move to another
People would still be in this room for a while before they got the message or whatever
bitgrower
@bitgrower
Feb 29 2016 04:39
what would be the purpose of your new room ?
Nick Robson
@nickrobson
Feb 29 2016 04:40
wa
it wuldn't be moving everyone lol
demipixel
@demipixel
Feb 29 2016 04:41
@nickrobson If we had to make a temp one and then once it became popular, move it to an official room?
bitgrower
@bitgrower
Feb 29 2016 04:41
yeah ... c'mon, even if it were ... I thought ya'all were hotshot programmers ... surely there's a way to move them via software, eh ?
Nick Robson
@nickrobson
Feb 29 2016 04:41
tbh I figure we can wait lol
I think you can mass-add people to a group
I can check with my bot
I just don't think it'd be pretty
xD
demipixel
@demipixel
Feb 29 2016 04:42
Yeah, we can wait
I already figured out the 1st one btw
You're suppose to make Hello World in h1

Sooo....

<h1>Hello World

;)

bitgrower
@bitgrower
Feb 29 2016 04:42
hah !!! NOT the attitude of an entrepreneur ... entrepreneurs take action on their ideas fast ...
Nick Robson
@nickrobson
Feb 29 2016 04:42
wait we're minifying html too?
oh dear
Liam Bang
@Liam345
Feb 29 2016 04:42
function destroyer(arr) {
  // Remove all the values


  return arr[2];
}

destroyer([1, 2, 3, 1, 2, 3], 4, 5);
How can I access the number 4 in the function destroyer (with the help of the argument objects)?
Nick Robson
@nickrobson
Feb 29 2016 04:43
has (computer) science gone too far?
demipixel
@demipixel
Feb 29 2016 04:43
@nickrobson Well, eh, I don't really want to, but we'll finish all the js and then resort to the html ones
Nick Robson
@nickrobson
Feb 29 2016 04:43
mhm
lmao, minifying the nodejs will be fun
if we get to that..
demipixel
@demipixel
Feb 29 2016 04:43

@Liam345 like...

function destroyer(arr, a, b) {

}

??

@nickrobson lmao minify a full stack app
Nick Robson
@nickrobson
Feb 29 2016 04:44
@Liam345
function destroyer(arr) {
  // Remove all the values
  var theFour = arguments[1];

  return arr[2];
}
bitgrower
@bitgrower
Feb 29 2016 04:44
well, y'all's room sounds intriguing ... but I'm not quite sure what you are intending it's purpose to be ?
Nick Robson
@nickrobson
Feb 29 2016 04:44
@bitgrower Golfing the FCC challenges.
demipixel
@demipixel
Feb 29 2016 04:44
@bitgrower Discuss pars and hole in ones
Nick Robson
@nickrobson
Feb 29 2016 04:44
(while still using JS ofc)
It'd be cheating to use coffeescript bahaha
although I'd make an exception for the nodejs ones
bitgrower
@bitgrower
Feb 29 2016 04:44
@what does that mean, @nickrobson ... you mean doing solutions in 1 line or 2 lines or something like that ?
Nick Robson
@nickrobson
Feb 29 2016 04:45
Using the least amount of bytes/characters but still having a working solution.
Since JS is all ASCII it's the same thing.
bitgrower
@bitgrower
Feb 29 2016 04:45
I think it sounds like an awesome idea ...
demipixel
@demipixel
Feb 29 2016 04:45
Alright here are the rules:
  • You MUST have a var before undeclared variables
  • You MUST have a semicolon at the end of statements
i.e.
function() {return 2;}
You need the ;
bitgrower
@bitgrower
Feb 29 2016 04:46
go make your room ... it's easy enough ... :)
Nick Robson
@nickrobson
Feb 29 2016 04:46
yikes
demipixel
@demipixel
Feb 29 2016 04:46
@nickrobson Well, I mean
Nick Robson
@nickrobson
Feb 29 2016 04:46
JS works without the ; tho :c
Rachel
@chellybear
Feb 29 2016 04:46
can you use ternary operator in JS?
demipixel
@demipixel
Feb 29 2016 04:47
I know...
bitgrower
@bitgrower
Feb 29 2016 04:47
I mean, I know I could learn a lot from y'all with your ES6 solutions ... which I don't know much of at all ...
Nick Robson
@nickrobson
Feb 29 2016 04:47
@chellybear Yep!
condition ? ifTrue : ifFalse
bitgrower
@bitgrower
Feb 29 2016 04:47
@chellybear yes
demipixel
@demipixel
Feb 29 2016 04:47
@nickrobson Your lookup() had a ; at the end of it
Rachel
@chellybear
Feb 29 2016 04:47
awesome :)
Nick Robson
@nickrobson
Feb 29 2016 04:47
@demipixel At the end of the line, not the return! :P
I don't mind, as long as we're consistent.
demipixel
@demipixel
Feb 29 2016 04:47
@nickrobson I know, but you either gotta enforce both or neither
Yeah, consistency
Nick Robson
@nickrobson
Feb 29 2016 04:48
It might be best to do all optional semicolons as required.
demipixel
@demipixel
Feb 29 2016 04:48
@nickrobson I mean technically you don't need var before variables either
Nick Robson
@nickrobson
Feb 29 2016 04:48
yup, deal.
yoni chanowitz
@yonichanowitz
Feb 29 2016 04:48
HELP ME ! Seek and Destroy, is destroying me
CamperBot
@camperbot
Feb 29 2016 04:48
no wiki entry for: me seek and destroy is destroying me
demipixel
@demipixel
Feb 29 2016 04:48
But then that screws with the global scope
Nick Robson
@nickrobson
Feb 29 2016 04:48
sure thing
Eduardo Garcia
@eagarcia8
Feb 29 2016 04:49
@yonichanowitz Show us your current code
Nick Robson
@nickrobson
Feb 29 2016 04:49
I'm gonna set up floobits to work.
It's a collab real time editor.
plus works with most text editors!
demipixel
@demipixel
Feb 29 2016 04:49
@nickrobson with... gitter?
Brian
@sludge256
Feb 29 2016 04:49
I think someone has mentioned/proposed code golf before
Nick Robson
@nickrobson
Feb 29 2016 04:49
For a github repo aye :P
demipixel
@demipixel
Feb 29 2016 04:50
@sludge256 yeah but me and @nickrobson are dedicated
Nick Robson
@nickrobson
Feb 29 2016 04:50
I think we've already confused everyone in the room with it :|
demipixel
@demipixel
Feb 29 2016 04:51
^^ That's why we want FreeCodeCamp/Golf haha
Brian
@sludge256
Feb 29 2016 04:52
I don't have room creation powers
demipixel
@demipixel
Feb 29 2016 04:52
whooooooo odoes
Nick Robson
@nickrobson
Feb 29 2016 04:53
eck
Brian
@sludge256
Feb 29 2016 04:53
Also, I dont think FCC wants to encourage beginners to spend too much time revisiting and optimizing their algos
they would prefer people focus on finishing projects
demipixel
@demipixel
Feb 29 2016 04:53
@sludge256 Mark it as a "room not for beginners" or something
Does every room have to be dedicated to newer coders?
Brian
@sludge256
Feb 29 2016 04:53
You could propose the idea to BerkeleyTrue or QuincyLarson
We're also trying to avoid creating dead rooms
demipixel
@demipixel
Feb 29 2016 04:54
mm
Brian
@sludge256
Feb 29 2016 04:54
Even the gaming room is mostly dead
demipixel
@demipixel
Feb 29 2016 04:54
Maybe we should just make demipixel/FCCGolf and be done with it lol
scottmike0
@scottmike0
Feb 29 2016 04:54
so many videos watched on java... 24% til I master it enough to make any data structure/collection >:D
demipixel
@demipixel
Feb 29 2016 04:55
@scottmike0 java...script?
scottmike0
@scottmike0
Feb 29 2016 04:55
@demipixel nope actual java.
demipixel
@demipixel
Feb 29 2016 04:55
Weird that you would mention it in the HelpJavascript room then haha
@sludge256 I need to work on my pitching skills anyway
scottmike0
@scottmike0
Feb 29 2016 04:55
@demipixel i like mentioning random stuff
Nick Robson
@nickrobson
Feb 29 2016 04:56
Brian
@sludge256
Feb 29 2016 04:56
I'm not entirely against the idea
scottmike0 @scottmike0 loves whispering stuff
Brian
@sludge256
Feb 29 2016 04:56
I'm just giving you a heads up on some of the obstacles in getting it created
There's a CodeReview room also
demipixel
@demipixel
Feb 29 2016 04:56
@nickrobson Permission request failed: There are no admins in this workspace.
Nick Robson
@nickrobson
Feb 29 2016 04:57
GUYS LEO WON AN OSCAR
WOOO
demipixel
@demipixel
Feb 29 2016 04:57
no big surprse
Nick Robson
@nickrobson
Feb 29 2016 04:57
uno momento
okay, should be good
log in with github
CamperBot
@camperbot
Feb 29 2016 04:58
Archives for HelpJavaScript
scottmike0
@scottmike0
Feb 29 2016 04:59
@nickrobson what ya creating
Nick Robson
@nickrobson
Feb 29 2016 04:59
Making a repo for golfing down FCC solutions. :)
scottmike0
@scottmike0
Feb 29 2016 04:59
which one is that?
Nick Robson
@nickrobson
Feb 29 2016 04:59
Hm?
scottmike0
@scottmike0
Feb 29 2016 05:00
i mean nvm
Nick Robson
@nickrobson
Feb 29 2016 05:00
http://github.com/nickrobson/fcc-golf, but the floobits is a live editor for it..
scottmike0
@scottmike0
Feb 29 2016 05:01
@nickrobson what is golfing downs? i did not see it on the map o.o
Nick Robson
@nickrobson
Feb 29 2016 05:01
lol
Code golfing means making the shortest possible solution to a question.
Caleb Martin
@caleb272
Feb 29 2016 05:01
^ yup
Nick Robson
@nickrobson
Feb 29 2016 05:01
The repo will contain the shortest possible solutions to every FCC challenge/bonfire.
Caleb Martin
@caleb272
Feb 29 2016 05:01
its a game and has no real world application
scottmike0
@scottmike0
Feb 29 2016 05:01
ah
Nick Robson
@nickrobson
Feb 29 2016 05:03
well, it's technically faster for an interpreter
yo @demipixel are you looking at the floobits chat section? :3
demipixel
@demipixel
Feb 29 2016 05:03
yep
Caleb Martin
@caleb272
Feb 29 2016 05:04
floobits chat ?
demipixel
@demipixel
Feb 29 2016 05:05
yeah
Caleb Martin
@caleb272
Feb 29 2016 05:05
help symmetric difference
CamperBot
@camperbot
Feb 29 2016 05:05

:point_right: algorithm symmetric difference [wiki]

Problem Explanation:

Symmetric Difference is the difference between two sets.

So in the Symmetric Difference Algorithm you would work through the arrays of numbers something like this -

sym(A, B, C) Translates to sym(sym(A,B),C)

Or in plain English - First find the Symmetric Difference of Set A and Set B. Then find the Symmetric Difference of this new set and Set C.

So -

sym([1, 2, 5], [2, 3, 5], [3, 4, 5])

would equal

[1,4,5]

Here's a nice video tutorial (with an awful fake British accent!) -

YouTube - Symmetric Difference
:pencil: read more about algorithm symmetric difference on the FCC Wiki

Caleb Martin
@caleb272
Feb 29 2016 05:05
fuck I’m screwed i will never do this algorithm
demipixel
@demipixel
Feb 29 2016 05:08
@caleb272 Cmon dude, you can do it
Think through it using english words
Before even typing any code
L Yeh
@PhotoGeek1
Feb 29 2016 05:09

question about arrays. Can we not use variables as part of an array name?

For example:

  arr1=[1,2,3];
  i=1;
  var arrLoop = arr[i];
  return arrLoop;

returns ReferenceError: arr is not defined.

Monty
@webdev8183
Feb 29 2016 05:09
because your arrayname is arr1
Caleb Martin
@caleb272
Feb 29 2016 05:09
@demipixel I’m watching the video once i understand it i will write pseudo code
demipixel
@demipixel
Feb 29 2016 05:09
Alright
@PhotoGeek1 Yeah, you're doing arr[i] but I think you meant to do arr1[i]
bitgrower
@bitgrower
Feb 29 2016 05:10
this is a GREAT lesson in learning to understand your error messages ....
demipixel
@demipixel
Feb 29 2016 05:11
@bitgrower ^^^
L Yeh
@PhotoGeek1
Feb 29 2016 05:11
@webdev8183 @demipixel I really do mean arr[i]. I want to change out the [i] to run functions on a different array
I have arr1, arr2, arr3
demipixel
@demipixel
Feb 29 2016 05:11
and arr I presume? :P
Oh I see
L Yeh
@PhotoGeek1
Feb 29 2016 05:11
no arr
bitgrower
@bitgrower
Feb 29 2016 05:11
....just break it apart .... "arr is not defined" ... it means exactly that ... the variable "arr" does not have a definition ...
demipixel
@demipixel
Feb 29 2016 05:11
@PhotoGeek1 You'd want a 2d array then
var arr = [[1,2,3], [4,5,6], [7,8,9]];
return arr[0];
L Yeh
@PhotoGeek1
Feb 29 2016 05:12
@demipixel Oh, got it
so it'd be best if I throw arr1, arr2 and arr3 into a combined 2D arr and then do the arr[i]
bitgrower
@bitgrower
Feb 29 2016 05:13

Think through it using english words
Before even typing any code

Hear! Hear !!!! More of this, please!

Caleb Martin
@caleb272
Feb 29 2016 05:13
^ what do you mean
L Yeh
@PhotoGeek1
Feb 29 2016 05:13
@demipixel thanks!
CamperBot
@camperbot
Feb 29 2016 05:13
photogeek1 sends brownie points to @demipixel :sparkles: :thumbsup: :sparkles:
:star: 79 | @demipixel | http://www.freecodecamp.com/demipixel
bitgrower
@bitgrower
Feb 29 2016 05:13
@caleb272 -- it means describing your solution in words first, not code
demipixel
@demipixel
Feb 29 2016 05:13
^^
@PhotoGeek1 np
Liam Bang
@Liam345
Feb 29 2016 05:14
function destroyer(arr) {
  // Remove all the values

  var ary =arguments[