These are chat archives for FreeCodeCamp/Help

24th
Jun 2015
Timothy Touch
@timtouch
Jun 24 2015 00:17
@moigithub Nice
Don
@raydancer
Jun 24 2015 00:27
last night when I completed Basic Algorithm Scripting: Bonfire 18, I was taken to Object Oriented Javascript: Waypoint 2...was this a site error?
Greg Haas
@izzaboo
Jun 24 2015 00:53
I see a little ways upthread there was discussion about HTML entities. I'm wondering if anybody else had trouble with just the "<>" test? I passed the other two. But can't seem to get that one. I'm using:
Candis Wasell
@CandiW
Jun 24 2015 00:54
Was wondering if someone could look at my code for Bonfire Return Largest Number in Arrays? I realized it's a nested array, so I wrote two for loops, but I still can't seem to get in to those inside arrays..... Help?
function largestOfFour(arr) {
  // You can do this!
  var largestNum = 0;
  var results = [];
  for (var a = 0; a<arr.length; a++){
    return arr[a];
  }
  for (var b = 0; b<arr[a].length; b++){
    return arr[b];
  }
  if(largestNum === arr[b]){
    return largestNum.push(results);
  }
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Greg Haas
@izzaboo
Jun 24 2015 00:54
var re = /[&><'"]/g;
  var result = [];

  while ((result = re.exec(str)) !== null) {
    switch (result[0]){
When I then replace, for example, & with &amp;
I get good result on first test but <> doesn't seem to escape (or whatever) correctly.
Candis Wasell
@CandiW
Jun 24 2015 01:02
Made some changes....getting closer
Steven Leiva
@StevenXL
Jun 24 2015 01:32
@CandiW when you use the keyword return, the function does literally that. It stops executing and returns the results if you ask it to.
Moisés Man
@moigithub
Jun 24 2015 01:41
http://codepen.io/MMan/full/OVOmbP weather zipline done!!
Lightwaves
@Lightwaves
Jun 24 2015 01:42
and I do the functional programming is cool dance
RaissaHughes
@RaissaHughes
Jun 24 2015 01:51
looks awesome! @moigithub
Greg Haas
@izzaboo
Jun 24 2015 02:05
modern day camper. i'm working on HTML entities bonfire from the passenger seat this evening. and it is Kickin' My Butt!
can anybody give some pointers? Is there something special about replacing < and > with their HTML entities as compared to & and ' and "?
Brett Guillory
@kurzninja
Jun 24 2015 02:18
Anyone got any tips for the Make A Person bonfire?
I've gone through the Udacity course for the OO Javascript, but it's still pretty confusing
Timothy Touch
@timtouch
Jun 24 2015 02:21
@izzaboo I've read that that bonfire is bugged right now
@kurzninja Mind telling me what is confusing?
Brett Guillory
@kurzninja
Jun 24 2015 02:22
Just still not clear on how to make the class that it's asking. I thought I was doing everything right, but I'm obviously not
RaissaHughes
@RaissaHughes
Jun 24 2015 02:22

can someone plese help me... it says i passed the lesson but the code just doesnt seem right... im talking about the last few lines of code... they dont work..

// Check if the user is ready to play!
confirm("I understand confirm!")

var age = prompt("What's your age");
if(age < 13)
{
console.log("You are allowed to play but I take no responsibilty!")
}
else
if (age > 13)

{
console.log("Have fun!")

}

console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");

if (userAnswer === 10 % 2 ) {
console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!")
} else {console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");
}

Brett Guillory
@kurzninja
Jun 24 2015 02:22
var Person = function(firstAndLast) {
  this.firstname = firstAndLast.split(" ")[0];
  this.lastname = firstAndLast.split(" ")[1];
};

  Person.prototype.getFirstName = function() {
    return this.firstname; 
  };

  Person.prototype.getLastName = function() {
    return this.lastname;
  };
  Person.prototype.getFullName = function() {
    return this.firstname + " " + this.lastname;
  };
  Person.prototype.setFirstName = function(first) {
    this.firstname = first;
  };
  Person.prototype.setLastName = function(last) {
    this.lastname = last;
  };
  Person.prototype.setFullName = function(firstAndLast) {
    this.firstname = firstAndLast.split(" ")[0];
    this.lastname = firstAndLast.split(" ")[1];
  }; 

var bob = new Person('Bob Ross');
bob.getFullName();
RaissaHughes
@RaissaHughes
Jun 24 2015 02:22
im on the adventure game javascript
Brett Guillory
@kurzninja
Jun 24 2015 02:23
@RaissaHughes please put your code in proper Markup using ```, thanks
all the tests are passing with my code, except the first one: expect(Object.keys(bob).length).to.eql(6);expected 2 to deeply equal 6
Timothy Touch
@timtouch
Jun 24 2015 02:25
@kurzninja Yeah, I found that requirement wierd since the udacity tutorial taught differently
Brett Guillory
@kurzninja
Jun 24 2015 02:25
but if I put the functions inside the Person function, it says "expected 8 to deeply equal 6" instead
Timothy Touch
@timtouch
Jun 24 2015 02:26
I think you are supposed to put the methods in the object
Oh
Brett Guillory
@kurzninja
Jun 24 2015 02:26
I thought the way I did it here was the correct way, adding the functions to the Person.prototype that Person will delegate to
Timothy Touch
@timtouch
Jun 24 2015 02:27
You shouldn't have those two variables defined in object
Brett Guillory
@kurzninja
Jun 24 2015 02:27
without them, how would the set methods work? What would they have to work on?
RaissaHughes
@RaissaHughes
Jun 24 2015 02:28

```// Check if the user is ready to play!
confirm("I understand confirm!")

var age = prompt("What's your age");
if(age < 13)
{
console.log("You are allowed to play but I take no responsibilty!")
}
else
if (age > 13)

{
console.log("Have fun!")

}

console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");

if (userAnswer === 10 % 2 ) {
console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!")
} else {console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");
}```

'''// Check if the user is ready to play!
confirm("I understand confirm!")

var age = prompt("What's your age");
if(age < 13)
{
console.log("You are allowed to play but I take no responsibilty!")
}
else
if (age > 13)

{
console.log("Have fun!")

}

console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");

if (userAnswer === 10 % 2 ) {
console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!")
} else {console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");
}'''

Brett Guillory
@kurzninja
Jun 24 2015 02:28
lol
RaissaHughes
@RaissaHughes
Jun 24 2015 02:28
hmm not working for me
Brett Guillory
@kurzninja
Jun 24 2015 02:29
You have to put your code on a newline after the first ```
and if you use ```js it will give it Javascript syntax coloring too
Timothy Touch
@timtouch
Jun 24 2015 02:29
directly manipulating the firstAndLast for each function
RaissaHughes
@RaissaHughes
Jun 24 2015 02:29
thanks for the info.. its my second my week my bad
Brett Guillory
@kurzninja
Jun 24 2015 02:29
no problem @raissa
Greg Haas
@izzaboo
Jun 24 2015 02:30
@timtouch That makes sense. I just pilfered some others' solutions to try and I could get none of them to work. Phew! Thought I was going bonkers.
Brett Guillory
@kurzninja
Jun 24 2015 02:30
but firstAndLast isn't stored anywhere, it's only passed in as the argument
I guess I'm too used to the Java class concept and it's screwing with my understanding here
Timothy Touch
@timtouch
Jun 24 2015 02:31
It was implicitly initialized in the args parameter
Brett Guillory
@kurzninja
Jun 24 2015 02:31
so is firstAndLast considered a variable of the object, even though it's not explicitly stored within the object?
RaissaHughes
@RaissaHughes
Jun 24 2015 02:31
// Check if the user is ready to play!
confirm("I understand confirm!")

var age = prompt("What's your age");
if(age < 13)
    {
console.log("You are allowed to play but I take no responsibilty!")
    }
else
if (age  > 13)

   {
    console.log("Have fun!")

    }
console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");

if (userAnswer === 10 % 2 ) {
    console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!") 
} else {console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");
}
i derd ert!!
Evan Aubry
@evanAubry
Jun 24 2015 02:32
This message was deleted
This message was deleted
Brett Guillory
@kurzninja
Jun 24 2015 02:33
good job Raissa :)
Evan Aubry
@evanAubry
Jun 24 2015 02:34
function chunk(arr, size) {
  if(arr.length % size === 0) {
    var multiArr = new Array(arr.length / size);
    for(i = 0; i < arr.length / size; i++) {
      multiArr[i] = new Array(size);
      for(j = 0; j < size; j++) {
        var k = (i * size) + j;
        multiArr[i][j] = arr[k];
      }
    }
  return multiArr;
  } else {
    var leftover = arr.length % size;
    var arrLengthNoRemainder = arr.length - leftover;
    var noRemainderGroups = arrLengthNoRemainder / size;
    var multiArr2 = new Array(noRemainderGroups);
    var arrRemainder = new Array(leftover);
    for(l = 0; l < noRemainderGroups; l++) {
      multiArr2[l] = new Array(size);
      for(m = 0; m < size; m++) {
        var n = (l * size) + m;
        multiArr2[l][m] = arr[n];
      }
    }
    for(o = 0; o < leftover; o++) {
      var p = arrLengthNoRemainder + o;
      arrRemainder[o] = arr[p];
    }
    multiArr2.push(arrRemainder);
    return multiArr2;
  }
}

chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], 3);
did i over complicate that?
cuz the other bonfires seemed easier
Brett Guillory
@kurzninja
Jun 24 2015 02:35
What Bonfire is that Evan?
Evan Aubry
@evanAubry
Jun 24 2015 02:35
chunky monkey
Steven Leiva
@StevenXL
Jun 24 2015 02:36
@evanAubry I can post my solution. It's shorter - not sure that means it is less complicated.
This message was deleted
This message was deleted
function chunk(arr, size) {
  var chunkyArray = [];
  var smallChunk = [];

  // iterate over each element of the array
  for (var index in arr) {
    // fill up our smallChunk array
    smallChunk.push(arr[index]);

    if (smallChunk.length === size) {
      // add smallChunk to chunkyArray and reset it
      chunkyArray.push(smallChunk);
      smallChunk = [];
    }
  }

  // when original array argument not divisible by size
  if (smallChunk.length > 0) {
    chunkyArray.push(smallChunk);
  }
  return chunkyArray;
}
Evan Aubry
@evanAubry
Jun 24 2015 02:38
thank you just what i was looking for
Brett Guillory
@kurzninja
Jun 24 2015 02:39
Thanks @timtouch, I just solved it. I think I understand better now :)
Timothy Touch
@timtouch
Jun 24 2015 02:39
@kurzninja It's all you
Steven Leiva
@StevenXL
Jun 24 2015 02:39
No problem. I created a new, empty array for the function to return, and I created a temporary array to fill with each element of the original array.
Brett Guillory
@kurzninja
Jun 24 2015 02:40
:D
Steven Leiva
@StevenXL
Jun 24 2015 02:40
Once my temporary array gets to a certain size, then I push that array onto the array returned by the function.
That last part where it tests if the temporary array is greater than 0 is there just to catch when the original array is not evenly divisible by the size argumet.
Evan Aubry
@evanAubry
Jun 24 2015 02:44
okay, i'm starting to understand it better, thanks again!
signing out of chat cya later
Steven Leiva
@StevenXL
Jun 24 2015 02:45
Bye. Glad to help.
Prashanth Chandra
@prashcr
Jun 24 2015 03:01
Regex question
What is [*]+ supposed to match?
seems really odd to me
since they're all meta-characters
JT Longino
@jtlongino
Jun 24 2015 03:43
@prashcr I don't think you'd normally see a Regex like that
Oh, never mind.
It matches one or more '*' symbols
The * doesn't mean anything special inside a [] grouping.
Tiffany White
@twhite96
Jun 24 2015 04:03

Need some help with this

var names ["Tiffany", "John", "Rick", "Jerri", "Joe"];
 for (var i = 0; i < names.length; i++) {
     console.log("I know someone called" " " + names[i]);
 }

I know I am not adding the space correctly to the Javascript string in console.log but I forget how

Timothy Touch
@timtouch
Jun 24 2015 04:05
@twhite96 I think you want var names =["Tiffany", "John", "Rick", "Jerri", "Joe"];
Tiffany White
@twhite96
Jun 24 2015 04:06
Ah! Got it thank
Erik W.
@PastorOfMuppets
Jun 24 2015 04:23
CSS/HTML5 noobie question: The waypoint instructions tell me that the classes I create should be inside <style></style> elements. So far I've been putting all of my classes inside the same set of <style></style> elements. Should I be creating separate sets for each class or is it okay to have them contained in the same set? And why?
Den McHenry
@denmch
Jun 24 2015 04:27
@PastorOfMuppets There's just one style element. It would go within the <head> element in your HTML document.
@PastorOfMuppets There are three ways to set styles:
  1. A style sheet proper (style.css), which is an external document linked in <head></head>
  2. A style element (<style></style>), which sits within <head></head>
  3. A style attribute (e.g., <p style="text-align: center"></p>), known as "inline style", within an individual element in your HTML document
@PastorOfMuppets The style sheet or the style element can hold style declarations for any and all items in your HTML document, while inline styles only apply to the individual elements they're part of.
Den McHenry
@denmch
Jun 24 2015 04:34
@PastorOfMuppets Finally, the style sheet can be applied to multiple HTML documents, and then individual styles can be overridden in the style element of individual pages. And individual page elements can override both with their own inline styles. That's part of the cascade in "cascading style sheets."
mailkev14
@mailkev14
Jun 24 2015 04:39
hey guys.. some help needed
I have a bonfire to calculate the orbital period
i searched on google for the solution and I implemented the same but it is not passing the tests
My Code is as follows

function orbitalPeriod(arr) {
var GM = 398600.4418,
earthRadius = 6367.4447;

return arr.map(function(obj){
return {
name: obj.name,
orbitalPeriod: Math.round( Math.sqrt( (GM * obj.avgAlt) / earthRadius) )
};
});
}

orbitalPeriod([{name : "sputkin", avgAlt : 35873.5553}]);

`function orbitalPeriod(arr) {
var GM = 398600.4418,
earthRadius = 6367.4447;

return arr.map(function(obj){
return {
name: obj.name,
orbitalPeriod: Math.round( Math.sqrt( (GM * obj.avgAlt) / earthRadius) )
};
});
}

orbitalPeriod([{name : "sputkin", avgAlt : 35873.5553}]);`

Den McHenry
@denmch
Jun 24 2015 04:43
Can you edit that and put three back ticks before and after the code?
mailkev14
@mailkev14
Jun 24 2015 04:43

```function orbitalPeriod(arr) {
var GM = 398600.4418,
earthRadius = 6367.4447;

return arr.map(function(obj){
return {
name: obj.name,
orbitalPeriod: Math.round( Math.sqrt( (GM * obj.avgAlt) / earthRadius) )
};
});
}

orbitalPeriod([{name : "sputkin", avgAlt : 35873.5553}]);
```

Den McHenry
@denmch
Jun 24 2015 04:44
Try a separate line for the first set :)
Grace
@dogbot101
Jun 24 2015 04:44
Hi there... anyone have any tips for the where do I belong bonfire... my code is:
mailkev14
@mailkev14
Jun 24 2015 04:45

function orbitalPeriod(arr) {
var GM = 398600.4418,
earthRadius = 6367.4447;

```  return arr.map(function(obj){

return {
name: obj.name,
orbitalPeriod: Math.round( Math.sqrt( (GM * obj.avgAlt) / earthRadius) )

```  });

}

orbitalPeriod([{name : "sputkin", avgAlt : 35873.5553}]);

Grace
@dogbot101
Jun 24 2015 04:45
function where(arr, num) {

  function compareNumbers(a, b) {
  return a - b;
}
  arr = arr.sort(compareNumbers);
  var i = 0;

  for(i in arr) {

    if(num < arr[i]) {
      return i;
    }

  }


}

where([40, 60], 50);
Den McHenry
@denmch
Jun 24 2015 04:45
function orbitalPeriod(arr) {
  var GM = 398600.4418,
  earthRadius = 6367.4447;
  return arr.map(function(obj){
    return {
      name: obj.name,
      orbitalPeriod: Math.round( Math.sqrt( (GM * obj.avgAlt) / earthRadius) )
    };
  });
}
orbitalPeriod([{name : "sputkin", avgAlt : 35873.5553}]);
mailkev14
@mailkev14
Jun 24 2015 04:45
@denmch how did u do that
Den McHenry
@denmch
Jun 24 2015 04:46
Three back ticks, then shift+enter for a new line, then the code.
Mario Mitchell
@undergroundfx
Jun 24 2015 04:46
you can do Where do I Belong without a loop, like this:
function where(arr, num) {
  var myarray = arr;
  myarray.push(num);
  myarray.sort();
  var location = myarray.indexOf(num);
  return location;
}

where([40, 60], 50);
Grace
@dogbot101
Jun 24 2015 04:48
Haha, well, that makes it easier now doesn't it..
Thank you @undergroundfx
mailkev14
@mailkev14
Jun 24 2015 04:48
@denmch any solution
Den McHenry
@denmch
Jun 24 2015 04:48
So, @mailkev14, your equation is a little off.
// orbitalPeriod: T = 2*pi * sqrt(R^3 / GM)
// R: semi Major Axis
Mario Mitchell
@undergroundfx
Jun 24 2015 04:49
push it into the array and then just sort it and return the index
Den McHenry
@denmch
Jun 24 2015 04:49
That's easier to read.
Mario Mitchell
@undergroundfx
Jun 24 2015 04:50
@dogbot101 no problem
mailkev14
@mailkev14
Jun 24 2015 04:50

@denmch oo

i went to this site to get the equation

Den McHenry
@denmch
Jun 24 2015 04:50
The first line is the equation for finding the orbital period, and you need not Earth radius, but the semi major axis of the satellite, which is Earth radius plus average altitude.
Den McHenry
@denmch
Jun 24 2015 04:51
And the semi major axis has to be defined for each individual item. One of the tests has I think three different satellites, so the semi major axis has to be defined within the map.
mailkev14
@mailkev14
Jun 24 2015 04:53

@denmch it worked now

tks a ton

Den McHenry
@denmch
Jun 24 2015 04:53
:thumbsup:
The equation was tricky.
Adie Williams
@adieCodes
Jun 24 2015 05:27
Hi all! Just completed Where art thou bonfire but really don't get Object.keys(). Is it just an alternative to a for/in loop?
Jeff Wilkey
@JeffWilkey
Jun 24 2015 06:19
hey @thewebologist
Adie Williams
@adieCodes
Jun 24 2015 06:33
Ehup @JeffWilkey I did read that and think I understand the syntax and what it returns but don't understand why it's used.
Is it just an alternative to for/in loop or have I completely missed the point
@JeffWilkey Having thought it through, I now understand its use. Think I just hacked it in my use
Elliescode
@EllieAdam
Jun 24 2015 06:49
G night!
mailkev14
@mailkev14
Jun 24 2015 07:02
hey guys anyone around
need help with the Pairwise Bonfire
mailkev14
@mailkev14
Jun 24 2015 07:14
anyone around?
Argentoratum
@Argentoratum
Jun 24 2015 08:35
Hi! What's wrong with this ? (Find the first element of an array where func is true)
function find(arr, func) {

  for (var i=0;i<arr.length;i++){
    if (func(i)){break;}

  }
  return arr[i];
}

find([1, 2, 3, 4], function(num){ return num % 2 === 0; });
solved it, sorry:)
MatthewDargis
@MatthewDargis
Jun 24 2015 09:07
Hi, I'm on the telephone check bonfire, and can anyone tell me why assert.deepEqual(telephoneCheck("(6505552368)"), false);expected true to deeply equal false
As far as I can tell that IS a valid phone number
Hugo
@HugoNebreda
Jun 24 2015 09:48
maybe
is for the "()" around the number
@MatthewDargis
6505552368 <--- valid phone number (in this bonfire)
(6505552368)<---- invalid phone number(in this bonfire)
Hugo
@HugoNebreda
Jun 24 2015 10:50

Anyone doing http://www.freecodecamp.com/challenges/zipline-use-the-twitch.tv-json-api ?

Here is my current progress
http://codepen.io/HugoNebreda/pen/oXGOQy

I can't get "status" property from TwitchChannel object updated from a JSON call
Anyone can help?

Krzysztof Miąsko
@kmiasko
Jun 24 2015 12:03
What do you mean? You're setting it to offline, and then set glyphicon-remove from that status property
willamgriffin
@willamgriffin
Jun 24 2015 12:08
does anyone have advice about bonfire: Mutations?
Krzysztof Miąsko
@kmiasko
Jun 24 2015 12:08
@HugoNebreda you probably have a async problem, your dom is getting set before json requests finish
Vos
@KrisVos130
Jun 24 2015 12:09
@willamgriffin Depends on what kind of advice, I don't want to accidently spoil something
willamgriffin
@willamgriffin
Jun 24 2015 12:10
so for i can get to location of the characters im searching for but not sure how to make that into a boolean answer
Vos
@KrisVos130
Jun 24 2015 12:11
@willamgriffin Well, if you find a characters you don't find in the other string in your for/while loop, you can immidietly return false and then all the way at the end return true if it hasn't come accross a character it's not supposed to find
willamgriffin
@willamgriffin
Jun 24 2015 12:14
oh yeah
i was over thinking
so you can basically assume true until you kit a false item hahaha
Costas Chaitas
@CostasChaitas
Jun 24 2015 12:49
anyone can help me with mutations bonfire?
Hugo
@HugoNebreda
Jun 24 2015 12:57
@kmiasko ahhhh that might be!
I'll check
Krzysztof Miąsko
@kmiasko
Jun 24 2015 12:59
@rasakos what the problem
's
Francesco
@FrancescoFilippi
Jun 24 2015 13:04
about HTML Entities, as I get this far the only proper way to fix the issue is actually skip that bonfire, right?
Krzysztof Miąsko
@kmiasko
Jun 24 2015 13:05
yes atm
when i was doing this bonfire, it was as easy as
function convert(str) { return str.replace(/&/g,'&amp;'); }
:D
Francesco
@FrancescoFilippi
Jun 24 2015 13:09
yea, that was my approach too. Glad to hear it wasn't my fault. Thanks :smile:
Costas Chaitas
@CostasChaitas
Jun 24 2015 13:59
@kmiasko it has bug but ty
Steven Leiva
@StevenXL
Jun 24 2015 14:35
Hi.
Can someone help me with the pairwise challenge?
My code is here.
It is failing the test when called with the following arguments: pairwise([1,1,1], 2);
According to the challenge, the results should be 1, but my function returns 0.
I might not be understanding the challenge correctly though. The values that sum up to 2 are at indexes: 0 & 1, 0 & 2, 1 & 0, 1 & 2, so my indexes variable is [0, 1, 2], which sums up to 3.
Steven Leiva
@StevenXL
Jun 24 2015 14:43
Hm.. I should have read the entire challenge - once an element has been used, it cannot be re-used.
Briana Swift
@brianamarie
Jun 24 2015 14:48
hey, anyone have time to help me out on the functional programming challenge at http://jhusain.github.io/learnrx/ ?
Ariel
@ArielLeslie
Jun 24 2015 14:51
@brianamarie What type of help do you need?
Briana Swift
@brianamarie
Jun 24 2015 14:52
On problem number 11, I'm pretty sure I have the correct answer and even when I click "show answer" it won't run correctly. Does someone mind running through to that point and seeing if you get the same bug?
Joe Balsamo
@Joe-Balsamo
Jun 24 2015 15:02
@Joe-Balsamo
Hey all, I tried to use some ECMAScript 6 specific stuff and got an error. Are we to avoid the newer stuff?
This is in the Bonfires, I should clarify.
Steven Leiva
@StevenXL
Jun 24 2015 15:06
@Joe-Balsamo I do not think they have implemented the new specifications.
Joe Balsamo
@Joe-Balsamo
Jun 24 2015 15:07
@StevenXL Thanks, I figured that was the case.
Steven Leiva
@StevenXL
Jun 24 2015 15:07
If you use the MDN JavaScript website for reference, they'll point out the stuff that is new.
Ariel
@ArielLeslie
Jun 24 2015 15:13
@brianamarie I get TypeError running the "answer"
Jessi L Wasell
@JessiW
Jun 24 2015 15:14
Hi - I just passed the Confirm the Ending Bonfire - I wondered if someone could explain to me why this worked? Not sure I get it :) Here's my code....
function end(str, target) {
  return str.substr(str.length-target.length)==target;
}

end('Bastian', 'n');
Joe Balsamo
@Joe-Balsamo
Jun 24 2015 15:15
@StevenXL yes, saw that. I rewrote my function without the newer stuff, but it’s not as clean.
Ariel
@ArielLeslie
Jun 24 2015 15:18
@brianamarie The code window in 11 doesn't seem to know about the code in ex 10. Add that concatAll code to 11
Lightwaves
@Lightwaves
Jun 24 2015 15:19
I did a very similar solution @JessiW
Ariel
@ArielLeslie
Jun 24 2015 15:20
@JessiW Why wouldn't it work? What part is confusing?
Jessi L Wasell
@JessiW
Jun 24 2015 15:20
Okay @Lightwaves - just not sure I understand why that worked?!
I had a if/else statement before that made more sense to me - I guess I don't get why subtracting target.length from str.length to equal the target works?\
how does that tell me its at the end of the string?
Ariel
@ArielLeslie
Jun 24 2015 15:23
@JessiW
This is what you're doing:
calculating the length of the string "str" calculating the length of the string "target"
subtracting the length of "target" from the length of "str" (the difference) getting a substring of "str" which starts at the end of the difference
checking to see if that substring is equivalent to "target" returning a boolean
I have no idea why that formatting got funky.
This is what you're doing:
1- calculating the length of the string "str"
2- calculating the length of the string "target"
3- subtracting the length of "target" from the length of "str" (the difference)
4- getting a substring of "str" which starts at the end of the difference
5- checking to see if that substring is equivalent to "target"
6- returning a boolean
Prathmesh Khedekar
@Optimus101
Jun 24 2015 15:24
Anyone for Bonfire: Find the Longest Word in a String?
Steven Leiva
@StevenXL
Jun 24 2015 15:25
@Joe-Balsamo Yea - I really like the stuff they are adding to JavaScript, but it seems like it is heading in the direction of Ruby, where a lot of methods are implemented in the new specification that right now we kind of have to implement ourselves.
Jessi L Wasell
@JessiW
Jun 24 2015 15:25
Okay - that makes sense! My if/else statement didn't pass so I started trying other things - which is how I ended up at this....Thanks for the clarification @arielleslie
Steven Leiva
@StevenXL
Jun 24 2015 15:25
I personally think it's a good thing, but a big change.
Ariel
@ArielLeslie
Jun 24 2015 15:25
You're welcome @JessiW
Karan Joisher
@karanjoisher
Jun 24 2015 15:25
Bonfire: Convert HTML Entities.... the code is passing all the tests except this one: assert.strictEqual('<>', '<>', 'should escape characters');should escape characters: expected '<>' to equal '<>'
Jessi L Wasell
@JessiW
Jun 24 2015 15:25
Thank you all :)
Krzysztof Miąsko
@kmiasko
Jun 24 2015 15:26
@karanjoisher skip it for now, it has a bug
Joe Balsamo
@Joe-Balsamo
Jun 24 2015 15:26
@StevenXL I like it as well. I remember the “bad old days” of C, where you literally wasted all day writing your function for darn near everything.
Lightwaves
@Lightwaves
Jun 24 2015 15:27
@StevenXL the way it seems that way is because emca6 is getting a lot of inspiration from coffeescript and coffeescript was written by..... Ruby developers at Github!
Karan Joisher
@karanjoisher
Jun 24 2015 15:27
thanks :)
Lightwaves
@Lightwaves
Jun 24 2015 15:27
@StevenXL so a lot of ruby and python nicities were added to emca6
Steven Leiva
@StevenXL
Jun 24 2015 15:29
@Lightwaves Sweeeet!
Like @Joe-Balsamo mentioned, why keep re-inventing the wheel?
Lightwaves
@Lightwaves
Jun 24 2015 15:29
@StevenXL list comprehensions that "May" be added in emca7 for example are essentially syntactic suger for map and filter and it's considered idiomatic to use a list/array comprehension in place of map and filter in python
Steven Leiva
@StevenXL
Jun 24 2015 15:30
I'm much more familar with Ruby than Python (though an beginner at both).
But I like how clean Ruby code is.
Anthony Harrington
@GhostParticle
Jun 24 2015 15:32
Ok, so apparently JScript has a different scope than other languages...im guessing, because from what i know and understand, any variable defined inside a function (at the top) should be usable throughout the entire function, including if statements and for statements inside the function, but if defined inside an if statement inside the function then it can only be used in the if statement... am i correct on this or am i out of bounds??????
Logan Tegman
@ltegman
Jun 24 2015 15:34
@GhostParticle JS is different in this regard. Not every set of curly braces creates a new scope, only new functions create a new scope. So when you create a variable inside an if block it still exists outside of that block
Anthony Harrington
@GhostParticle
Jun 24 2015 15:36
so why when i create a variable at the top of the function do i get errors when trying to use it within an if statement inside the function.. Error "variable not defined"
Logan Tegman
@ltegman
Jun 24 2015 15:37
@GhostParticle I would need to see your code, because generally that shouldn't happen.
Anthony Harrington
@GhostParticle
Jun 24 2015 15:37

such as
function alpha {
var x
if (code code code) {
code using x
}
more code using x
}

Answer: Error "x not defined"

Krzysztof Miąsko
@kmiasko
Jun 24 2015 15:39
by default x will be undefined
you need to assign something to it
Anthony Harrington
@GhostParticle
Jun 24 2015 15:39
@kmiasko ; yes, it has something.. but still states its undefined
Krzysztof Miąsko
@kmiasko
Jun 24 2015 15:39
so show actual code, not that pseudo ;)
Anthony Harrington
@GhostParticle
Jun 24 2015 15:39
that was just an example of the scoping
Anthony Harrington
@GhostParticle
Jun 24 2015 15:45
i got it.... facepalming
@kmiasko ... after thinking about what you posted i realized i created the variable (which was an array) but didnt tell it to be an array.. so when i was trying to push things into it i was getting the error
Krzysztof Miąsko
@kmiasko
Jun 24 2015 15:47
ok, nice you figured it out
Hugo
@HugoNebreda
Jun 24 2015 15:58
I have some problems with javascript and handling async tasks
Is there any pattern/structure to help typical "initialize, request, response, render" information?
I've seen libraries that helps you, but I maybe there is a simpler way to handle async task in js with jquery without using more libraries
Lightwaves
@Lightwaves
Jun 24 2015 16:02
Just finished mutations bonfire!
Lol I seriously need to finish the js waypoints but this is too fun
I was busting my brain trying to figure out how to iterate through two arrays using every and forEach somehow then I read the hint again and a pretty epic lightbulb went off on a much simpler way of verifying it.
Steven Leiva
@StevenXL
Jun 24 2015 16:06
@Lightwaves I'm stuck on that one.
I spent about an hour yesterday on it and got absolutely nowhere.
Briana Swift
@brianamarie
Jun 24 2015 16:06
@arielleslie thank you for your help!
Ariel
@ArielLeslie
Jun 24 2015 16:07
You're welcome @brianamarie
Steven Leiva
@StevenXL
Jun 24 2015 16:07
@arielleslie mentioned that there's a mathematical way of solving instead of figuring out all permutations and then deleting the ones we don't want to count.
Jeremiah Biard
@jeremiahbiard
Jun 24 2015 16:07
@HugoNebreda have you worked through the node.js Async tutorial from nodeschool.io?
Steven Leiva
@StevenXL
Jun 24 2015 16:07
But I couldn't get to that.
Lightwaves
@Lightwaves
Jun 24 2015 16:09
Haha my math skills unfortunately aren't good enough to figure it out
Krzysztof Miąsko
@kmiasko
Jun 24 2015 16:09
@HugoNebreda from jquery 1.5 (i think) all async tasks return promises, so you can use pipe, and done on them
Ariel
@ArielLeslie
Jun 24 2015 16:09
@StevenXL I haven't coded it up, but there is no reason you couldn't write a function that performs the mathematical calculation for permutations. I suspect you would need to import a better math library though.
Lightwaves
@Lightwaves
Jun 24 2015 16:09
I almost thought you might be able to do
Anthony Harrington
@GhostParticle
Jun 24 2015 16:09
Just making sure i am correct, but a string starts at zero...correct?
Krzysztof Miąsko
@kmiasko
Jun 24 2015 16:09
yes
Lightwaves
@Lightwaves
Jun 24 2015 16:09
I swear it's some modification of that formula would allow you to remove the repeats mathmatically but I definitely can't figure it out
Anthony Harrington
@GhostParticle
Jun 24 2015 16:10
thats what i thought
You will still need to count the number of unique characters
Steven Leiva
@StevenXL
Jun 24 2015 16:11
@arielleslie Thanks! I bookmarked the link and will take a look at it as soon as I have some time.
Lightwaves
@Lightwaves
Jun 24 2015 16:12
hmm I looked at the link maybe I wasn't far off at least in thought
Steven Leiva
@StevenXL
Jun 24 2015 16:12
Yup!
Jeremiah Biard
@jeremiahbiard
Jun 24 2015 16:12
@arielleslie @Lightwaves i'm thinking the function you're looking for is nChooseR
Ariel
@ArielLeslie
Jun 24 2015 16:13
I think it comes down to the choice of whether you want to count the number of unique letters at the beginning and avoid creating duplicate permutations, or whether you want to check each permutation against those already before adding it.
Lightwaves
@Lightwaves
Jun 24 2015 16:13
@jeremiahbiard yes and in the link n choose r is used
Ariel
@ArielLeslie
Jun 24 2015 16:15
Once you've psuedocoded both solutions, do a complexity analysis and let us know which is better :D
Steven Leiva
@StevenXL
Jun 24 2015 16:17
Hah - my gf is not a great cook, and we were in a hurry this morning. My lunch is a spinach salad with the only other two ingredients being cranberries and goat cheese.
Tastes awesome!
Ariel
@ArielLeslie
Jun 24 2015 16:18
@StevenXL Sounds better than my lunch. I just keep bread, peanut butter, and jelly in my cubicle.
Steven Leiva
@StevenXL
Jun 24 2015 16:19
That sounds pretty good too. I'm not picky. I can subsist on little.
Lightwaves
@Lightwaves
Jun 24 2015 16:21
Cheese I'm heading to a sandwich shop if you guys keep talking about food.
I just want to get off of work
lol cheese instead of jeez my mind is on food
Ariel
@ArielLeslie
Jun 24 2015 16:23
You must be in a later TZ than me @Lightwaves . I just got to work a couple hours ago.
Hugo
@HugoNebreda
Jun 24 2015 16:23
@jeremiahbiard nope, I'll give it a try
And @kmiasko I saw the promise thing but I didn't understand well for small examples.
Jeremiah Biard
@jeremiahbiard
Jun 24 2015 16:25
hmm, actually, if you want to brute force it, the simplest way is to create an array and push the permutations iff it doesn't already exist in the array, then return the array length
I think
I have to implement it
Anthony Harrington
@GhostParticle
Jun 24 2015 16:26
how does one post a picture in this chat
Lightwaves
@Lightwaves
Jun 24 2015 16:27
print screen
ctrl v
is one way
Anthony Harrington
@GhostParticle
Jun 24 2015 16:27
what about a saved image
Jeremiah Biard
@jeremiahbiard
Jun 24 2015 16:28
i like cominatorics and discrete math. it makes my head hurt though
Lightwaves
@Lightwaves
Jun 24 2015 16:28
you could possibly upload it imgur or some site like that then post the link
Anthony Harrington
@GhostParticle
Jun 24 2015 16:28
errr. one thing slack could do was put an image in chat without the use of third party apps
Lightwaves
@Lightwaves
Jun 24 2015 16:31
Ultraviolet_image_of_the_Cygnus_Loop_Nebula_crop.jpg
actually you could just drag it into a chat haha I guess I never tried it xD
Anthony Harrington
@GhostParticle
Jun 24 2015 16:31
hmm.. ill try, cause im in need of some advice
umm.PNG
Im not getting the lower case letters for some reason
Lightwaves
@Lightwaves
Jun 24 2015 16:35
hmm
it seems like you almost have it
Think of what your not including
Anthony Harrington
@GhostParticle
Jun 24 2015 16:38
I think i got it... i needed an else statement that just pushes the letter when false... as soon as i added that it placed everything correctly
Lightwaves
@Lightwaves
Jun 24 2015 16:40
GhostParticle once you verify your solution I can show you mine if you want.
Anthony Harrington
@GhostParticle
Jun 24 2015 16:41
Yea, im almost there.. i have been working on this one for several days trying different methods. Im sure there is an easier way to do this but im still learning alot of things and im just using what i know.
Im doing each part bit by bit to see what works the way i want it to, then adding more to get it to where i am going
Lightwaves
@Lightwaves
Jun 24 2015 16:42
That's a very good strategy
Krzysztof Miąsko
@kmiasko
Jun 24 2015 16:43
you don't have default in your switch
Lightwaves
@Lightwaves
Jun 24 2015 16:44
If you know what you want each part to do you can turn it into a function and have each part solve that specific sub problem and combine them all to get your solution.
Anthony Harrington
@GhostParticle
Jun 24 2015 16:44
Yea, now that its doing something to where i want it to go, i need to figure out how to seperate the words, i thought it would to begin with but when pushing them it didnt
I havent really worked with subs yet.. i will look at that bit later.. gotta roll to a VA appointment now. Thanks @Lightwaves for your help... helps to talk it out with someone sometimes
Godfrey Chiu
@ggwc82
Jun 24 2015 17:14
anyone here help me with an error i'm getting on the cashier bonfire?
Steven Leiva
@StevenXL
Jun 24 2015 17:15
@ggc100 I can try and help.
Godfrey Chiu
@ggwc82
Jun 24 2015 17:15
I get Uncaught TypeError: Cannot read property '1' of undefined when trying to access my change array
trying to do the following: change1[4][1] = change1[4][1] + 1
I believe my change array is an object
so for ['QUARTER', 0] I want to be able to increment this by 0.25, and ['ONE', 0] increment that by 1.00
Steven Leiva
@StevenXL
Jun 24 2015 17:21
can you send me your code?
Moisés Man
@moigithub
Jun 24 2015 17:25
wikipedia API is awfull tooooooo many parameters is confusing
Godfrey Chiu
@ggwc82
Jun 24 2015 17:26
This message was deleted
how do I copy it here?
Steven Leiva
@StevenXL
Jun 24 2015 17:26
@ggc100 if you have a github account, you can paste your code into gist.github.com
And then link here - it will show up.
Moisés Man
@moigithub
Jun 24 2015 17:27
triple backticks ` at start..
shift enter
paste code
triple backtick at end
Steven Leiva
@StevenXL
Jun 24 2015 17:28
Are you sure that cidcopy actually makes a copy of that object?
Godfrey Chiu
@ggwc82
Jun 24 2015 17:28
I think my overall algorithm appears correct, but just accessing and updating the cidcopy, change1 arrays (which using typeof, are actually objects)
Steven Leiva
@StevenXL
Jun 24 2015 17:28
I think what you are doing is pointing two variables to the same object
Godfrey Chiu
@ggwc82
Jun 24 2015 17:31
right i think i see
Steven Leiva
@StevenXL
Jun 24 2015 17:31
Also, I think you want to move your change1.filter outside of the while loop
Once you do that, you won't get the type error anymore.
Godfrey Chiu
@ggwc82
Jun 24 2015 17:34
ahh, good spot @StevenXL ! I moved the filter outside the while loop now. also did var cidcopy = Object.create(cid);
Moisés Man
@moigithub
Jun 24 2015 17:35
... toFixed return a string
1==="1" false
Godfrey Chiu
@ggwc82
Jun 24 2015 17:36
hmm...now it seems to be stuck in an endless loop
Moisés Man
@moigithub
Jun 24 2015 17:39

var totalcid = cid.reduce(function(a, b) {return a.concat(b);}).filter(function(value) {return typeof

value === "number";}).reduce(function(c,d) {return c + d;}).toFixed(2); <-- to fixed return a string....

Godfrey Chiu
@ggwc82
Jun 24 2015 17:39
@moigithub thanks. lemme check those
Moisés Man
@moigithub
Jun 24 2015 17:47
u no need to filter out when 0
but... u need to SORT it.. from higher to lower...
if (difference >= 100 && cid[8][1] > 0.00){... how u interpret it ?
Moisés Man
@moigithub
Jun 24 2015 17:52

@ggc100
lets says.. difference = 288.6
cid[8][1] .. i suppose is... ONE HUNDRED drawer cash available

soooo lets say... from ONE hundred bill u have 100

Godfrey Chiu
@ggwc82
Jun 24 2015 17:53
yep, i follow that
it subtracks the 100 from cidcopy (theres an error in that line, i replaced cid with cidcopy)
Moisés Man
@moigithub
Jun 24 2015 17:54

so at first loop..
change1[8][1] = change1[8][1] + 100;
cidcopy[8][1] = cidcopy[8][1] - 100;
difference -= 100;

difference will be 188.6
cidcopy[8][1] will be 0

and cid[8][1] will be 100 (Still )

Godfrey Chiu
@ggwc82
Jun 24 2015 17:55
yep thats correct, so it wont satisfy the if statement anymore, and will go to the next else if for the 20dollar
Moisés Man
@moigithub
Jun 24 2015 17:55
then on next loop
difference will be 88.6
cidcopy[8][1] will be -100
and cid[8][1] will be 100 (Still )
Godfrey Chiu
@ggwc82
Jun 24 2015 17:55
cid is a mistake, its meant to be cidcopy
if (difference >= 100 && cidcopy[8][1] > 0.00)
Moisés Man
@moigithub
Jun 24 2015 17:56
so it works now ? :)
Godfrey Chiu
@ggwc82
Jun 24 2015 17:56
crashes my chrome now
lol
Moisés Man
@moigithub
Jun 24 2015 17:57
refresh ur gist source code copy so i can take a look again :)
cidcopy is now a copy of cid, totalcid is a number
Godfrey Chiu
@ggwc82
Jun 24 2015 18:04
also, should my filter line change to this: change1 = change1.reverse();
duh! cidcopy is empty
actually I dont need to make a copy of cid, just change cid
Moisés Man
@moigithub
Jun 24 2015 18:08
i pasted ur code on repl.it and works...
Godfrey Chiu
@ggwc82
Jun 24 2015 18:10
thats weird
i tried the same and it works too
but not in chrome
in ie, it doesnt even run
Godfrey Chiu
@ggwc82
Jun 24 2015 18:18
right, it seems to crash when trying to compute the test case : drawer(3.26, 100.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]])
ahhh!!!
damn, I got it
I forgot to set upper bounds
**actually scrub that, it should still work
Moisés Man
@moigithub
Jun 24 2015 18:24
@ggc100 IF u have a difference of 0.001.. u will have a infinite loop... cuz still >0
Timothy Touch
@timtouch
Jun 24 2015 18:25
@moigithub I think you got it
Moisés Man
@moigithub
Jun 24 2015 18:26
so add a else.. at end.. and break;
Ariel
@ArielLeslie
Jun 24 2015 18:26
or just floor/round/cast the value so it evaluates to 0.
Lightwaves
@Lightwaves
Jun 24 2015 18:26
@moigithub when dealing with loops and floating points you need to have an epilson value or some value to check against which tells me something has gotten to small to continue looping.
Ariel
@ArielLeslie
Jun 24 2015 18:27
break statements should usually be avoided when possible (for most languages)
Moisés Man
@moigithub
Jun 24 2015 18:28
or instead while >0... while >=0.01 (wich is ur lowest value)
Godfrey Chiu
@ggwc82
Jun 24 2015 18:30
right, i see
but why does it not compute exactly? I had to add .reduce(2) at the end of my totalcid calc
update - it works for all but one test!
Moisés Man
@moigithub
Jun 24 2015 18:33
so no more crash.. thats good :)
Lightwaves
@Lightwaves
Jun 24 2015 18:34
here we go I found the example I was looking for but honesly I try and avoid loops and floating points for this reason
blob
Timothy Touch
@timtouch
Jun 24 2015 18:34
That's a lot of open tabs
Lightwaves
@Lightwaves
Jun 24 2015 18:34
Don't remind me lol
Timothy Touch
@timtouch
Jun 24 2015 18:35
Haha
Lightwaves
@Lightwaves
Jun 24 2015 18:35
That's an implementation of Newton–Raphson method to find a square root of a number
Godfrey Chiu
@ggwc82
Jun 24 2015 18:36
so now it only fails on this one: drawer(3.26, 100.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]])
the result in repl.it is [ [ 'TWENTY', 60 ],
[ 'TEN', 20 ],
[ 'FIVE', 15 ],
[ 'ONE', 1 ],
[ 'QUARTER', 0.5 ],
[ 'DIME', 0.2 ],
[ 'PENNY', 0.03 ] ]
the last object is meant to be ['PENNY', 0.04]!
Timothy Touch
@timtouch
Jun 24 2015 18:37
For me, exact change is all about that floating point precision error
This message was deleted
Godfrey Chiu
@ggwc82
Jun 24 2015 18:37
yes I got 3 lol
just need that last one penny
Timothy Touch
@timtouch
Jun 24 2015 18:38
It's like 0.0399999
Moisés Man
@moigithub
Jun 24 2015 18:38
what IF u remove toFixed(2) and parseFloat on top of ur code... to test
Godfrey Chiu
@ggwc82
Jun 24 2015 18:39
right, after doing the above I get totalcid 335.40999999999997
so it should be 335.41
the test fails btw
Lightwaves
@Lightwaves
Jun 24 2015 18:41
couldn't you round to 2 decimal points?
Jeremiah Biard
@jeremiahbiard
Jun 24 2015 18:41
actually if you want to see how bad javascript handles floating point, try
console.log( .1 + .2);
i got 0.30000000000000004
Lightwaves
@Lightwaves
Jun 24 2015 18:42
I think that's because 0.1 can't be represented exactly in binary
Timothy Touch
@timtouch
Jun 24 2015 18:42
basically
Jeremiah Biard
@jeremiahbiard
Jun 24 2015 18:42
does it matter why it's so awful?
Lightwaves
@Lightwaves
Jun 24 2015 18:42
so it prints out the closest approximation not 0.3
Moisés Man
@moigithub
Jun 24 2015 18:42
patch it :p sum a 0.00001
i used division and modulus on that exercise.. code was a bit longer
Godfrey Chiu
@ggwc82
Jun 24 2015 18:46
solved it! thank you guys, especially @moigithub!!
I added difference = Math.round(difference * 100) / 100; at the end of each else if statement
Lightwaves
@Lightwaves
Jun 24 2015 18:47
there we go!
Godfrey Chiu
@ggwc82
Jun 24 2015 18:47
I should read up about that floating point error thing, in case it crops up again!
Lightwaves
@Lightwaves
Jun 24 2015 18:47
@ggc100 read the article about the patriot missle
Godfrey Chiu
@ggwc82
Jun 24 2015 18:47
also, do you guys think the algorithm I chose is the most optimal one?
@Lightwaves googling now, sounds interesting
well that's one example of a floating point error mucking stuff up
blob
Just to show that it's not just javascript this shows up in a few languages because some floating points can't be represented exactly python hides it when you use the print statement but it doesn't mean it went away
Steven Leiva
@StevenXL
Jun 24 2015 18:51
@ggc100 I missed most of this conversation, but I get the general gist of what you guys are talking about.
Not all decimal numbers can be converted to binary, and at the end of the day, a computer only knows binary.
Lightwaves
@Lightwaves
Jun 24 2015 18:52
^^
Steven Leiva
@StevenXL
Jun 24 2015 18:53
Financial applications tend to keep a list of dollars that you have, and cents that you have to avoid that problem.
For the bonfire, I converted everything into pennies. So 1 $100 bill turned into 10,000 pennies.
That way, I don't have to worry about floating point.
I'm subtracting whole numbers from whole number.s
Jeremiah Biard
@jeremiahbiard
Jun 24 2015 18:54
it has to do with the ieee floating point representation, i think there's a way to do it that doesn't suck so hard but i haven't lookd into it too deeply
Lightwaves
@Lightwaves
Jun 24 2015 18:54
shields eyes from potential solution
seriously though that's a cool way of doing it.
Steven Leiva
@StevenXL
Jun 24 2015 18:55
No solutions forthcoming @Lightwaves ;)
Lightwaves
@Lightwaves
Jun 24 2015 18:55
haha I'm not that far yet anyways
Luke Pensiero
@VonCrab
Jun 24 2015 18:57
@StevenXL I had the same idea, converting all the cash into cents
Destino Dello
@destino92
Jun 24 2015 19:04
This message was deleted
help guys please
function convert(str) {
  // &colon;&rpar;
  return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g,'&apos');
}

convert('Dolce & Gabbana');
Moisés Man
@moigithub
Jun 24 2015 19:05
skip that exercise.. is bugged
Destino Dello
@destino92
Jun 24 2015 19:07
@moigithub i can i report it?
Steven Leiva
@StevenXL
Jun 24 2015 19:07
@VonCrab great minds think alik.e
Moisés Man
@moigithub
Jun 24 2015 19:07
staff already working on it.. i heard
Logan Tegman
@ltegman
Jun 24 2015 19:08
The Staging branch of the FCC code base already has a fix, so whenever they deploy it things should be good to go
Destino Dello
@destino92
Jun 24 2015 19:08
@moigithub got you
Daniel Simão
@simaodeveloper
Jun 24 2015 19:10
This message was deleted
Moisés Man
@moigithub
Jun 24 2015 19:15
any1 did or doin wikipedia zipline ? api is confusing.... and probably can explain me how get search results links ? or point me to another reference for noobs ? (will be a lot better if in spanish ) :)
Logan Tegman
@ltegman
Jun 24 2015 19:19
Unfortunately I'm still on the bonfires, otherwise I'd be happy to help.
Darryl Dixon - Piece Digital
@piecedigital
Jun 24 2015 19:22
This message was deleted
This message was deleted
Marquina
@Marquina
Jun 24 2015 19:25
Hi - can someone help me understand what I'm missing with http://www.freecodecamp.com/challenges/waypoint-responsively-style-radio-buttons
I have:
<div class='row col-xs-6'>

<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
</div>
I've tried wrapping each individual line element in a separate div with <div class='col-xs-6'></div> around it, but that's not correct either.
Johnathan Brown
@Legend28469
Jun 24 2015 19:27
@Marquina I’m don’t remember the exact excursus, but you are very close to doing it right
Zadious
@Zadious
Jun 24 2015 19:27
Hello, you will need to make a opening <div> and closing </div> around each of the individual li objects
Johnathan Brown
@Legend28469
Jun 24 2015 19:27
@Marquina You only use row once
@Marquina and then each one should have it’s own column
Zadious
@Zadious
Jun 24 2015 19:28
each of those div's has the class col-xs-6
then the outer div contains all of that, and has the class of row
Marquina
@Marquina
Jun 24 2015 19:29
I tried that as well (i think)
<div class='row'>
<ul>
<div class='col-xs-6'>
<li>cat nip</li>
</div>
<div class='col-xs-6'>
<li>laser pointers</li>
</div>
<div class='col-xs-6'>
<li>lasagna</li>
</div>
</ul>
</div>
That's not correct either.
Still not correct?
There is one div around all of them (class row), and each li has a div around it (class col-xs-6).
Johnathan Brown
@Legend28469
Jun 24 2015 19:31
@Marquina I just went throught it right now to make sure it works and it does. Let me examine your code for a sec
Zadious
@Zadious
Jun 24 2015 19:31
That looks correct. Are they all indented correctly? I've ran into a problem where the code was right, but I had to tab in on the nested li objects
Marquina
@Marquina
Jun 24 2015 19:32
Yes, the indents are in the actuall code.
*actual
Johnathan Brown
@Legend28469
Jun 24 2015 19:32
I got it
You’re working on the radio buttons correct?
Marquina
@Marquina
Jun 24 2015 19:32
Does it all need to be in a form element? There was something about a form in the help text on the page.
yes, just the radio buttons. Not the numbers.
Johnathan Brown
@Legend28469
Jun 24 2015 19:33
Gotcha, your code is correct, but it’s in the wrong part
Marquina
@Marquina
Jun 24 2015 19:33
Is the ul tag in the right spot?
Johnathan Brown
@Legend28469
Jun 24 2015 19:33
No
Radio buttons are the 2 circles
Indoor and outdoor
Marquina
@Marquina
Jun 24 2015 19:33
ah haha! you're right.
thanks mega duh.
later!
Johnathan Brown
@Legend28469
Jun 24 2015 19:34
Lol, no worries. Happens all the time
@Marquina Happy Coding!
Marquina
@Marquina
Jun 24 2015 19:34
bam! works.
thanks again
Johnathan Brown
@Legend28469
Jun 24 2015 19:34
@Marquina Anytime
Stjepan Mazalovic
@stjema
Jun 24 2015 19:34
aren't functions the same as having a text file with some code snippets, then copy&paste it if needed?
Johnathan Brown
@Legend28469
Jun 24 2015 19:37
@stjema I don’t understand your question
Ariel
@ArielLeslie
Jun 24 2015 19:38
me neither
Stjepan Mazalovic
@stjema
Jun 24 2015 19:38
a function is like a macro or?
you press 4 and it execute something
you type the function name and it executes it.
Ariel
@ArielLeslie
Jun 24 2015 19:39
@stjema are you talking about javascript?
Stjepan Mazalovic
@stjema
Jun 24 2015 19:40
ya and in genral
Miguel Correa
@miguelc1221
Jun 24 2015 19:41
can someone explain how this equals 11
For example, pairwise([1, 4, 2, 3, 0, 5], 7) should return 11 because 4, 2, 3 and 5 can be paired with each other to equal 7.
its from the pairwise bonfire
Ariel
@ArielLeslie
Jun 24 2015 19:42
a function (or a method, depending on the language) is a behavior captured in code. There are lots of ways to call (or "invoke" ) a function
It will be more code that truly calls the function, but there may or may not be an action taken by the user to cause that to happen.
Stjepan Mazalovic
@stjema
Jun 24 2015 19:45
HM
Logan Tegman
@ltegman
Jun 24 2015 19:46
@miguelc1221 4 and 3 (indices 1 and 3) make a pair, 2 and 5 (indices 2 and 5) make a pair. Add the indices (1+3+2+5) and you get 11
Took me a while to realize it was wanting a sum of the indices.
Miguel Correa
@miguelc1221
Jun 24 2015 19:47
thank you!
Steven Leiva
@StevenXL
Jun 24 2015 20:05
Sigh.
Ariel
@ArielLeslie
Jun 24 2015 20:07
what's ailing you now @StevenXL ?
Steven Leiva
@StevenXL
Jun 24 2015 20:13
lol - sorry.
It's still the permutations bonfire.
BL Hill
@montythemack
Jun 24 2015 20:14
This message was deleted
Lightwaves
@Lightwaves
Jun 24 2015 20:20
I just did the drop it bonfire and I had one of those wait seriously... and this answer is too obvious to be right
moments
Steven Leiva
@StevenXL
Jun 24 2015 20:21
which one is the drop it bonfire?
Lightwaves
@Lightwaves
Jun 24 2015 20:21
bonfire 34
I'm stopping at finishing half the bonfires then taking a break.
Robert Lin
@Rlin415
Jun 24 2015 20:23
Hi can someone help me with bonfire 38?
I don't think I am completely understanding the problem
Miguel Correa
@miguelc1221
Jun 24 2015 20:25
ok…so this might be a stupid question but whast does it mean to indice a number?
i thought i knew but guess i dont
Moisés Man
@moigithub
Jun 24 2015 20:26
click on "More information" @Rlin415 and read about argumentsobject ?

@Rlin415 a simple test to start would be...

function add() {
  console.log(arguments);
}

add(2,3);

then open devtools (control shift i ) and check on console what u have logged

Lightwaves
@Lightwaves
Jun 24 2015 20:29

@Rlin415 haven't solved it yet but to help you understand the problem,
Say I have a function called multiply that takes two arguments x and y and I call it

Multiply(3,6)
18
Multiply(18,3)
54

what they want you to do is if you call this function whatever it is without all it's arguments it returns a new function so something like

var Multiplyby3 = Multiply(3)

Multiplyby3(4)
12
Mutiplyby3(5)
15

Moisés Man
@moigithub
Jun 24 2015 20:30
@miguelc1221 en cual ejercicio estas?
Lightwaves
@Lightwaves
Jun 24 2015 20:30
so in this case I provided the x argument and this function needed it's y argument to finish running
Miguel Correa
@miguelc1221
Jun 24 2015 20:30
@moigithub Pairwise
Moisés Man
@moigithub
Jun 24 2015 20:31
y que parte no entiendes ?
Robert Lin
@Rlin415
Jun 24 2015 20:31
I think I am understanding it a bit more now. Where I am really stuck at is how do I grab the second argument that was provided in the test like this
add((2)(3))
Miguel Correa
@miguelc1221
Jun 24 2015 20:32
@moigithub que es indices
Lightwaves
@Lightwaves
Jun 24 2015 20:32
Haven't done it yet
Timothy Touch
@timtouch
Jun 24 2015 20:32
Lightwaves
@Lightwaves
Jun 24 2015 20:32
so I can't quite guide you on that.
Moisés Man
@moigithub
Jun 24 2015 20:33
a=["uno", "dos", "tres","cuatro"]
a[2] <--- q valor devuelve este ?
Robert Lin
@Rlin415
Jun 24 2015 20:33
Alright but thank you for trying still!
Lightwaves
@Lightwaves
Jun 24 2015 20:33
that will probably help me too. I know about the concept At least on how it relates to partial application
thanks @timtouch
Miguel Correa
@miguelc1221
Jun 24 2015 20:33
@moigithub tres
Moisés Man
@moigithub
Jun 24 2015 20:33
@miguelc1221 "uno", "dos", "tres","cuatro" son los valores... y el 2 ( a[2] ) es el indice
Miguel Correa
@miguelc1221
Jun 24 2015 20:33
no index….(indices)
Moisés Man
@moigithub
Jun 24 2015 20:34
indices es plural de index
Miguel Correa
@miguelc1221
Jun 24 2015 20:34
@moigithub anda el diablo que estupido soy haha
Moisés Man
@moigithub
Jun 24 2015 20:34
^^
Lightwaves
@Lightwaves
Jun 24 2015 20:34
LOL
Miguel Correa
@miguelc1221
Jun 24 2015 20:34
estaba piensando en power
Harshit Kedia
@harshitKedia
Jun 24 2015 20:35
whats the meaning of "<h1>" in this code: <h1>Hello</h1>
Moisés Man
@moigithub
Jun 24 2015 20:35
thats a header html tag
Harshit Kedia
@harshitKedia
Jun 24 2015 20:36
1 mean?
evaristoc
@evaristoc
Jun 24 2015 20:36
@miguelc1221 y @migithub: hispano-parlantes! no sabia que hablabas espanhol, @miguelc1221
Moisés Man
@moigithub
Jun 24 2015 20:36
html have 6 header tags... <h1> ... to <h6>
Harshit Kedia
@harshitKedia
Jun 24 2015 20:36
ok thanks. I am beginning to learn
Moisés Man
@moigithub
Jun 24 2015 20:37
h1 have bigger font size than others....and h6 smallest font size
Robert Lin
@Rlin415
Jun 24 2015 20:37
oh haha I got it guys I was seeing the test completely wrong lol
it was add(2(3))
Moisés Man
@moigithub
Jun 24 2015 20:37
...and ofcource it can be changed with styles
Miguel Correa
@miguelc1221
Jun 24 2015 20:37
si
Robert Lin
@Rlin415
Jun 24 2015 20:37
thanks everyone
Harshit Kedia
@harshitKedia
Jun 24 2015 20:37
thank you @moigithub
evaristoc
@evaristoc
Jun 24 2015 20:39
@miguelc1221 y @mogithub: bueno ya nos veremos por alli! y si, cualquiera se enreda con index e indice, el ingles es una pasada...
Estamos en contacto
Shannon Latham
@shannon-latham
Jun 24 2015 20:39
@harshitKedia Here is a good reference for the available HTML tags MDN Html Element Reference
Miguel Correa
@miguelc1221
Jun 24 2015 20:40
@evaristoc haha claro
Harshit Kedia
@harshitKedia
Jun 24 2015 20:40
@Aesier thank you
Shannon Latham
@shannon-latham
Jun 24 2015 20:42
@harshitKedia Your welcome! Hope it helps.
Moisés Man
@moigithub
Jun 24 2015 20:43
@miguelc1221 @evaristoc yo voy por los ziplines... ahora estoy con el wikipedia zipline
Miguel Correa
@miguelc1221
Jun 24 2015 20:45
@moigithub nice, yo todavia necisito sabe usar ajax
RockefellerCode
@RockefellerCode
Jun 24 2015 20:55
Wonderful link @Aesier Thank you
Though you weren't Talkin to me lol
How long is this HTML CSS part anyway? I'm ready to code
Rasheed Bustamam
@abustamam
Jun 24 2015 20:58
its pretty short
RockefellerCode
@RockefellerCode
Jun 24 2015 21:03
cool
Cromwell James Cutaran
@CromwellCutaran
Jun 24 2015 21:03
I searched online for what the Bootstrap CSS "img-responsive" class does exactly but still can not see why it is useful. Could anyone clarify?
Rasheed Bustamam
@abustamam
Jun 24 2015 21:07
It makes the image scale.
So try resizing your window downwards
you'll see that the responsive image gets smaller as the screen gets smaller
Harshit Kedia
@harshitKedia
Jun 24 2015 21:07
What's the meaning of the semi-colon(;) in the HTML code: "<style>h2 {color: red;}</style>"
Rasheed Bustamam
@abustamam
Jun 24 2015 21:07
compare that to a non-responsive image, set statically at 300px x 400px, where it stays that size all the time @CromwellCutaran
@harshitKedia the semicolon marks the end of a CSS statement
You can think of it as a period at the end of a programming statement, but it's not really equivalent
Harshit Kedia
@harshitKedia
Jun 24 2015 21:08
thank you @abustamam
Grace
@dogbot101
Jun 24 2015 21:08
Does anyone know how to remove duplicates in an array in javascript?
Shannon Latham
@shannon-latham
Jun 24 2015 21:08
@RockefellerCode The link that I posted is pretty extensive. FCC doesn't cover that many.
Rasheed Bustamam
@abustamam
Jun 24 2015 21:10
@dogbot101 there's an algorithm for that... feel free to private message me
Colin H.
@clnhll
Jun 24 2015 21:25
anyone know anything about twitter oauth?
RockefellerCode
@RockefellerCode
Jun 24 2015 21:33
stuck at 'fa-thumbs-up' juncture the Thumb is in the button! Why can't i just go to the next lesson?
yeah half of them i've never seen before @Aesier
Lightwaves
@Lightwaves
Jun 24 2015 21:38
@clnhll good luck is all I'm saying toward that... The OAuth Dance is a major pain in the ass. I remember getting google+ to work and maybe facebook didn't try the rest.
Colin H.
@clnhll
Jun 24 2015 21:43
@lightwaves hahaha thanks
JMitnik
@JMitnik
Jun 24 2015 21:44
Hey guys, quick question unrelated to any bonfires: if you have a String.prototype.customFunction which is supposed to refer to a string, how do you refer to the string parameter inside the prototype funtion?
RockefellerCode
@RockefellerCode
Jun 24 2015 21:47
This message was deleted
Howard-S
@Howard-S
Jun 24 2015 22:00
im stuck on an assignment! help
Timothy Touch
@timtouch
Jun 24 2015 22:02
@Howard-S What's up?
Howard-S
@Howard-S
Jun 24 2015 22:04
@timtouch could you see the assignment Waypoint: Override Styles or should i send you the question?
Timothy Touch
@timtouch
Jun 24 2015 22:04
Override Styles with Important?
Howard-S
@Howard-S
Jun 24 2015 22:05
i guess it should be !important
RockefellerCode
@RockefellerCode
Jun 24 2015 22:06
does anyone see anything wrong here: <button
        class=


        "fa fa-thumbs-up btn btn-block btn-primary"<i></i> 

  Like


</button>
trying to put <i> element in the <button> element!
Timothy Touch
@timtouch
Jun 24 2015 22:06
Are you stuck on where to put the !important?
RockefellerCode
@RockefellerCode
Jun 24 2015 22:07
no!!! trying to put an <i> element within the <button> element
Howard-S
@Howard-S
Jun 24 2015 22:08
@timtouch No, they want you to the following "Your h2 element should have the class "blue-text".
Your h2 element should have the class "urgently-red".
Your h2 element should be red." Where/how do I do the last step?
RockefellerCode
@RockefellerCode
Jun 24 2015 22:08
oops thought you were talking to me (laughter)
Timothy Touch
@timtouch
Jun 24 2015 22:08
what do you have so far?
Howard-S
@Howard-S
Jun 24 2015 22:10
i need to copy/paste . BRB
Timothy Touch
@timtouch
Jun 24 2015 22:11
@Howard-S Did you add the blue-text and urgently-red classes to the h2?
Howard-S
@Howard-S
Jun 24 2015 22:11
doing it now
ok now up to the last part - the one i cant figure out
Timothy Touch
@timtouch
Jun 24 2015 22:14
@RockefellerCode I believe your put the fa fa-thumbs-up class in the <i> tag
@Howard-S Is your h2 still blue?
Howard-S
@Howard-S
Jun 24 2015 22:17
@timtouch no, it shows up as red but the "challenge" says Your h2 element should be red
thats hard to read, sorry

<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>

<style>
.red-text {
color: red;
}

<style>
.blue-text {
color: blue;
}


h2 {
font-family: Lobster, Monospace;
}

h2 {

.blue-text
color: blue

}


p {
font-size: 16px;
font-family: Monospace;

!important: <style> .urgently-red { color: red !important; } </style>

</style>

<h2 class='blue-text'</h2>

<h2 class='urgently-red'</h2>

<h2 class='red-text'</h2>

<h2 class='red-text'>CatPhotoApp</h2>

<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

Timothy Touch
@timtouch
Jun 24 2015 22:20
You can use the ``` on the line before and after your code to format it
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<style>
.red-text {
color: red;
}

<style>
.blue-text {
color: blue;
}


h2 {
font-family: Lobster, Monospace;
}

h2 {

.blue-text
color: blue

}


p {
font-size: 16px;
font-family: Monospace;

!important: <style> .urgently-red { color: red !important; } </style>
</style>
<h2 class='blue-text'</h2>
<h2 class='urgently-red'</h2>
<h2 class='red-text'</h2>
<h2 class='red-text'>CatPhotoApp</h2>
<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
Howard-S
@Howard-S
Jun 24 2015 22:21
@timtouch ok
Timothy Touch
@timtouch
Jun 24 2015 22:22
@Howard-S If you want to add multiple classes to an element, just separate them with a space
< h1 class=" first second third">
Howard-S
@Howard-S
Jun 24 2015 22:22
do you see where i'm stuck?
Shouldnt line 37 (before the CatPhotoApp) meet the requirement?
Timothy Touch
@timtouch
Jun 24 2015 22:25
If you do it like that, you are creating multiple elements unrelated to each other
Howard-S
@Howard-S
Jun 24 2015 22:25
how would u fix it in order to get this finished?
Timothy Touch
@timtouch
Jun 24 2015 22:28

take away

<h2 class='blue-text'</h2>
<h2 class='urgently-red'</h2>
<h2 class='red-text'</h2>

and add the blue-text and urgently-red classes to the <h2>CatPhotoApp </h2>

Howard-S
@Howard-S
Jun 24 2015 22:30
trying now
RockefellerCode
@RockefellerCode
Jun 24 2015 22:30
It Worked! <button class='btn btn-block btn-primary'><i class='fa fa-thumbs-up'></i>Like
</button> Thanks @timtouch
Ariel
@ArielLeslie
Jun 24 2015 22:31
@timtouch those first h2 tags aren't opened and closed properly either
@RockefellerCode :clap:
Timothy Touch
@timtouch
Jun 24 2015 22:32
@arielleslie Ah, you're right. These eyes aren't what they used to be.
Ariel
@ArielLeslie
Jun 24 2015 22:33
I'm at my screen-blindness point in the day, so I'm making those same errors.
Candis Wasell
@CandiW
Jun 24 2015 22:34
Hi - could someone help me out with the Bonfire Return Largest Number in Arrays? Someone tried to help me last night and I wanted to thank whomever it was.....anyway - here's the code:
function largestOfFour(arr) {
  // You can do this!
  var results = [];
  for (var i = 0; i < arr.length; i++){
    results.push();
    return results;
  }
  var largest = [];
  for (var n = 0; n < arr[i].length; n++){
    largest.push();
    return arr[n].length;
  }
  if (n[0] > n[1]){
    largest = 0;
    largest = Math.max.apply(Math, arr[i], arr[n]);
  } return largest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
right now i'm only getting an empty array....
Rasheed Bustamam
@abustamam
Jun 24 2015 22:35
you have a bunch of return statements
once there's a return statement, the function is done
Howard-S
@Howard-S
Jun 24 2015 22:36
@timtouch hey Tim, it didnt work but I'll re-do it later. I need a break all of the letters are starting to look the same. Thanks for the help!
Candis Wasell
@CandiW
Jun 24 2015 22:36
ok - would console.log be better then?
Rasheed Bustamam
@abustamam
Jun 24 2015 22:36
so in your first for-loop, you're returning results
Well, you still want a return statement; console.log is great for debugging though
Candis Wasell
@CandiW
Jun 24 2015 22:37
i'm going to try it out....
Timothy Touch
@timtouch
Jun 24 2015 22:37
@Howard-S Haha, I know what you mean
Howard-S
@Howard-S
Jun 24 2015 22:37
ahh my retinas LOL
adcor
@adcor
Jun 24 2015 22:38
I have a quick question. I can't seem to push a value from inside a forEach loop to an external array. Why is that?
Timothy Touch
@timtouch
Jun 24 2015 22:38
@adcor How do you reference the external array?
Moisés Man
@moigithub
Jun 24 2015 22:39
probably variable scope ??
Ariel
@ArielLeslie
Jun 24 2015 22:39
And what do you mean by "external"? outside of the function or inside the function but outside the loop?
This message was deleted
Howard-S
@Howard-S
Jun 24 2015 22:40
@timtouch Re-done and it worked - THANKS!
adcor
@adcor
Jun 24 2015 22:40
function where(collection, source) {
var arr = [];
var srcKey = Object.keys(source);
console.log(srcKey);
var arrAns = source[srcKey];
function arrPush(value, index, arr){
if(value[srcKey] === arrAns){
arr.push( value) ;
};
};
collection.forEach(arrPush);
return arr;
}
ooo, let me see if I can make that prettier
Timothy Touch
@timtouch
Jun 24 2015 22:40
@Howard-S Anytime
Grace
@dogbot101
Jun 24 2015 22:41
Hi helpers... I'm working on Diff Two Arrays Bonfire and have this code:
Howard-S
@Howard-S
Jun 24 2015 22:41
you'll regret that!
Grace
@dogbot101
Jun 24 2015 22:41
function diff(arr1, arr2) {
var newArr =[]; 
function isMissing(element) {
  return arr1.indexOf(element) ==-1  ; 
}

  newArr.push(arr1.filter(isMissing));
}

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Candis Wasell
@CandiW
Jun 24 2015 22:42
ok - I did console.log and it tells me that it 'can't read property 'length' of undefined'?? not sure what i'm doing wrong!
function largestOfFour(arr) {
  // You can do this!
  var results = [];
  for (var i = 0; i < arr.length; i++){
    results.push();
    console.log(results);
  }
  var largest = [];
  for (var n = 0; n < arr[i].length; n++){
    largest.push();
    console.log(largest);
  }
  if (n[0] > n[1]){
    largest = 0;
    largest = Math.max.apply(Math, arr[i], arr[n]);
  } return largest;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
adcor
@adcor
Jun 24 2015 22:43
'''
function where(collection, source) {
var arr = [];
var srcKey = Object.keys(source);
console.log(srcKey);
var arrAns = source[srcKey];
function arrPush(value, index, arr){
if(value[srcKey] === arrAns){
var val = value;
return val;
};
};
collection.forEach(arrPush);
return arr;
}
'''
ookay, I guess I don't understand code formatting
Moisés Man
@moigithub
Jun 24 2015 22:43
@adcor use backticks ``` alt + 96 .. instead of apostrophes
Timothy Touch
@timtouch
Jun 24 2015 22:44
@adcor use the same key as ~
Grace
@dogbot101
Jun 24 2015 22:44
@CandiW I think for the push method, you need to put something in the parentheses that you want to add to your array...
Candis Wasell
@CandiW
Jun 24 2015 22:45
@dogbot101 : thanks - i'll try that :)
adcor
@adcor
Jun 24 2015 22:46
function where(collection, source) {
var arr = [];
var srcKey = Object.keys(source);
console.log(srcKey);
var arrAns = source[srcKey];
function arrPush(value, index, arr){
if(value[srcKey] === arrAns){
var val = value;
return val;
};
};
collection.forEach(arrPush);
return arr;
}
Grace
@dogbot101
Jun 24 2015 22:46
@Candi, also for the array,
adcor
@adcor
Jun 24 2015 22:46
lol getting closer
Ariel
@ArielLeslie
Jun 24 2015 22:46
You have a function within a function
Moisés Man
@moigithub
Jun 24 2015 22:46
@adcor acording to https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Objetos_globales/Array/forEach
Array.forEach can have only 2 arguments.. 1 of 'em is optional
and acording to the examples on that page ... the callback only have 1 argument
not 3 like urs function arrPush(value, index, arr){ ....
Timothy Touch
@timtouch
Jun 24 2015 22:46
functionception!
Sorry, I had to...
adcor
@adcor
Jun 24 2015 22:48
would that really affect pushing to the array though?
Timothy Touch
@timtouch
Jun 24 2015 22:48
@dogbot101 You aren't returning anything
adcor
@adcor
Jun 24 2015 22:49
amazing! @moigithub Why did that work?
Grace
@dogbot101
Jun 24 2015 22:49
whoops, sorry @Candi I meant, @CandiW ...
Hmm @timtouch I'd have to fix that, thank you
Candis Wasell
@CandiW
Jun 24 2015 22:49
that's ok :)
Moisés Man
@moigithub
Jun 24 2015 22:51
@adcor on ur code i dont see any arr.push()
Timothy Touch
@timtouch
Jun 24 2015 22:51
@dogbot101 try doing arr2.filter instead of arr1.filter
Otherwise the array is checking against itself
Grace
@dogbot101
Jun 24 2015 22:52
Hmm, still coming out undefined
Timothy Touch
@timtouch
Jun 24 2015 22:53
What are you returning from the function?
adcor
@adcor
Jun 24 2015 22:53
@moigithub Yeah, I realized, that was code I was messing with but wasn't working. this is the code
var arr = [];
    var srcKey = Object.keys(source);
    console.log(srcKey);
    var arrAns = source[srcKey];
          function arrPush(value, index){
                 if(value[srcKey] === arrAns){
                       var val = value;
                       arr.push(val); 
                 };
  };
  collection.forEach(arrPush);
  return arr;
Ariel
@ArielLeslie
Jun 24 2015 22:54
get the function out of the other function
adcor
@adcor
Jun 24 2015 22:55
@arielleslie is that not a good practice, if so why? Also, this is really just me playing around to try and find other ways to answer the problem. How could one solve this problem without using a function within a function and still using a forEach loop
Timothy Touch
@timtouch
Jun 24 2015 22:55
@dogbot101 You also don't need to push arr2.filter(isMissing) into newArr because filter() returns an array already
Ariel
@ArielLeslie
Jun 24 2015 22:56
You can call a function from within another function, but you don't define it there.
I'm honestly not sure if you even can.
But in this case you aren't even calling the inner function (arrPush)
gabazine
@gabazine
Jun 24 2015 22:57
relaxing time, just completed jquery waypoint 3
Ariel
@ArielLeslie
Jun 24 2015 22:57
Functions don't run like a loop. they have to be invoked.
adcor
@adcor
Jun 24 2015 22:57
well this code works
Ariel
@ArielLeslie
Jun 24 2015 22:57
the one you posted last?
oh. I see where you call it. My bad on that.
adcor
@adcor
Jun 24 2015 22:58
s'all good
Candis Wasell
@CandiW
Jun 24 2015 23:00
oh boy - now I'm getting 'your code is either too slow, has a fatal error, or an infinite loop' !!
function largestOfFour(arr) {
  // You can do this!
  var results = [];
  for (var i = 0; i < arr.length; i++){
    arr.push(results[i]);
    console.log(results[i]);
  }
  var largest = 0;
  for (var n = 0; n < arr[i].length; n++){
    arr.push(largest[n]);
    console.log(largest[n]);
  }
  if (n[0] > n[1]){
    largest = 0;
    largest = Math.max.apply(Math, arr[i], arr[n]);
  } return largest;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Candis Wasell
@CandiW
Jun 24 2015 23:02
ok - thanks - I will take a look
Ariel
@ArielLeslie
Jun 24 2015 23:03
your four loops are both adding a value onto the end of the array on ever iteration and don't stop until they hit the end. Therefore they will never stop.
Candis Wasell
@CandiW
Jun 24 2015 23:04
hmmm.....is there a better way to do this then?
Moisés Man
@moigithub
Jun 24 2015 23:05
@adcor so what was ur question ?? was checking ur last code.. though was the same u posted earlier
Lightwaves
@Lightwaves
Jun 24 2015 23:06
@CandiW also look at map I shared my code with someone he did it one way and I did it another both of us were surprised and intrigued how the other did it.
Candis Wasell
@CandiW
Jun 24 2015 23:07
@dogbot101 @timtouch I'm going to rework my code using the array.reduce() and see if I can get it to work.....I agree that the array.length isn't working for me
@Lightwaves I'm always interested in how others are solving their challenges....it's interesting how coding works
what is map?
Timothy Touch
@timtouch
Jun 24 2015 23:09
array.map() is another useful function
Lightwaves
@Lightwaves
Jun 24 2015 23:09
@CandiW In a nutshell map performs some function on each thing in an array.
Candis Wasell
@CandiW
Jun 24 2015 23:10
ok - thanks for the clarification :) I'll try that too....thank you everyone for the help - going to go try this out
Lightwaves
@Lightwaves
Jun 24 2015 23:10

@CandiW
so I could do something like var arr = [1,2, 3]
arr.map(function(){return x+1;}); and you'd get

[2,3,4]

Candis Wasell
@CandiW
Jun 24 2015 23:11
@Lightwaves : sounds good - i will try that
Moisés Man
@moigithub
Jun 24 2015 23:12

I have a quick question. I can't seem to push a value from inside a forEach loop to an external array. Why is that?

ok.. i had to scroll :)

reason is this::

function where(collection, source) {
var arr = [];
var srcKey = Object.keys(source);
console.log(srcKey);
var arrAns = source[srcKey];
function arrPush(value, index, arr){

u have declared var arr on top...
and inside ur internal function u also have arr as argument/parameter

so when u do inside ur func arr.push it reference the arr argument.. not the first arr variable u declared

@adcor
any1 doin wikipedia zipline ??
Candis Wasell
@CandiW
Jun 24 2015 23:14
@Lightwaves quick question - are the for loops applicable in this case? or should I try something else?
Moisés Man
@moigithub
Jun 24 2015 23:15
Array map filter reduce all have internal foor loops
Lightwaves
@Lightwaves
Jun 24 2015 23:16
what @moigithub said
Candis Wasell
@CandiW
Jun 24 2015 23:16
ok - thanks, just double-checking what I was thinking
Lightwaves
@Lightwaves
Jun 24 2015 23:17
@CandiW one way to think of reduce is like a cursor. the cursor keeps moving right and keeps eatting stuff up until reaches the end and returns it's final value.
Candis Wasell
@CandiW
Jun 24 2015 23:18
@Lightwaves that's a great way to remember that....I think I am going to rework my code to use reduce()
ronaldrdguez
@ronaldrdguez
Jun 24 2015 23:31
Hello, anyone going through the Functional Programming tutorial at http://jhusain.github.io/learnrx/ ? I have a question on exercise 19
Candis Wasell
@CandiW
Jun 24 2015 23:31
sorry - i'm not...
adcor
@adcor
Jun 24 2015 23:35
@moigithub that makes sense. Thanks for explaining
gabazine
@gabazine
Jun 24 2015 23:38
@ronaldrdguez I remeber seeing it on the freecodecamp youtube channel
ronaldrdguez
@ronaldrdguez
Jun 24 2015 23:41
@gabazine I’ll check it out thanks.
Moisés Man
@moigithub
Jun 24 2015 23:42
@ronaldrdguez what question ?
willamgriffin
@willamgriffin
Jun 24 2015 23:42
'''

'''
function mutation(arr) {
arr0=arr[0];
arr1=arr1;

arr0=arr0.toLowerCase();
arr1=arr1.toLowerCase();

for(i=0;i<arr0.length;i++)
if (arr0.indexOf(arr1.charAt(i)) < 0) {
return false;
}else{
return true;
}
}

mutation(['hello', 'hey']);
'''

hmm that dint work
Moisés Man
@moigithub
Jun 24 2015 23:43
backticks ` alt +96
@willamgriffin arr1=arr1; --> probably should be arr1=arr[1]; <-- with brackets ?
willamgriffin
@willamgriffin
Jun 24 2015 23:45
hmm well in my code it actually is not sure why if didn't show up here
ronaldrdguez
@ronaldrdguez
Jun 24 2015 23:45
@moigithub In ex 19, the solution doesn’t match the expected output, what var copyOfAccumulatedMap = Object.create(accumulatedMap); does is creating a long prototype chain, the returned object will only have the last property, everything else will have to be found traversing the chain.
Moisés Man
@moigithub
Jun 24 2015 23:47
@willamgriffin arr0 == hello... this have 5 characters ( range 0 to 4) ...
arr1 == hey
arr1.charAt(i) what if i == 4...
ronaldrdguez
@ronaldrdguez
Jun 24 2015 23:49

@moigithub I can get it right I think using

accumulatedMap[video.id] = video.title;
 return accumulatedMap;

but I’m wondering it’s best to use something like an extend instead of modifying accumulatedMap itself.

willamgriffin
@willamgriffin
Jun 24 2015 23:50
.indexOf is still > 0
Moisés Man
@moigithub
Jun 24 2015 23:52
@willamgriffin hey[0] == h // hey1 = e // hey[2] = y // hey[3] = ""
willamgriffin
@willamgriffin
Jun 24 2015 23:53
when i console.log that it gave me a 0
guess i need to find a way to get the loop to stop once .indexOf hits a -1
Moisés Man
@moigithub
Jun 24 2015 23:54
so 0 < 0 ?? thats false.. so ur if condition goes to else.. returning true;
willamgriffin
@willamgriffin
Jun 24 2015 23:56
ah