These are chat archives for FreeCodeCamp/HelpJavaScript

29th
Jan 2019
Riadh
@KWFE
Jan 29 00:00
@kebien6020 i don't wanna spam the chat would you answer me on private chat?
Jason Luboff
@JLuboff
Jan 29 00:42
D'oh... made some changes...now have 7 failing tests :*(
Kevin Peña
@kebien6020
Jan 29 00:50
There is always git reset --hard HEAD :P
Jason Luboff
@JLuboff
Jan 29 00:50
Nah...it was failing due to changing the functions that get tested
Fixed all but 2 which I just need to change the test data for that one
Brad
@bradtaniguchi
Jan 29 00:51
Id say changing code and getting tests to fail is a great thing, means the tests are doing their jobs :D
Jason Luboff
@JLuboff
Jan 29 00:51
Very true
Eh...I'll fix the last two tomorrow
Kevin Peña
@kebien6020
Jan 29 00:56
Yeah I meant that as a joke. That is the good thing about tests, they test the code but they also test themselves.
Brad
@bradtaniguchi
Jan 29 00:58
Hehe how about changing code and breaking 140 tests! XD
Jason Luboff
@JLuboff
Jan 29 00:59
No thank you. lol
Brad
@bradtaniguchi
Jan 29 01:01
Changing sync code to async code broke all the tests XD
Karma Drukpa
@coderkarma
Jan 29 07:35
const addPepperoniToPizza = arr => {
let result = arr.map((ele) => {
        if (arr.indexOf(ele.includes("pepperoni"))) {
            arr.push("pepperoni")
        }
        return ele;
    })
    return result;
}
console.log(addPepperoniToPizza(['onions', 'olives', 'pineapple']));
could any one point out why I am not able to push the pepperoni in the array?
alpox
@alpox
Jan 29 08:44
@coderkarma there are multiple problems in this code. 1. The map method maps every item in the array to some other value. This means that you run the code in the function for every one element in the array. 2. arr.indexOf needs an element to test for but you pass a boolean (the return value of ele.includes)
Yogender
@yb1997
Jan 29 08:44
@coderkarma because ele.includes returns a boolean, btw why are you mutating that array while mapping over it ?
const addPepperoniToPizza  = arr => [...arr]
if arr contains pepperoni, it will get added otherwise return just the same thing
Yogender
@yb1997
Jan 29 08:50
but in here im creating a new copy of array using ... spread operator
tundeiness
@tundeiness
Jan 29 11:05
hi guys, can you help me look at this project? https://codepen.io/highness/pen/xmMMoG?editors=0011 the drum pads are not displaying the way I want it to. It has just been refactored to the present code base because I want to remove repetitive stuffs. So I thought I should map over the data sounds in state to create the drum pads but it seem it might be a wrong idea? any help is appreciated. Thanks.
tundeiness
@tundeiness
Jan 29 15:29
hi guys, can you help me look at this project? https://codepen.io/highness/pen/xmMMoG?editors=0011 the drum pads are not displaying the way I want it to. It has just been refactored to the present code base because I want to remove repetitive stuffs. So I thought I should map over the data sounds in state to create the drum pads but it seem it might be a wrong idea? any help is appreciated. Thanks.
Christopher McCormack
@cmccormack
Jan 29 15:30
@tundeiness they aren't going to display at all because you don't have any shape to your drum elements. You are using SCSS and need to use the proper selectors - your .drum-pad are not nested within a #drums element
@tundeiness mapping is fine - I like to give each discrete item (like a drum) its own component but you can do it either way
tundeiness
@tundeiness
Jan 29 15:32
@cmccormack #drums is Drums component? unless I have mixed it all up
Christopher McCormack
@cmccormack
Jan 29 15:33
#drums is your CSS selector for a div element with an id of drums
You have a bunch of CSS for your .drum-pad but aren't using it because you didn't add that id to the parent
tundeiness
@tundeiness
Jan 29 15:35
@cmccormack seems that the best way out...add #drum id to the parent
Christopher McCormack
@cmccormack
Jan 29 15:35
I mean... that's the CSS you wrote so you should try to use it right?
tundeiness
@tundeiness
Jan 29 15:36
@cmccormack absolutely..
@cmccormack only snag is it might not pass FCC test suite...
Christopher McCormack
@cmccormack
Jan 29 15:37
@tundeiness so write it so it does :)
But I don't think it will affect it
tundeiness
@tundeiness
Jan 29 15:38
@cmccormack :laughing: okay that is the only option..let me try it out
Christopher McCormack
@cmccormack
Jan 29 15:39
@tundeiness I just tested it with success so you should be good, just keep filling in what you need
tundeiness
@tundeiness
Jan 29 15:41
@cmccormack there goes my cue...another thing, I am obviously passing data from the child to the parent component how do I do this without props and is it right?
Christopher McCormack
@cmccormack
Jan 29 15:42

I am obviously passing data from the child to the parent component

Where? This is not how React works, it works from Parent to Child with props. You pass data back up to parents using callback functions

tundeiness
@tundeiness
Jan 29 15:46
@cmccormack well that is what I am about to do
@cmccormack my concern is how to handle the state for this data in parent, it's not clear to me yet on how to go about it.
Christopher McCormack
@cmccormack
Jan 29 15:48
What exactly do you need to do? what do you mean by handle the state for this data in parent?
tundeiness
@tundeiness
Jan 29 15:54
@cmccormack the audio is in a server and making sure when the right key is pressed the right sound is played in will need to set state now the question is where should it be? parent or child? Besides the Drum component is what I need to click to get the sound to play? all this and many others are giving me worries ( I might be over thinking it though)
Christopher McCormack
@cmccormack
Jan 29 15:57
@tundeiness why does it need to set state?
You already created the audio element, what you need to do is figure out how to utilize it when the button is clicked or the letter is pressed on the keyboard
tundeiness
@tundeiness
Jan 29 15:58
@cmccormack it's my assumption...it's the way i am thinking about it...I may be wrong though.
Christopher McCormack
@cmccormack
Jan 29 15:58
well try it out, see what snags you hit
this one isn't perfectly straight forward either, there are a few ways you could reference/play the audio
@tundeiness if a Parent component does need access to some information for whatever reason, though, use a callback function from the parent, passed down to the child as props, to handle this
tundeiness
@tundeiness
Jan 29 16:03
@cmccormack is it possible to use document.addEventlistener on the drum component in the parent component?
Christopher McCormack
@cmccormack
Jan 29 16:04
do you want to add the event listener at the document level?
I think in React all events are actually at the document level, and then React parses it based on the type and their custom Event
@tundeiness best thing you can do is try it out, play with it, see what happens, add logging to see where it may be breaking
tundeiness
@tundeiness
Jan 29 16:06
@cmccormack true that
Jason Luboff
@JLuboff
Jan 29 16:14
Morning
Christopher McCormack
@cmccormack
Jan 29 16:23
@JLuboff yo
Jason Luboff
@JLuboff
Jan 29 16:24
what up
Christopher McCormack
@cmccormack
Jan 29 16:24
playin with stuff
you?
Jason Luboff
@JLuboff
Jan 29 16:27
Catching up on a few things I put off yesterday before getting back into programming
Christopher McCormack
@cmccormack
Jan 29 16:33
do you still have to do the PC stuff?
Jason Luboff
@JLuboff
Jan 29 16:33
Ya but... I usually just put it off lol
Christopher McCormack
@cmccormack
Jan 29 16:35
you should see if you can get an intern to do that work, you're a developer man you shouldn't have to do that anymore
Jason Luboff
@JLuboff
Jan 29 16:36
We don't get interns homie. But ya I've suggested it
Christopher McCormack
@cmccormack
Jan 29 16:39
Need something right? You need to focus, can't be context switching all day
Jason Luboff
@JLuboff
Jan 29 16:40
I think if I end up getting deadlines (I currently dont have any except for the ones I give myself) I would push much stronger for it
Christopher McCormack
@cmccormack
Jan 29 16:41
or maybe create Tech Support Tuesdays where that's the only day they can get stuff fixed :)
Jason Luboff
@JLuboff
Jan 29 16:43
People would loose their minds... god forbid their printer isn't working!
Christopher McCormack
@cmccormack
Jan 29 16:45
hmm maybe adopt the devops model - if a printer isn't working, what steps would you take? Can you automate the 90% of the issues?
Jason Luboff
@JLuboff
Jan 29 16:48
Man... you have a lot of confidence in people
Christopher McCormack
@cmccormack
Jan 29 16:48
I do in you!
Jason Luboff
@JLuboff
Jan 29 16:49
You don't know how many times I have to ask "Have you tried turning your computer and/or printer off?" and its always "No.... " and then it fixes it 75% of the time
Christopher McCormack
@cmccormack
Jan 29 16:50
that's what I'm saying - if someone submits a ticket - automatically parse that using scripts to gather the printer details then maybe reboot them right away
Jason Luboff
@JLuboff
Jan 29 16:50
We don't have tickets. People either just directly call me or email me
But I can have several days in a row where I get nothing and then get bombarded the next
Christopher McCormack
@cmccormack
Jan 29 16:52
No tickets eh? sounds like two birds with one stone - you create the ticket system, simple at first, and use it as part of your automation
Jason Luboff
@JLuboff
Jan 29 16:53
I like your Moxie kid
Christopher McCormack
@cmccormack
Jan 29 16:53
make them select a printer and issue from a dropdown - if you have a solution for that tuple already - apply it automatically, run tests against the printer before/after, then close the ticket as successful if it starts working
Jason Luboff
@JLuboff
Jan 29 16:54
Sounds like a lot of work
Christopher McCormack
@cmccormack
Jan 29 16:55
lol
@JLuboff yeah maybe :)
Jason Luboff
@JLuboff
Jan 29 17:14
@cmccormack any how... what're you working on?
Christopher McCormack
@cmccormack
Jan 29 17:15
@JLuboff More iVPN stuff and reviewing some fcc PRs
Jason Luboff
@JLuboff
Jan 29 17:16
Nice. Back feeling better?
Christopher McCormack
@cmccormack
Jan 29 17:16
nothing fun yet
yeah a bit, just letting it rest. You?
Jason Luboff
@JLuboff
Jan 29 17:17
Eh...no not really. Still fucked. lol
Christopher McCormack
@cmccormack
Jan 29 17:19
ouch man put some ice on it and rest as much as you can
Jason Luboff
@JLuboff
Jan 29 17:21
It hurts the most when I'm lying down lol sitting is alright though. My wife thinks its my sciatic
Christopher McCormack
@cmccormack
Jan 29 17:22
dang I wonder if we have the same issue, I can't lie on my back at all without it hurting, have to lie on my side a bit
Jason Luboff
@JLuboff
Jan 29 17:27
Ya, mine is more focused on the lower left side too
Christopher McCormack
@cmccormack
Jan 29 17:27
yeah, me too...
do you do squats?
Jason Luboff
@JLuboff
Jan 29 17:27
Ya but haven't done any for probably a month or so
Christopher McCormack
@cmccormack
Jan 29 17:29
never thought I'd have a back injury brother lol
Jason Luboff
@JLuboff
Jan 29 17:34
Right? I don't think I messed it up squating..but who knows
Christopher McCormack
@cmccormack
Jan 29 17:40
Yeah not sure, I'm pretty sure I did, but it's hard to tell. I keep aggrevating it after it heals by doing stupid things
Jason Luboff
@JLuboff
Jan 29 17:40
Sounds like me. We must be getting old
Also I finally looked up how to collapse all code in Atom. I really wish I did it sooner
Christopher McCormack
@cmccormack
Jan 29 17:41
Is that Code Folding?
Jason Luboff
@JLuboff
Jan 29 17:42
..maybe? Like if you have a function you can click on an arrow to collapse it so its only on a single line (you don't see inside it basically)
Christopher McCormack
@cmccormack
Jan 29 17:42
Yeah I think that's the same, super useful in long code
Jason Luboff
@JLuboff
Jan 29 17:43
Ya. I just collapsed all my test data, then was able to quickly drill down to the tests I need to modify
Christopher McCormack
@cmccormack
Jan 29 17:45
I wonder if there is an option to callapse all BUT the one you're in
Jason Luboff
@JLuboff
Jan 29 17:46
Hmm... maybe. But it's easy enough for me at this point so I'll be lazy and not look that up lol
Jason Luboff
@JLuboff
Jan 29 19:00
Ugh... getting lost in my own code again :satisfied:
Brad
@bradtaniguchi
Jan 29 19:14
I'm dealing with bugs that aren't even bugs, its bugs with the data and my code throws an error cuse it wont do its job if the data is messed up (since it creates issues down the line)
Jason Luboff
@JLuboff
Jan 29 19:14
Well your code should be able to handle the data :P
Brad
@bradtaniguchi
Jan 29 19:16
Oh yea it can handle it and then let it thru, (it can't fix it since its an open ended problem) but then down the line stuff will get messed up
Jason Luboff
@JLuboff
Jan 29 19:16
I'm guessing the data doesn't get validated?
Brad
@bradtaniguchi
Jan 29 19:16
Basically my code goes over all the ids and generates new ones, so we can "copy" things. The issue arised going over a part of the code that was missing an id
Jason Luboff
@JLuboff
Jan 29 19:17
Oh.. why would it not have an id?
Brad
@bradtaniguchi
Jan 29 19:17
IDK some other code that creates the data was to leanit and didn't give a shit if it wasn't there -___- just so it doesn't throw errors right
Jason Luboff
@JLuboff
Jan 29 19:18
So whats your solution? Add validation for the id, or skip over those without id's?
Brad
@bradtaniguchi
Jan 29 19:23
First is fix the data that is messed up, then fix the code that creates the data to do it correctly
Christopher McCormack
@cmccormack
Jan 29 19:23
what about the code that validates the data?
Brad
@bradtaniguchi
Jan 29 19:24
I shouldn't even call it create, its a migration util that takes stuff from 1 user creates a template from it, that I can create for another user
The issue is only my code validates the data when it comes in (to prevent odd issues down the line), the migration code didn't give a damn if the code it's getting is old/invalid
Nate Mallison
@NJM8
Jan 29 20:48
You guys gotta stretch your hip flexors
@cmccormack @JLuboff
They get tight sitting all day and they pull on your lower back. I gotta do hamstrings, hip flexors, and trunk twists or my back kills me.
Christopher McCormack
@cmccormack
Jan 29 21:02
I do a slew of stretches before I work out
But unfortunately I went a little lax on my form
Nate Mallison
@NJM8
Jan 29 21:03
In the am though? I find that after squats if I don't stretch a bunch in the am for the days after, everything gets tight.
the problem is you are working out in a sitting position basically, then just sitting at a desk all day, so everything tightens up as the muscles heal. My back was killing me a few days after squats last week.
Next morning did 15 minutes stretching and everything was good.
Lots of ab work too.
Jason Luboff
@JLuboff
Jan 29 21:06
Ya need to get better about stretching
Christopher McCormack
@cmccormack
Jan 29 21:13
Yeah man, I've been doing this for over 15 years, learned about good stretching in the Army, just getting old I guess :)
enestatli
@enestatli
Jan 29 21:27
hello
Kaz Baig
@kbaig
Jan 29 21:27
:wave:
enestatli
@enestatli
Jan 29 21:28
I get this error "has not yet agreed to our Academic Honesty Pledge."
Jason Luboff
@JLuboff
Jan 29 21:28
Hi
enestatli
@enestatli
Jan 29 21:29
why is that ? :(
just completed responsive web design projects
but whenever I tried to claim my certification it returns this error
Kaz Baig
@kbaig
Jan 29 21:31
You should go back to one of the earliest pages and you'll find the pledge
enestatli
@enestatli
Jan 29 21:32
@kbaig damn, I forgot to accept the privacy thing :D
after 4 months I could finally get the certificate
@kbaig thank you
Christopher McCormack
@cmccormack
Jan 29 21:34
nice
you finally have integrity @enestatli :D
enestatli
@enestatli
Jan 29 21:35
@cmccormack yes man, and that feels amazing :D
enestatli
@enestatli
Jan 29 21:40
if you have a little time please give me some feedback for my portfolio page: https://codepen.io/enestatli/full/yZarEw
Jason Luboff
@JLuboff
Jan 29 21:43
Couple of things. 1. Your navbar (About/Projects/Contacts) should have a solid background color as right now as you scroll, it overlays the text making both difficult to read 2. I think if you're only going to utilize half the page for content, the other half should have something a picture or animation I dunno just seems like wasted space
Kaz Baig
@kbaig
Jan 29 21:43

Your navbar (About/Projects/Contacts) should have a solid background color

Could add a color after a certain amount of scroll

ughhh React hooks scheduled for feb 4 but I'll be traveling then
Jason Luboff
@JLuboff
Jan 29 21:45
So you have a phone
enestatli
@enestatli
Jan 29 21:48
@JLuboff thanks I was thinking the same thing but do not know how to fix it but now something came my mind :D and about the second advice, wish I thought of that before, it took up time too much
Jason Luboff
@JLuboff
Jan 29 21:49
:thumbsup:
enestatli
@enestatli
Jan 29 21:49
@kbaig after a certain amount of scroll? I need to check google
Kaz Baig
@kbaig
Jan 29 21:49
like have it so it changes color once you scroll down to the content
DMZ
@DMZ011
Jan 29 21:54
hey all!
Jason Luboff
@JLuboff
Jan 29 21:55
Hey
enestatli
@enestatli
Jan 29 21:56
@kbaig try something tomorrow, now I need sleep, thank you:D
have a nice day all!
DMZ
@DMZ011
Jan 29 21:56
@JLuboff how are u?
Christopher McCormack
@cmccormack
Jan 29 22:03
@kbaig what will you be missing?
Pagnito
@Pagnito
Jan 29 22:03
hey im havin trouble accessin my ip address from another computer, im tryin to test something on my project and i need to access it from another computer
i dont wanna use localtunnel btw
Christopher McCormack
@cmccormack
Jan 29 22:04
@Pagnito on the same network?
Pagnito
@Pagnito
Jan 29 22:04
yea
Christopher McCormack
@cmccormack
Jan 29 22:04
can you ping the other computer?
Pagnito
@Pagnito
Jan 29 22:04
how?
Christopher McCormack
@cmccormack
Jan 29 22:05
ping [other computer's IP]
from terminal/cmd
so if you're both on a home network, for example, and the other computer's IP is 192.168.0.101, ping 192.168.0.101
Pagnito
@Pagnito
Jan 29 22:06
sweet, im glad i asked u, i feel like this will be usefull in future too. But anways i think i might been doing something wrong, hold on
Christopher McCormack
@cmccormack
Jan 29 22:06
that will at least give you somewhat of an idea if the other host is reachable, although it won't necessarily work if there is a local firewall preventing it
Jason Luboff
@JLuboff
Jan 29 22:10
@DMZ011 Doing alright, yourself?
Kaz Baig
@kbaig
Jan 29 22:12
@cmccormack the opportunity to use it on day 1 that's all
Christopher McCormack
@cmccormack
Jan 29 22:12
can use it now lol
DMZ
@DMZ011
Jan 29 22:18
@JLuboff doing well
@cmccormack hey!
Christopher McCormack
@cmccormack
Jan 29 22:18
@DMZ011 hey shrek how's it going
Jason Luboff
@JLuboff
Jan 29 22:18
Is there a way to view the onclick method attached to an element in React DevTools? (Using it for Firefox in this case)
DMZ
@DMZ011
Jan 29 22:24
going well @cmccormack
Christopher McCormack
@cmccormack
Jan 29 22:55
@DMZ011 what you been up to?
@JLuboff did you figure it out?
Jason Luboff
@JLuboff
Jan 29 22:57
@cmccormack No, moved on lol . In the tools, I see the onClick and thats value is fn() and if I hit the arrow next to onClick to expand it, I see proto, length, name, and prototype. proto and prototype seem to be endless, length is 1, and name is blank
Christopher McCormack
@cmccormack
Jan 29 23:07
@JLuboff that may mean there isn't one, but I don't remember. I thought there was something that would show if you did have a callback passed to the handler
Jason Luboff
@JLuboff
Jan 29 23:08
I definitely have an attached method :-/
Christopher McCormack
@cmccormack
Jan 29 23:25
@JLuboff I just checked mine in the Chrome dev tools and it has something like onClick: bound myMethodName()
Jason Luboff
@JLuboff
Jan 29 23:32
Hmmm... let me try Chrome then'
Huh...same thing in Chrome...
Wasiu Idowu
@Hoxtygen
Jan 29 23:58
Hello guys, how you all doing?
I'm here with my question again