These are chat archives for FreeCodeCamp/Help

19th
Feb 2015
Suzanne Atkinson
@AdventureBear
Feb 19 2015 01:19
@chrisdziewa :point_up: February 18 2015 6:15 PM I eventually came up with something I really liked. Had some help, I used Object.keys and a for...in
Nathan
@terakilobyte
Feb 19 2015 01:27
;)
@chrisdziewa it should center on object.keys and hasownproperty
at least mine did
also, try using map or filter to iterate collections
I know it seems strange at first, but trust me, get comfortable with it
it will make your javascripts much more powerful and get you towards thinking functional
which will simplify your programs overall, make them easier to maintain, and increase testability
Suzanne Atkinson
@AdventureBear
Feb 19 2015 01:35
ohh hasownproperty. Need to check that out
I think where art thou is the ultimate bonfire.
Nathan
@terakilobyte
Feb 19 2015 01:39
lol
they get harder ;)
Suzanne Atkinson
@AdventureBear
Feb 19 2015 01:39
I'm going to do where art though for about a month. once a day
thou
Nathan
@terakilobyte
Feb 19 2015 01:40
lol
once you've passed it you should move on
Suzanne Atkinson
@AdventureBear
Feb 19 2015 01:40
spoilsport.
Nathan
@terakilobyte
Feb 19 2015 01:40
remember, all we're teaching is ideas
those ideas are reinforced by later challenges
Suzanne Atkinson
@AdventureBear
Feb 19 2015 01:40
stuck on seek & destroy now
:)
Nathan
@terakilobyte
Feb 19 2015 01:40
ah let me pull it up
Suzanne Atkinson
@AdventureBear
Feb 19 2015 01:41
couldn't access this: [1, 2, 3, 1, 2, 3] with arr[0]. So I went to sleep
Nathan
@terakilobyte
Feb 19 2015 01:42
ah
there's a really cool thing built into js
it's called arguments
Suzanne Atkinson
@AdventureBear
Feb 19 2015 01:43
now we are fighting?
Suzanne Atkinson
@AdventureBear
Feb 19 2015 01:43
ooh. OK, interesting
OH, Nathan, not sure if you saw the earlier chat, @Maximization and @crisberrios were helping me get FCC running locally. we uninstaleld and reinstalled both gulp and the dependancy packages. For my .env file I just used the first 4 lines since the github read me said that was enough, but then gulp showed an oauth error.
Chris Dziewa
@chrisdziewa
Feb 19 2015 02:07
@terakilobyte @AdventureBear This was my solution. I've used filter and map before. I'll have to play around with it tomorrow.
function where(collection, source) {
  var result = [];
  var findKeys = Object.keys(source);

  for (var i = 0; i < collection.length; i++) {

    var hasProperties = true;
    var currentObject = collection[i];

    for (var j = 0; j < findKeys.length; j++) {
      var key = findKeys[j];

      if (!currentObject.hasOwnProperty(key) || currentObject[key] !== source[key]) {
        hasProperties = false;
      }
    }
    if (hasProperties) {
      result.push(currentObject);
    } 
  }
  return result;
}
Suzanne Atkinson
@AdventureBear
Feb 19 2015 03:19
@terakilobyte what do you think about adding some kind of "hint" system for bonfires? I feel like there are things I could be picking up but I'm not...like filter/map/reduce/hasownproperty/etc...that I don't know I don't know...also arguments. and I'm sure 1000 other things.
Eric Blosch
@eblosch
Feb 19 2015 03:53
Hi, having an issue with the factorial bonfire. Result is correct, but assertions aren't passing.
Julie Myers
@BlueOceanView
Feb 19 2015 03:54
@eblosch Could you past your code?
Eric Blosch
@eblosch
Feb 19 2015 03:54
you bet
var total = 1;

function factorialize(num) {
  for (var i = 1; i <= num; i++) {
    total *= i;
  }
  return total;
}

factorialize(5);
Julie Myers
@BlueOceanView
Feb 19 2015 03:56
I did this one not to long ago. I'm trying to remember what else I needed to add. Could you past the error messages? I can help you read them.
Eric Blosch
@eblosch
Feb 19 2015 03:56
sure thing, appreciate it. one second...
expect(factorialize(20)).to.equal(2432902008176640000);AssertionError:expected 291948240981196800000 to equal 2432902008176640000
expect(factorialize(10)).to.equal(3628800);AssertionError:expected 435456000 to equal 3628800
expect(factorialize(5)).to.equal(120);AssertionError:expected 14400 to equal 120
expect(factorialize(5)).to.be.a("Number");
the first three fail, the last one passes
Danny Fritz
@dannyfritz
Feb 19 2015 03:57
the problem is your total isn't being reset on each call to the function
Eric Blosch
@eblosch
Feb 19 2015 03:58
thanks @dannyfritz. if i reset it each time, wouldn't that erase the running value? I get the right result in CodeRunner, but not in the Bonfire
Danny Fritz
@dannyfritz
Feb 19 2015 03:58
@eblosch run the function twice in a row and see if you get the right value.
Julie Myers
@BlueOceanView
Feb 19 2015 03:58
Move var total = 1; to be the top line of the function.
Eric Blosch
@eblosch
Feb 19 2015 03:59
Okay let me try that
No luck, same result.
Eric Blosch
@eblosch
Feb 19 2015 03:59
in this case, the assertions are lower than expected (getting 2, expecting 120)
Danny Fritz
@dannyfritz
Feb 19 2015 04:00
@eblosch no, your factorial isn't right
Eric Blosch
@eblosch
Feb 19 2015 04:00
I see... each time it runs, it's adding to the total result
jsbin makes sense
Danny Fritz
@dannyfritz
Feb 19 2015 04:00
total lives outside the closure of your factorial function
Julie Myers
@BlueOceanView
Feb 19 2015 04:01
Factorialize would need to do 1x2x3x4x5 = 120 (because you are passing in 5)
Eric Blosch
@eblosch
Feb 19 2015 04:01
Okay, we got it now. Thanks @dannyfritz and @BlueOceanView , works now. Appreciate the help!
Danny Fritz
@dannyfritz
Feb 19 2015 04:01
haha, markdown mangled that
:)
Julie Myers
@BlueOceanView
Feb 19 2015 04:02
@eblosch What was your final coding?
Eric Blosch
@eblosch
Feb 19 2015 04:03
It was moving total inside the function, so it didn't keep evaluating a running total. I'll paste it here
function factorialize(num) {
  var total = 1;
  for (var i = 1; i <= num; i++) {
    total *= i;
  }
  return total;
}

factorialize(5);
Danny Fritz
@dannyfritz
Feb 19 2015 04:04
good work! :)
Julie Myers
@BlueOceanView
Feb 19 2015 04:05
Cool.
Eric Blosch
@eblosch
Feb 19 2015 04:06
Appreciate it, thanks!
Julie Myers
@BlueOceanView
Feb 19 2015 04:06
You're welcome.
David Charles
@davidcharles212
Feb 19 2015 05:44
Hi everyone, I'm working on the animation for my css robot's eyes and am having trouble
DASH gives me the green check marks indicating I'm correct, but my eyes aren't lighting up
I don't know if it's a problem with their coding simulator, or my code
How do I paste a code box like the guy doing the factorial code did above me?

@keyframes blink {
50% {
background: radial-gradient(circle, red 15%, transparent 40%), #cc5;
}
}
@-webkit-keyframes blink {
50% {
background: -webkit-radial-gradient(circle, red 15%, transparent 40%), #cc5;
}
}
@-moz-keyframes blink {
50% {
background: -moz-radial-gradient(circle, red 15%, transparent 40%), #cc5;
}
}

.brain {
background: radial-gradient(circle, white 15%, transparent 40%), #cc5;
background: -moz-radial-gradient(circle, white 15%, transparent 40%), #cc5;
background: -webkit-radial-gradient(circle, white 15%, transparent 40%), #cc5;
background-size: 75px 150px;
height: 150px;
width: 150px;
border-radius: 60px 60px 10px 10px;
border-bottom: 40px solid #666;
position: relative;
left: 70px;
}

'''
@keyframes blink {
50% {
background: radial-gradient(circle, red 15%, transparent 40%), #cc5;
}
}
@-webkit-keyframes blink {
50% {
background: -webkit-radial-gradient(circle, red 15%, transparent 40%), #cc5;
}
}
@-moz-keyframes blink {
50% {
background: -moz-radial-gradient(circle, red 15%, transparent 40%), #cc5;
}
}

.brain {
background: radial-gradient(circle, white 15%, transparent 40%), #cc5;
background: -moz-radial-gradient(circle, white 15%, transparent 40%), #cc5;
background: -webkit-radial-gradient(circle, white 15%, transparent 40%), #cc5;
background-size: 75px 150px;
height: 150px;
width: 150px;
border-radius: 60px 60px 10px 10px;
border-bottom: 40px solid #666;
position: relative;
left: 70px;
}
'''

Sorry, trying to figure out formatting
@keyframes blink {
  50% {
    background: radial-gradient(circle, red 15%, transparent 40%), #cc5;
  }
}
@-webkit-keyframes blink {
  50% {
    background: -webkit-radial-gradient(circle, red 15%, transparent 40%), #cc5;
  }
}
@-moz-keyframes blink {
  50% {
    background: -moz-radial-gradient(circle, red 15%, transparent 40%), #cc5;
  }
}

.brain {
  background: radial-gradient(circle, white 15%, transparent 40%), #cc5;
  background: -moz-radial-gradient(circle, white 15%, transparent 40%), #cc5; 
  background: -webkit-radial-gradient(circle, white 15%, transparent 40%), #cc5;
  background-size: 75px 150px;
  height: 150px;
  width: 150px;
  border-radius: 60px 60px 10px 10px;
  border-bottom: 40px solid #666;
  position: relative;
  left: 70px;
}
Is my "blink" class correctly defined?
Alex Dixon
@alex-dixon
Feb 19 2015 08:05
    checkWin: function (currentBoard) {
        var check = function (num) {
            currentBoard.some(function (elem) { return elem === num })
        };
@davidcharles212 blink is a class? not sure but might need a period in front of it
my code above appears not to work when passing in an array to object.checkWin. I’m trying to define ‘check' so it always runs the ’some’ method on the array passed to the outer function, but want to be able to pass a number to it
Chris Dziewa
@chrisdziewa
Feb 19 2015 16:36
@davidcharles212 That wouldn't be referred to as a class. Only as an animation. Do you by chance have all of the code you can share?
Serhii Borovskyi
@serhiicss
Feb 19 2015 16:38
Hello everyone!
Chris Dziewa
@chrisdziewa
Feb 19 2015 16:45
@alex-dixon Could you just pass in the num parameter to the main function after current board and carry it down?
Jonathan
@jonathantimm
Feb 19 2015 16:49
Hey yall! Who's a javascript guru who can help me with my embarassingly simple roadblock?
Justin Rogers
@yaskyj
Feb 19 2015 16:49
@jonathantimm What's the problem?
Danny Fritz
@dannyfritz
Feb 19 2015 16:50
@jonathantimm if it is simple, i don't think you need a guru to help out. ;P
Jonathan
@jonathantimm
Feb 19 2015 16:52
So basically all i'm trying to do is customize a highchart in an html page
Just have an html page that displays a highchart with the labels and numbers I put into it
And I'm just getting a couple errors that I can't figure out via the googlez
(I am very beginner)
the first one is Uncaught TypeError: Cannot read property 'addEvent' of undefined
Danny Fritz
@dannyfritz
Feb 19 2015 16:53
might want to try the highcharts forum http://forum.highcharts.com/highcharts-usage/
highcharts is a pay to use library
Jonathan
@jonathantimm
Feb 19 2015 16:54
Even for their demos, though?
We are just sort of checking out potential options for our app's dashboards
Danny Fritz
@dannyfritz
Feb 19 2015 16:54
it is free for personal use
do you have a fiddle or something with the error?
Jonathan
@jonathantimm
Feb 19 2015 16:56
i'm embarassed to say I don't know what that is
Justin Rogers
@yaskyj
Feb 19 2015 16:56
Do you have anyplace that we can see the code?
Jonathan
@jonathantimm
Feb 19 2015 16:57
What's the best way to pass along code like that?
Justin Rogers
@yaskyj
Feb 19 2015 16:58
It would be something like jsfiddle: http://jsfiddle.net/ or codepen.io
Jonathan
@jonathantimm
Feb 19 2015 16:59
hmmm
Justin Rogers
@yaskyj
Feb 19 2015 17:00
First thing: the /script is after the /body.
Danny Fritz
@dannyfritz
Feb 19 2015 17:01
you have some wird <script> tags going on
you're also using an ancient version of jquery
Jonathan
@jonathantimm
Feb 19 2015 17:02
haha crap
Justin Rogers
@yaskyj
Feb 19 2015 17:02
Yes, the script tag in the body is opened twice.
Danny Fritz
@dannyfritz
Feb 19 2015 17:02
@jonathantimm here is a starting spot http://jsfiddle.net/c1b0yjkt/1/
Jonathan
@jonathantimm
Feb 19 2015 17:03
you're a genius
wait, how is it possible that that worked on jsfiddle when i'm referring to local resources
Danny Fritz
@dannyfritz
Feb 19 2015 17:05
i changed it to cdnjs
look at external resources on the left
Jonathan
@jonathantimm
Feb 19 2015 17:06
i see
wow, thank you so much
Danny Fritz
@dannyfritz
Feb 19 2015 17:07
np
Jonathan
@jonathantimm
Feb 19 2015 17:08
is there a way to see this code all in one place?
like the way I was doing it, just as one set of code in an html doc?
Danny Fritz
@dannyfritz
Feb 19 2015 17:08
view the source of the result frame
Serhii Borovskyi
@serhiicss
Feb 19 2015 17:12
var getReview = function (movie) {

    switch (movie) {
      case "Toy Story 2" :
        console.log("Great story. Mean prospector.")
        break;
      case "Finding Nemo" :
        console.log("Cool animation, and funny turtles.")
        break;
      case "The Lion King" :
        console.log("Great songs.")
        break;
      default:
        console.log("I don't know!")
    };
};

getReview("Toy Story 2");
Can anyone tell what is wrong with the code?
Danny Fritz
@dannyfritz
Feb 19 2015 17:13
seems fine ot me
Serhii Borovskyi
@serhiicss
Feb 19 2015 17:15
it works for me too, but codecademy says there is an error
and the code returns review twice for some reason
Justin Rogers
@yaskyj
Feb 19 2015 17:18
Maybe codecademy would prefer for you to have semicolons behind your console.logs?
Serhii Borovskyi
@serhiicss
Feb 19 2015 17:18
Oops, try again. Are you sure you're returning the right thing?
That is what I get from them
Does switch act as return here?
Danny Fritz
@dannyfritz
Feb 19 2015 17:19
no
switch is just a control flow, similar to an if/else
Serhii Borovskyi
@serhiicss
Feb 19 2015 17:20
so how do I make return work in this funciton?
Justin Rogers
@yaskyj
Feb 19 2015 17:21
Is this "More Control Flow in JS" number 8?
That one wouldn't give me a success even though I knew it was correct. I added an extra break on each case and a break on default and it finally let me through.
Serhii Borovskyi
@serhiicss
Feb 19 2015 17:23
It is OBJECTS I
let me try that
Danny Fritz
@dannyfritz
Feb 19 2015 17:25
you can just return from each case instead of break
Jon Lucas
@jonslucas
Feb 19 2015 17:42
Looks like this is a case of the codecademy testing specifically for return instead of console.log(). The error I got when I ran your code was: "Oops, try again. Are you sure you're returning the right thing?" Also, in the instructions: "and returns its review".
Serhii Borovskyi
@serhiicss
Feb 19 2015 18:01
@jonslucas Thank you!!! I knew I had to use return, I just did not know where. It works now! :)
david
@dalvarado
Feb 19 2015 20:10
hello all
Jonathan
@jonathantimm
Feb 19 2015 20:10
@dalvarado hey there
david
@dalvarado
Feb 19 2015 20:12
@jonathantimm how's it going? just had a question about one of the bonfire challenges test cases
is it me or are the test cases for the "drop it like it's hot" bonfire challenge wrong?
Cristián Berríos
@crisberrios
Feb 19 2015 20:16
can you link the bonfire?
david
@dalvarado
Feb 19 2015 20:17
Danny Fritz
@dannyfritz
Feb 19 2015 20:35
yeah, the predicate in that bonfire seems to be backwards
david
@dalvarado
Feb 19 2015 20:46
yeah, for all three cases that are tested
Oliver
@Dadsaster
Feb 19 2015 20:47
I can't figure out what I did wrong here:
function titleCase(str) {
  var grab = str.replace(/\*\w\S*/g, function(txt) {
    return txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase();
  });
  console.log(grab);
}

titleCase("HERE IS MY HANDLE");
specifically - it won't lower case any text.
Cristián Berríos
@crisberrios
Feb 19 2015 20:47
@dalvarado I think it should say "drop the items from the array while the predicate returns true"
Oliver
@Dadsaster
Feb 19 2015 20:48
and sorry - how do I create the black code box? (Noob question sorry)
Cristián Berríos
@crisberrios
Feb 19 2015 20:48
use ``` before and after code
not ' or ´
Danny Fritz
@dannyfritz
Feb 19 2015 20:48
@Dadsaster it is the * in your regex
david
@dalvarado
Feb 19 2015 20:49
@crisberrios cool thanks
Oliver
@Dadsaster
Feb 19 2015 20:49
@dannyfritz - thanks
david
@dalvarado
Feb 19 2015 21:24
@crisberrios who do we notify about updating this particular challenge?
Cristián Berríos
@crisberrios
Feb 19 2015 21:26
submit an issue to FCC git repo
or contact @terakilobyte or @QuincyLarson when they are available.
david
@dalvarado
Feb 19 2015 21:27
thanks again
Darryl Dixon - Piece Digital
@piecedigital
Feb 19 2015 21:28
I had been thrown for a loop in that one as well
I had to put the string to lower case before I proceeded, I believe.
Briana Swift
@brianamarie
Feb 19 2015 23:13
So I've got an array full of characters from a split up string. I want to use regex and a loop to push ONLY \w into a new array. A few questions... (1) Is my array that's recently split from a string full of tiny, one character strings? If not, how do I make it only character strings? (2) Using regex, will /\w/ work? Need more [] or something? (3) Regex only works with strings, right?
Cristián Berríos
@crisberrios
Feb 19 2015 23:19
1.- yes it should "briana".split('') becomes ["b","r","i","a","n","a"]
2.- it will work, but watch out since \w is not just only [a-zA-Z] but [0-9A-Za-z] + some extra characters
3.- yes
also, check if you can avoid a loop using the array filter method
Briana Swift
@brianamarie
Feb 19 2015 23:23
@crisberrios thank you!! very helpful :)
Nathan
@terakilobyte
Feb 19 2015 23:33
if you only want letters you can save some time by not using str.split() at all
str.replace() may help
just replace anything that isn't a letter with an empty string ''
assuming you start with a string instead of an array
Briana Swift
@brianamarie
Feb 19 2015 23:38
true! thanks!