These are chat archives for FreeCodeCamp/Help

16th
Mar 2018
RIYA DASHORIYA
@riyadashoriya
Mar 16 2018 00:39
Hi I'm trying to understand how freecodecamp and GitHub works. If I go to https://www.freecodecamp.org/riyadashoriya, that shows that I committed in January, but my actual git profile https://github.com/riyadashoriya shows 0 contributions. Are they even connected? Or am I just wasting my time trying to find out why's?
Might be a wrong question in wrong room.
Kyle Holm
@thekholm80
Mar 16 2018 00:41
@riyadashoriya they are not connected
RIYA DASHORIYA
@riyadashoriya
Mar 16 2018 00:41
Thanks @thekholm80
CamperBot
@camperbot
Mar 16 2018 00:41
riyadashoriya sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1730 | @thekholm80 |http://www.freecodecamp.org/thekholm80
Will Rodgers
@daddyrodgers
Mar 16 2018 04:34
I need to start over
Ganeshan Dash
@binarytrance
Mar 16 2018 06:38
hi, HTML semantics question here... my page has multiple cards and these cards have headings. But the page in itself doesnt have any clear heading... what <h> tag to use for these card headings
Sorin Ruse
@sorinr
Mar 16 2018 08:50
@binarytrance there is no semantics in html5 for cards. cards are just a group ui components. so, you can just use some divs to layout your card and "semantically" give them css classes that "make" them semantically
Darren
@DarrenfJ
Mar 16 2018 15:11
morning fCC
@thekholm80 saw the python django discussion yesterday... weirdly I'm redoing the python in codecademy just for kicks when I'm bored with the CSS ..
Kyle Holm
@thekholm80
Mar 16 2018 15:12
@DarrenfJ :wave:
Darren
@DarrenfJ
Mar 16 2018 15:12
it's sometimes so hard to stay on point with coding
Kyle Holm
@thekholm80
Mar 16 2018 15:12
i tried the codeacademy course, spent way too much time fighting their editor over indentation errors
Darren
@DarrenfJ
Mar 16 2018 15:19
ha! yah it's not ideal.. i'm doing it mostly as a review and a break from doing the net ninja vids.. when i want to actually type like someone from the ole tymey times
with my fingers
Kyle Holm
@thekholm80
Mar 16 2018 15:22
lol
i usually just face-roll my keyboard
Nazar
@IsaakNazar
Mar 16 2018 15:36
does anyone have deep understanding of React ?
Kyle Holm
@thekholm80
Mar 16 2018 15:36
how deep?
Nazar
@IsaakNazar
Mar 16 2018 15:36
not so deep :) one second
Kyle Holm
@thekholm80
Mar 16 2018 15:37
i can google like a savant and i've read most the docs, if that helps lol
Nazar
@IsaakNazar
Mar 16 2018 15:37
these 2 snippets give same result, but which is preferably better?
class App extends React.Component {
  render() {    
    const tags = ['attr', 'head', 'alt'];
    return (
      <div>
        <Action tags={tags} />        
      </div>
    );
  }
}
class Action extends React.Component {
  render() {
    return (
      <div>
        {this.props.tags.map(tag=><h4 key={tag}>{tag}</h4>)}
      </div>
    );
  }
}
class App extends React.Component {
  render() {
    const tags = ['attr', 'head', 'alt'];
    return (
      <div>      
        {tags.map(tag => <Action key={tag} tagg={tag}/>)}
      </div>
    );
  }
}
class Action extends React.Component {
  render() {
    return (
      <div>        
        <h4>{this.props.tagg}</h4>
      </div>
    );
  }
}
Kyle Holm
@thekholm80
Mar 16 2018 15:39
they give the same result?
Nazar
@IsaakNazar
Mar 16 2018 15:39
@thekholm80 yes
Kyle Holm
@thekholm80
Mar 16 2018 15:41
i would think the top one would output something like
<div>
  <div>
    <h4></h4>
    <h4></h4>
    <h4></h4>
    <h4></h4>
  </div>
</div>
Nazar
@IsaakNazar
Mar 16 2018 15:42
the bottom one also outputs the same result
Kyle Holm
@thekholm80
Mar 16 2018 15:42
while the bottom would be
<div>
  <div>
    <h4></h4>
  </div>
  <div>
    <h4></h4>
  </div>
  <div>
    <h4></h4>
  </div>
  <div>
    <h4></h4>
  </div>
</div>
Nazar
@IsaakNazar
Mar 16 2018 15:43
@thekholm80 all right, so if i will not wrap the bottom one inside 'div', result will be the same, right?
Kyle Holm
@thekholm80
Mar 16 2018 15:44
i'm not sure you can get away with not wrapping it, i don't recall for sure but I think it's required?
Nazar
@IsaakNazar
Mar 16 2018 15:45
@thekholm80 better to do map inside child class or parent class?
Kyle Holm
@thekholm80
Mar 16 2018 15:45
for me, i'd want the bottom one. it seems more clear to me
Nazar
@IsaakNazar
Mar 16 2018 15:46
@thekholm80 ok, thank you :smile:
CamperBot
@camperbot
Mar 16 2018 15:46
isaaknazar sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1731 | @thekholm80 |http://www.freecodecamp.org/thekholm80
Kyle Holm
@thekholm80
Mar 16 2018 15:47
that's only based on how easy the code is to understand quickly, you may have other requirements that are more important
Kaz Baig
@kbaig
Mar 16 2018 18:18
@thekholm80 jw, have you been using graphql with redux?
Kyle Holm
@thekholm80
Mar 16 2018 18:53
@kbaig My last project did, but it was largely unnecessary
Kaz Baig
@kbaig
Mar 16 2018 18:54
@thekholm80 interesting. What were you using for async actions?
Kyle Holm
@thekholm80
Mar 16 2018 18:55
i'm not sure what you mean. inside redux i used middleware called redux-promise
apollo handled everything it did by itself
Kaz Baig
@kbaig
Mar 16 2018 19:33
@thekholm80 yeah I meant what were you using to handle the asynchronous actions. I've been using redux-thunk
Kyle Holm
@thekholm80
Mar 16 2018 19:34
when i learned redux the course used redux-promise, i've not branched out from there
I've heard great things about thunk, i just haven't had a reason to try it yet
Kaz Baig
@kbaig
Mar 16 2018 19:34
@thekholm80 thunk is from the same dude as redux
Kyle Holm
@thekholm80
Mar 16 2018 19:35
trying to remember
Dan Abromamov? or something like that?
Kaz Baig
@kbaig
Mar 16 2018 19:36
mhmm
I always remember his username, gaeron I think it is
Kyle Holm
@thekholm80
Mar 16 2018 19:36
he's a smart dude, i follow him on twitter
Kaz Baig
@kbaig
Mar 16 2018 19:37
I've watched a couple of his talks. He speaks well/smart too
Yossi Fisch
@yoizfefisch
Mar 16 2018 21:06

Hi, I am on the ES6: Use Destructuring Assignment with the Rest Operator to Reassign Array Elements lesson and the following code didn't pass:

const [,, ...arr] = list; // change this

The tests expect you to name the ommitted elements. Do you think it should be this way?

Christopher McCormack
@cmccormack
Mar 16 2018 21:18
@yoizfefisch you don't want to leave those blank
try filling in with any variable names, a, b, ...arr should work
Kyle Holm
@thekholm80
Mar 16 2018 21:21
i tried that and it's giving me an error saying i can't reassign arr ... beta's still got some bugs lol
Christopher McCormack
@cmccormack
Mar 16 2018 21:22
worked for me
don't reassign change the whole line
Kyle Holm
@thekholm80
Mar 16 2018 21:22
that's kind of how bugs work lol
it's part of their testing
i'm not saying your code is wrong, i'm saying when i try to do the lesson it bugs out on me
Christopher McCormack
@cmccormack
Mar 16 2018 21:23
oh sure blame the beta :grin:
Kyle Holm
@thekholm80
Mar 16 2018 21:23
image.png
when i load the page and do nothing
Manish Giri
@Manish-Giri
Mar 16 2018 21:24
gotta use const inside the function, me thinks
Kyle Holm
@thekholm80
Mar 16 2018 21:24
i'm just going to not do beta until they get it working lol
Manish Giri
@Manish-Giri
Mar 16 2018 21:25
beta is crap..a lot of the things don't work..
I wonder how did they come up with the "new year 2018" release date
Kyle Holm
@thekholm80
Mar 16 2018 21:25
i don't know anything about project management
Yossi Fisch
@yoizfefisch
Mar 16 2018 21:30
@cmccormack I saw it works when I fill in with variable names. My question was is this really how it should be? In real world, is my code wrong?
Christopher McCormack
@cmccormack
Mar 16 2018 21:31
@yoizfefisch yes, you need to have something to store the first few into
then the REST will be stored in ...arr
Yossi Fisch
@yoizfefisch
Mar 16 2018 21:33
@cmccormack Why is it not working as it does in ES6: Use Destructuring Assignment to Assign Variables from Arrays:
const [a, b,,, c] = [1, 2, 3, 4, 5, 6];
console.log(a, b, c); // 1, 2, 5
Kyle Holm
@thekholm80
Mar 16 2018 21:34
the commas should be allowed, the MDN page suggests they get filled with an elision
Christopher McCormack
@cmccormack
Mar 16 2018 21:34
yeah I think you have to match the number of items in the list array
Kyle Holm
@thekholm80
Mar 16 2018 21:36
const arr = [1, 2, 3, 4, 5];

console.log([, , ...arr]); // [undefined, undefined, 1, 2, 3, 4, 5]
so it pads the array, doesn't destructure
Christopher McCormack
@cmccormack
Mar 16 2018 21:36
hmm nope testing all seemed fine
you're logging the array
Kyle Holm
@thekholm80
Mar 16 2018 21:37
oh duh
Manish Giri
@Manish-Giri
Mar 16 2018 21:37

this is their regex -

.match(/\\[\\s*\\w\\s*,\\s*\\w\\s*,\\s*...arr\\s*\\]/g)

they expect some variables for the first 2 elements (which imo is incorrect)

Christopher McCormack
@cmccormack
Mar 16 2018 21:38
@Manish-Giri Agreed, has to be a regex issue
Manish Giri
@Manish-Giri
Mar 16 2018 21:38
coz they only mentioned the first 2 elements were to be omitted, no mention about needing to save them as well
@cmccormack :+1:
Christopher McCormack
@cmccormack
Mar 16 2018 21:40
I've honestly not had to do much destructuring with Arrays, seems to mostly be with objects
Kyle Holm
@thekholm80
Mar 16 2018 21:40
i've not done this before, it's pretty slick
let arr = [1, 2, 3, 4, 5];
const [, , ...list] = arr;
console.log(list); // [3, 4, 5]
Christopher McCormack
@cmccormack
Mar 16 2018 21:40
Arrays should really be used as an iterable most of the time so I can't think of many times you would need to destructure
Manish Giri
@Manish-Giri
Mar 16 2018 21:41
maybe create an array from another one, plus a few elements?
Christopher McCormack
@cmccormack
Mar 16 2018 21:41
true cloning is a good reason to use it
Kyle Holm
@thekholm80
Mar 16 2018 21:42
i use the ... a lot with react state, since i can't mutate
Christopher McCormack
@cmccormack
Mar 16 2018 21:42
@thekholm80 yeah that's where I mostly use it as well
Kyle Holm
@thekholm80
Mar 16 2018 21:42
this.setState({ list: [newItem, ...this.state.list] });
Kyle Holm
@thekholm80
Mar 16 2018 21:50
anyway, moral of the story is someone should submit an issue on github to modify the instructions or the test so that the trailing commas are either allowed or explicitly forbidden lol
Christopher McCormack
@cmccormack
Mar 16 2018 21:51
@thekholm80 are you volunteering? haha
Kyle Holm
@thekholm80
Mar 16 2018 21:51
1, 2, 3, not it
Christopher McCormack
@cmccormack
Mar 16 2018 21:52
not i... dang
Yossi Fisch
@yoizfefisch
Mar 16 2018 22:25
I will
It's mentioned in a comment on freeCodeCamp/freeCodeCamp#15224