These are chat archives for FreeCodeCamp/Help

15th
Feb 2015
Carlos Toro Vera
@carmelo12341
Feb 15 2015 01:19
I have a little question
Cristián Berríos
@crisberrios
Feb 15 2015 01:33
sure
@carmelo12341 me puedes enviar un PM en español si te es más fácil así
Nathan
@terakilobyte
Feb 15 2015 01:42
we’d prefer if questions pertaining to challenges were asked in the open, even if in Spanish
these rooms are logged, and eventually we’ll be doing somethign useful with that
Suzanne Atkinson
@AdventureBear
Feb 15 2015 02:14
ljk :point_up: February 14 2015 2:56 PM Yeah I still want to get my method to work, and did not expect a totally different solution. This one is still troubling me. @terakilobyte it would be nice if we could come back to various bonfires to review them. Maybe rate comfort with how we solved it, kind of like a smart learning system.
Nathan
@terakilobyte
Feb 15 2015 02:14
I’ll keep that in mind
but.. if I may show you something
Suzanne Atkinson
@AdventureBear
Feb 15 2015 02:15
sure
a sample of the data we collect
assuming you allow google analytics
which we hope you do for fcc
Suzanne Atkinson
@AdventureBear
Feb 15 2015 02:17
can you filter it for me?
Cristián Berríos
@crisberrios
Feb 15 2015 02:18
@AdventureBear last time I checked, just Math.ceil was missing. Your code passed the tests for me
Suzanne Atkinson
@AdventureBear
Feb 15 2015 02:18
see what i've done specifically? if you do colelct by user, you could then use a smart algorithm to present challenging topics more often.
@crisberrios really?
inside bonfire it did?
Cristián Berríos
@crisberrios
Feb 15 2015 02:19
that's right
Nathan
@terakilobyte
Feb 15 2015 02:19
no it would be impossible for me to filter it to a user
ip isn’t collected
nor is your username or anything else
Suzanne Atkinson
@AdventureBear
Feb 15 2015 02:20
cool.
Nathan
@terakilobyte
Feb 15 2015 02:20
ah I see what you are saying
and it would be a cool idea if we had like 4-500 challenges
Suzanne Atkinson
@AdventureBear
Feb 15 2015 02:20
:)
maybe for some folks who want it?
Nathan
@terakilobyte
Feb 15 2015 02:20
then I could measure time vs average time per category
and serve challenges more often from the category you’re weak in
Suzanne Atkinson
@AdventureBear
Feb 15 2015 02:22
I have a language program I use that lets you rate on a scale of 1-5 how well you knew the world. Workds you rate a 1 are relelntlessly presented very 3-4 cards until you at least give it a 2. Then it slows down and includes more new words. words you rate as a 5 hardly ever come back. Like "gracias" I'd rate a 5, but the verb tener I'd give it a 3.
it works well if there are small chunks of new material presented at a time. it'd be awful to just have relentless 1 out of 5 words shown over and over!
Suzanne Atkinson
@AdventureBear
Feb 15 2015 02:51
Hot diggidy !! @crisberrios , @terakilobyte , @Sudeepto
  for (i=0; i<rows; i++) {
    //place correct "size" of elements into each new group
    multiArray[i] = arr.slice(i*size, (i+1)*size);
       //counter += 1; 
    }
this worked. rows is the math.ceil function
Cristián Berríos
@crisberrios
Feb 15 2015 03:12
nice, you incorporated the slice method :D
you can use pretty much every method of Array in that bonifire
Nathan
@terakilobyte
Feb 15 2015 03:37
all of our level 1 challenges are meant to walk you through the mdn
Evan Davis
@davisec52
Feb 15 2015 15:17

Could anyone explain where the problem lies with the code sample below? This is code from a problem set in chapter 4 of Eloquent Javascript.

The first instance shows the code presenting an error, and in the second instance it runs without error. I don't see any difference other than the first list has three values and the first has two.


function nth(list, n) {
  if (!list)
    return undefined;
  else if (n == 0)
    return list.value;
  else
    return nth(list.rest, n - 1);
}
nth({value: 1, rest: {value: 2, rest: {value: 4, rest: null}}, 1);
VM140:10 Uncaught SyntaxError: Unexpected token )VM116:777 


function nth(list, n) {
  if (!list)
    return undefined;
  else if (n == 0)
    return list.value;
  else
    return nth(list.rest, n - 1);
}
nth({value: 1, rest: {value: 2, rest: null}}, 1);
2
Nathan
@terakilobyte
Feb 15 2015 15:21
I suspect there’s more code than just that
Danny Fritz
@dannyfritz
Feb 15 2015 15:22
nah, there are three {'s in the first invocation but only 2 }'s
Evan Davis
@davisec52
Feb 15 2015 15:27
@terakilobyte the code is part of a larger problem set. It is the "list" problem in chapter 4. I didn't understand the nth function, so I was trying to look at it more closely.
For some reason, the list with two values works, but the list with three values does not.
Danny Fritz
@dannyfritz
Feb 15 2015 15:28
i answered why. :(
Nathan
@terakilobyte
Feb 15 2015 15:28
^
Danny Fritz
@dannyfritz
Feb 15 2015 15:28
you're missing a } in the first invocation
Evan Davis
@davisec52
Feb 15 2015 15:29
@dannyfritz Thank you. I'm sorry, I am just not seeing it.
Nathan
@terakilobyte
Feb 15 2015 15:29
jshint.com
Danny Fritz
@dannyfritz
Feb 15 2015 15:29
nth({value: 1, rest: {value: 2, rest: {value: 4, rest: null}}, 1);
if you remove all the contents we have nth({{{}}, 1);
Evan Davis
@davisec52
Feb 15 2015 15:30
Is that not the same as the working sample?
Danny Fritz
@dannyfritz
Feb 15 2015 15:31
nth({value: 1, rest: {value: 2, rest: null}}, 1); becomes nth({{}}, 1);
Evan Davis
@davisec52
Feb 15 2015 15:33
Could you show me the extra "{" in the problematic sample?
Danny Fritz
@dannyfritz
Feb 15 2015 15:34
it isn't that there is an extra {. It is that there is a missing }
Evan Davis
@davisec52
Feb 15 2015 15:35

nth({value: 1, rest: {value: 2, rest: null}}, 1);
nth({value: 1, rest: {value: 2, rest: {value: 4, rest: null}}, 1);
Nathan
@terakilobyte
Feb 15 2015 15:35
@davisec52 paste that code into jshint.com
get in the habit
use a linter
it will catch errors like that
Evan Davis
@davisec52
Feb 15 2015 15:37
@terakilobyte Thank you . . . for the hint.
:)
Evan Davis
@davisec52
Feb 15 2015 15:41
@terakilobyte @dannyfritz Thank you very much. got it!
cerissa
@cerissa
Feb 15 2015 15:45
quick question, why cant i set a div height to 100% when i do it doesnt show up
Danny Fritz
@dannyfritz
Feb 15 2015 15:46
do you have a jsfiddle or similar to demonstrate?
cerissa
@cerissa
Feb 15 2015 15:47
no but i can hold on let me make one
Danny Fritz
@dannyfritz
Feb 15 2015 15:49
it is because height 100% will take up 100% of what the body is. the body starts at 0
and if the div's don't have any height they don't add any
Suzanne Atkinson
@AdventureBear
Feb 15 2015 15:49
Should background be background-color?
cerissa
@cerissa
Feb 15 2015 15:49
that makes sense,
@dannyfritz
Danny Fritz
@dannyfritz
Feb 15 2015 15:50
@AdventureBear background is shorthand
Suzanne Atkinson
@AdventureBear
Feb 15 2015 15:50
Ok. Hmmm I could shorthand all if js!
Cristián Berríos
@crisberrios
Feb 15 2015 15:50
hello everyone
cerissa
@cerissa
Feb 15 2015 15:51
what does vw stand for?
Suzanne Atkinson
@AdventureBear
Feb 15 2015 15:51
Morning!
Cristián Berríos
@crisberrios
Feb 15 2015 15:51
VolksWagen
:D
Danny Fritz
@dannyfritz
Feb 15 2015 15:51
i actually meant to use vh :P but vw is viewport width and vh is viewport height
cerissa
@cerissa
Feb 15 2015 15:52
oh ok thank you
Evan Davis
@davisec52
Feb 15 2015 17:07
This is another sample of code from chapter 4 of Eloquent Javascript. I would
appreciate help understanding why it only produces a partial list of only the
first three array elements.


function arrayToList(array) {
  var list = null;
  for (var i = array.length - 1; i >= 0; i--)
    list = {value: array[i], rest: list};
  return list;
}
arrayToList([ 1, 2, 3, 4, 5, 6, 7]);


=> { value: 1, rest: { value: 2, rest: { value: 3, rest: [Object] } } }
Danny Fritz
@dannyfritz
Feb 15 2015 17:10
you are trying to flatten the nesting?
Evan Davis
@davisec52
Feb 15 2015 17:11
I was just trying to understand the code given in the chapter.
Danny Fritz
@dannyfritz
Feb 15 2015 17:12
oh, it recursively builds a deeper list
Evan Davis
@davisec52
Feb 15 2015 17:12
It is supposed to convert an array to a list: http://eloquentjavascript.net/04_data.html
Danny Fritz
@dannyfritz
Feb 15 2015 17:12
unflattens an array. :P
Evan Davis
@davisec52
Feb 15 2015 17:13
I'm not sure I understand what you mean by "unflattens an array."
Danny Fritz
@dannyfritz
Feb 15 2015 17:13
if you want an understanding of what is happening in the for loop. try putting a console.log(list) in it
Evan Davis
@davisec52
Feb 15 2015 17:16
All right. But why doesn't the return give the complete list?
When I ran console.log, I got this: { value: 1, rest: { value: 2, rest: { value: 3, rest: [Object] } } }
Danny Fritz
@dannyfritz
Feb 15 2015 17:17
the for loop isn't complete
oh, your console isn't expanding all of the objects
for brevity
Evan Davis
@davisec52
Feb 15 2015 17:19
Ok, so it is not a case of getting idiosyncratic results, just that the repl.it console is cutting it short.
Danny Fritz
@dannyfritz
Feb 15 2015 17:20
oh yeah
a lot of the online JS runners really obfuscate any attempt to debug
Evan Davis
@davisec52
Feb 15 2015 17:21
Wow. Ok, I just ran this in the chrome js console and got the same abbreviation.
Danny Fritz
@dannyfritz
Feb 15 2015 17:21
in the chrome console you should be able to expand the little arrows
Evan Davis
@davisec52
Feb 15 2015 17:21
This is a little off topic--but how do I verify that the entire list has been produced?
Evan Davis
@davisec52
Feb 15 2015 17:23
Ok, I see it. Thank you!