These are chat archives for FreeCodeCamp/HelpJavaScript

11th
Dec 2018
Christopher McCormack
@cmccormack
Dec 11 2018 00:00
add a linter rule and add automating --fix
Jason Luboff
@JLuboff
Dec 11 2018 00:02
Mmmhm yes yes
Sounds like work. But.. work that I will probably do becuase its annoying me
Christopher McCormack
@cmccormack
Dec 11 2018 00:08
could get complicated though
Brad
@bradtaniguchi
Dec 11 2018 00:10
It's work to get it automated, then after that its negative work :D
Jason Luboff
@JLuboff
Dec 11 2018 00:13
:thumbsup: Thanks bud
Jason Luboff
@JLuboff
Dec 11 2018 00:33
Why does React not like empty anchor tags?
Pagnito
@Pagnito
Dec 11 2018 01:10
anyone know how i can return a response to my front end from a service worker, i cached a resolved promise, so basically the data, but my front end expects a promise
Brad
@bradtaniguchi
Dec 11 2018 01:13
@Pagnito So your just asking how to send data from a service worker to your front-end?
Pagnito
@Pagnito
Dec 11 2018 01:13
kind of hold on, i think i figured it out, ill get back if im having trouble still
Pagnito
@Pagnito
Dec 11 2018 01:40
yea nvm i didnt solve it
basically my prbolem is that my sw is intercepting a fetch request for an array of object wit some data
on the first visit cache it, in indexedDB
on ssecond i try to read it, bu the problem is when i read it returns the array instead of a promise that my request expects
found it
Aditya
@ezioda004
Dec 11 2018 02:25
@JLuboff React doesnt like a lot of things, but I guess most of them are linter settings :D
Christopher McCormack
@cmccormack
Dec 11 2018 02:32
@ezioda004 :wave: morning
Brad
@bradtaniguchi
Dec 11 2018 02:33
Morning, damn I'm about to head home from a long days work hehe
Christopher McCormack
@cmccormack
Dec 11 2018 02:34
@bradtaniguchi same just got home myself, already ready for sleep
Aditya
@ezioda004
Dec 11 2018 02:34
@cmccormack Hey, fell asleep early yesterday(getting old)
Hows it going :wave:
Christopher McCormack
@cmccormack
Dec 11 2018 02:35
@ezioda004 when you get old, going to sleep early is awesome
good man just jumping around https://overreacted.io Dan Abramov's blog trying to better understand React a bit
Aditya
@ezioda004
Dec 11 2018 02:36
Yeah, his blogs and talks are great
Christopher McCormack
@cmccormack
Dec 11 2018 02:39
@ezioda004 what you up to

Such dorks over there on the React team:

Alas, they don’t get this extra protection. React still includes the $$typeof field on the element for consistency, but it’s set to a number — 0xeac7.

Why this number specifically? 0xeac7 kinda looks like “React”.

Jason Luboff
@JLuboff
Dec 11 2018 02:41
...dare I ask how old @Aditya is...
Aditya
@ezioda004
Dec 11 2018 02:41
Got Math exam in couple of hours, looking through the book real quick
@JLuboff Haha, I'm 22
Jason Luboff
@JLuboff
Dec 11 2018 02:43
Oh you’re still a youngin’ 😛
Aditya
@ezioda004
Dec 11 2018 02:44
@cmccormack Lol, they also had that funny prototype name
React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOM;
Christopher McCormack
@cmccormack
Dec 11 2018 02:44
haha
I remember finding that by accident and slightly exhaling air in amusement
Aditya
@ezioda004
Dec 11 2018 02:46
Has technology gone too far?
Theres also giveaway of those drones by IBM, but to only US/Canada resident, ya'll could try
Pagnito
@Pagnito
Dec 11 2018 02:47
how do i attach key:values on to req.body like axios does, but with fetch
Christopher McCormack
@cmccormack
Dec 11 2018 02:48
@Pagnito you mean how to send additional properties along with the body to the backend?
@ezioda004 I heard that on his podcast but thanks for sharing the video, hadn't seen it
Aditya
@ezioda004
Dec 11 2018 02:48
fetch have a body property in its 2nd argument
Pagnito
@Pagnito
Dec 11 2018 02:49
im not sure how to phrase it, but u know how with axios, u can just say axios.post(url, object) and on the back end use req.body.objectKey and get the object value
fetch('/api/get_gifs', {
      method: "POST",
      headers: {
        "body": chunk,
        "Accept":"application/json",
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
        }
      })
but i dont recive the chunk object on the back end
let chunk = {
      chunkCounter:this.state.chunkLocation
    }
Christopher McCormack
@cmccormack
Dec 11 2018 02:50
what format is the chunk?
Aditya
@ezioda004
Dec 11 2018 02:51
The body shouldnt be in headers I think
Christopher McCormack
@cmccormack
Dec 11 2018 02:51
agreed
Aditya
@ezioda004
Dec 11 2018 02:51
In past I've done lke
var data = {username: 'example'};

fetch(url, {
  method: 'POST', // or 'PUT'
  body: data,
  headers: {... }
  })
Pagnito
@Pagnito
Dec 11 2018 02:52
OOOO
WOW
lol
ihow did i not notice that lol
thanks
Christopher McCormack
@cmccormack
Dec 11 2018 02:53
with json I believe you need to sent the content type
      body: JSON.stringify(jsonData),
      headers: { "Content-Type": "application/json", },
Pagnito
@Pagnito
Dec 11 2018 02:57
fetch('/api/get_gifs', {
      method: "POST",
      body: JSON.stringify(chunk),
      headers: {
        "Accept":"application/json",
        "Content-Type": "application/json"
        }
      })
on the back end i still seem to be getting an empty object on req.body
Christopher McCormack
@cmccormack
Dec 11 2018 02:59
What format is the chunk?
Pagnito
@Pagnito
Dec 11 2018 02:59
oh i got it
Christopher McCormack
@cmccormack
Dec 11 2018 02:59
Are you using auth? Does your endpoint require auth?
ah great
Pagnito
@Pagnito
Dec 11 2018 03:00
the data in chunk had a typo >.<
typos are the most paralyzing i swear
cuz it always makes it seem like ur fucked
Christopher McCormack
@cmccormack
Dec 11 2018 03:02
but it's also low hanging fruit!
it's when you can't find the typo you're really going to have to search
Pagnito
@Pagnito
Dec 11 2018 03:05
yea thats true
Brad
@bradtaniguchi
Dec 11 2018 03:09
Or use typescript muhahaha
Pagnito
@Pagnito
Dec 11 2018 03:09
anyone know about converting json into a respone object
lmao
yea i want to, but i put it on for later, i had a pain tin the ass hookin it up with react
i know there is like an official boilerplate but i wanted to do it myself >.<
Christopher McCormack
@cmccormack
Dec 11 2018 03:11
@Pagnito converting it? Can you just do res.json(jsonObj)?
Pagnito
@Pagnito
Dec 11 2018 03:11
nah i mean a response object before u call json() on to it
basically taking what u get from res.json()
and converting it back to what it was
Pagnito
@Pagnito
Dec 11 2018 03:22
the problem im having is retrieving indexdDB cached data
i cant pass into respondWith() a non response object
but it doesnt seem to work even with the new Response
Christopher McCormack
@cmccormack
Dec 11 2018 03:25
unsure sorry
Pagnito
@Pagnito
Dec 11 2018 03:38
ah
shit
this whole time
i didnt even have to use indexedDB
my dynaamic caching can cache it
and i dont gotta worry about the whole reponse thingy
Precious adeyinka
@precious-adeyinka
Dec 11 2018 09:07
@thodorisanta No its fine, thanks.. your welcome buddy...
tundeiness
@tundeiness
Dec 11 2018 09:55
hi guys I need directions please. So I am doing some React project(s) as required by FCC. My challenge/ assumption is that There is no way I can do such project in codepen and then submit it to FCC or is it possible? if it is not how do I get to do the project without using local server?
Greg Duncan
@GregatGit
Dec 11 2018 13:01
@tundeiness I recomend you use create-react-app
yayne
@yayne
Dec 11 2018 13:33
Hi friends, How to customize button in the div? it means when i tried it for small device, the button out of the div. How can i customize it? thanks
Tom
@moT01
Dec 11 2018 13:51
@yayne what do you want to happen
add some style to it
and color
and effects
Mohammed Boudad
@matrixersp
Dec 11 2018 14:01
@tundeiness Yes you can do them in codepen
Go to settings > select JavaScript tab > In JavaScript Preprocessor choose babel then search for react and react-dom and add them
After that you can work on your React projects
yayne
@yayne
Dec 11 2018 14:10
image.png
@moT01 ... see it the image... I can't put the code on the codepen because I have alot of files and some of the file in ShadowDom and some of out of it... but the one you saw green background is out of ShadowDom and the buttons are in ShadowDom. The violet background it the body. As you see the button is out of the div. I can't customize it
Tom
@moT01
Dec 11 2018 14:24
you can make a reduced version on codepen that can demonstrate the problem
I dont have an answer for you without seeing some code. Is there at least a repo?
You can't add some css to limit the size?
Spyrantis Theodoros
@thodorisanta
Dec 11 2018 14:27
is recursion a good way to solve a problem or not? doesnt it slow down the whole program?
Tom
@moT01
Dec 11 2018 14:30
1000 lines of code there
Aditya
@ezioda004
Dec 11 2018 14:31
@thodorisanta In JS? Depends, but tail recursion can be faster, JS can do it but except safari no other browsers support it. Also, recursion can make your code clean and elegant.
Tom
@moT01
Dec 11 2018 14:33
@yayne you must have given it the style it currently has - gray background, font style, etc... you can't just fix it in there?
Spyrantis Theodoros
@thodorisanta
Dec 11 2018 14:35
@ezioda004 the fast that only safari supports it isnt a reason to not use it?
Aditya
@ezioda004
Dec 11 2018 14:37
@thodorisanta Its more like you write the same code but engines interpret differently, not a syntactic thing.
Chrome will not use tail recursion for this but safari will:
function factorial(num){
  return num == 1 ? 1 : num * factorial(num-1);
}
yayne
@yayne
Dec 11 2018 14:43
@moT01 ...the problem is it is not responsive
Tom
@moT01
Dec 11 2018 14:46
so make it responsive
try using some units that would be responsive
like 100% instead of 200px
Spyrantis Theodoros
@thodorisanta
Dec 11 2018 14:48
@ezioda004 so how will chrome deal with this?
Aditya
@ezioda004
Dec 11 2018 15:00
Umm, just as a regular recursive function, tail recursion is an optimization
KingKongg
@KingKongg
Dec 11 2018 15:22
Hi , anybody can help ? I'm doing the Palindrome Checker challenge. I passed all the test except for "almostomla"
function palindrome(str) {

let lowerCaseStr=str.toLowerCase();
let testStr=lowerCaseStr.replace(/[\W_]+/g,"");

for(let i=0;i<testStr.length;i++){

if(testStr.charAt(i)==(testStr.charAt(testStr.length-1-i))){
  console.log(testStr.charAt(i))
return true;
}
else{
  return false;
}
}
}
palindrome("almostomla");
can't seem to figure out why
would appreciate any help
Christopher McCormack
@cmccormack
Dec 11 2018 15:29
@KingKongg please use proper code markdown when you paste code so it's easy to read. There is a markdown button on the bottom right that shows you how to do this, but basically you wrap the code in three backticks, with the backticks on their own line (optionally, you can add the code syntax you prefer after the backticks on the first line):
```js
Code
```
You can also edit previous posts
@KingKongg most likely your issue is you aren't accounting for odd length strings, where the middle character will be used twice
KingKongg
@KingKongg
Dec 11 2018 15:31
@cmccormack Thank you for letting me know!
Christopher McCormack
@cmccormack
Dec 11 2018 15:33
@KingKongg here's a hint: you don't have to loop through the whole string; once you're half way through you should have already checked all characters.
When creating your condition to only iterate through half the string, you can include a way to ignore the middle character in an odd length string as well
Christopher McCormack
@cmccormack
Dec 11 2018 15:38
@KingKongg you're also returning way too early - you have return true below a conditional that will only be run once at max when you add the return
I believe just fixing this last issue will allow you to pass all the tests with the rest of your code being the same
KingKongg
@KingKongg
Dec 11 2018 15:58
@cmccormack Thank you for your help. But I'm still quite confused by what you mean .
I'm trying to loop through half of the string instead of the full string
Christopher McCormack
@cmccormack
Dec 11 2018 15:59
@KingKongg did you read my last few sentences?
focus on that first
Tom
@moT01
Dec 11 2018 16:04
morning
Christopher McCormack
@cmccormack
Dec 11 2018 16:08
@moT01 yo
Tom
@moT01
Dec 11 2018 16:09
hey
Christopher McCormack
@cmccormack
Dec 11 2018 16:11
what's happening today?
Tom
@moT01
Dec 11 2018 16:12
doing one of the files right now
comin along, we're almost down to 7,000
Christopher McCormack
@cmccormack
Dec 11 2018 16:13
yeah it seems to go much faster this way
Tom
@moT01
Dec 11 2018 16:13
you've been doing quite a few eh?
Christopher McCormack
@cmccormack
Dec 11 2018 16:14
Which one you working on?
@moT01 I got through blender, html, and cryptocurrency, now working on Python
Tom
@moT01
Dec 11 2018 16:14
im doing html forms
Pagnito
@Pagnito
Dec 11 2018 16:15
woop woop, finally finished my sw, now my u can have full functionality offline even stay logged in offloine >:)
Christopher McCormack
@cmccormack
Dec 11 2018 16:15
that should be fun, bet it's going to be mostly the same grammar/punctuation mistake fixes in each PR
@Pagnito wanna try that sentence again?
lol
Pagnito
@Pagnito
Dec 11 2018 16:16
lmao
forreal i just read that jumbled mess
Jason Luboff
@JLuboff
Dec 11 2018 16:16
Morning :wave:
Pagnito
@Pagnito
Dec 11 2018 16:16
morning
Christopher McCormack
@cmccormack
Dec 11 2018 16:16
@JLuboff yo
@Pagnito that's awesome, can we use you as a resource now? :)
Jason Luboff
@JLuboff
Dec 11 2018 16:16
Whats happening?
Pagnito
@Pagnito
Dec 11 2018 16:16
word will be glad to help
Christopher McCormack
@cmccormack
Dec 11 2018 16:16
more api work/slowly working through FCC PRs. You?
@Pagnito excellent thanks!
Pagnito
@Pagnito
Dec 11 2018 16:17
np
Christopher McCormack
@cmccormack
Dec 11 2018 16:17
my next project I want to add PWA/JWT/graphQL/Redux/other tech I haven't yet touched
Jason Luboff
@JLuboff
Dec 11 2018 16:17
Think I'm going to work on breaking up my React app this morning..
My next project I'm going to add Electron :scream:
Christopher McCormack
@cmccormack
Dec 11 2018 16:18
@JLuboff that's pretty cool, my wife just made a few electron apps for fun, she doesn't know much about webdev but still got it working
Jason Luboff
@JLuboff
Dec 11 2018 16:18
Nice. They make it sound easy enough so...we'll see lol
Christopher McCormack
@cmccormack
Dec 11 2018 16:19
She has a team that will be building something for her lab, but she wanted to learn Electron first so if they try to lie to her about something she can punch them in the brain
Jason Luboff
@JLuboff
Dec 11 2018 16:19
So...do the two of you nerd out on node/react/etc?
Christopher McCormack
@cmccormack
Dec 11 2018 16:21
not really, she's still not really ready to jump into the web dev stuff but we do nerd out on Python and Linux pretty often
Jason Luboff
@JLuboff
Dec 11 2018 16:21
Ah.. what exactly does she do?
Christopher McCormack
@cmccormack
Dec 11 2018 16:22
i'll ping you her bio :)
Biology crossed with data/computer science
Jason Luboff
@JLuboff
Dec 11 2018 16:23
Ya...wow. I did not understand most of that bio.. lol
Christopher McCormack
@cmccormack
Dec 11 2018 16:23
me neither
Jason Luboff
@JLuboff
Dec 11 2018 16:23
But..you're married to a doctor eh?
Christopher McCormack
@cmccormack
Dec 11 2018 16:24
haha yeah
she wasn't a doctor when I met her so no sugar momma ambitions
Jason Luboff
@JLuboff
Dec 11 2018 16:24
:joy:
Christopher McCormack
@cmccormack
Dec 11 2018 16:25
I wouldn't wish becoming a science doctor on anyone, so much work
Jason Luboff
@JLuboff
Dec 11 2018 16:25
My buddy just finished his Phd in Biochemistry... sounds like a hell of a lot of work lol
And not necessarily making big money
Christopher McCormack
@cmccormack
Dec 11 2018 16:26
yeah that's the worst part!
but hopefully they are smart enough to find their way into something high paying later
Jason Luboff
@JLuboff
Dec 11 2018 16:28
Well.. he just finished in September and was working a research job.. stayed a few months where he was due to some stupid legal trouble... than took a month to drive cross country and now looking for a job lol He said least he would take a position for is $75k/year but more likely around the $100k/year which isn't bad but I guess when I think phd I think big money hah
Christopher McCormack
@cmccormack
Dec 11 2018 16:29
It definitely can be but you have to find where it's in high demand
Jason Luboff
@JLuboff
Dec 11 2018 16:29
True
Christopher McCormack
@cmccormack
Dec 11 2018 16:29
they are problem solvers, which is a great benefit
I bet their upward mobility is higher than those without a PhD as well
Jason Luboff
@JLuboff
Dec 11 2018 16:31
That is a good point
Christopher McCormack
@cmccormack
Dec 11 2018 16:32
I can't wait for tonight - Google is buying me drinks at an aquarium
Jason Luboff
@JLuboff
Dec 11 2018 16:32
Whattt!
Christopher McCormack
@cmccormack
Dec 11 2018 16:32
yeah!
There is a Google Cloud Platform event near my house at an aquarium tonight, I got invited as I've been helping our cloud teams a lot
I can never pass up free food/drinks
Jason Luboff
@JLuboff
Dec 11 2018 16:33
Thats super cool
Christopher McCormack
@cmccormack
Dec 11 2018 16:33
it will most likely be the death of me
yeah I'm pretty excited
Maybe I can schmooze my way into an awesome Google job or something lol
Tom
@moT01
Dec 11 2018 16:34
nice
Christopher McCormack
@cmccormack
Dec 11 2018 16:35
it's at 18:30 MST if either of you wants to fly in and be my +1 haha
Jason Luboff
@JLuboff
Dec 11 2018 16:35
That'd be cool. Need a plus one? :P
:joy:
Christopher McCormack
@cmccormack
Dec 11 2018 16:36
Wife couldn't stay and join me :(
Jason Luboff
@JLuboff
Dec 11 2018 16:38
Lame
I hate that SSRS uses VB.NET
Tom
@moT01
Dec 11 2018 16:41
on my way
Christopher McCormack
@cmccormack
Dec 11 2018 16:41
@JLuboff VB.NET includes C# doesn't it?
@moT01 sweet!
Jason Luboff
@JLuboff
Dec 11 2018 16:42
@cmccormack No. Two different, but somewhat similar languages. They both use .NET so thats where some of the shared syntax comes into play
Christopher McCormack
@cmccormack
Dec 11 2018 16:42
oh yeah duh Visual Basic
I was ignoring the VB part and just thinking of .NET
Jason Luboff
@JLuboff
Dec 11 2018 16:43
:)
Christopher McCormack
@cmccormack
Dec 11 2018 16:43
yeah VB is dim
Jason Luboff
@JLuboff
Dec 11 2018 16:43
Yup.. its dim... (and why the hell do you define a variable with dim anyhow?)
Christopher McCormack
@cmccormack
Dec 11 2018 16:44
seems like legacy verbiage to me
Jason Luboff
@JLuboff
Dec 11 2018 16:47
Ya. I hate VB lol
C#...not bad...
Christopher McCormack
@cmccormack
Dec 11 2018 16:49
yeah I would definitely like to try out C# if I was making a native app or something. I might try to use it as a backend sometime as our automation team has been using it for a while
Tom
@moT01
Dec 11 2018 16:52
I dont think I can do these guide article's anymore
They're just too sloppy
Christopher McCormack
@cmccormack
Dec 11 2018 16:56
@moT01 it is like scraping teeth
(that's a saying, right?)
Tom
@moT01
Dec 11 2018 16:57
in a mouth with 7,000 teeth
and when you're done, you realize the scraping did nothing
Christopher McCormack
@cmccormack
Dec 11 2018 16:58
of course it did, it severely damaged the teeth!
man people have been adding new ones recently
Tom
@moT01
Dec 11 2018 16:58
encouraging this way of contribution was not a good idea
Christopher McCormack
@cmccormack
Dec 11 2018 16:59
maybe for the guides, contributors should be able to merge other PRs as well. Maybe it will work out perfectly, like Twitch Plays Pokemon lol
Tom
@moT01
Dec 11 2018 17:00
im lost on that one
Christopher McCormack
@cmccormack
Dec 11 2018 17:00
the twitch thing?
Tom
@moT01
Dec 11 2018 17:01
both
Christopher McCormack
@cmccormack
Dec 11 2018 17:01
basically they crowdsourced the playing of one of the Pokemon games to their chat room, so they would spam the channel with directions and actions. Eventually, they beat the game
wasn't fast though
Jason Luboff
@JLuboff
Dec 11 2018 17:01
Man...that was years ago wasnt it?
Christopher McCormack
@cmccormack
Dec 11 2018 17:02
there were even factions that would fight against each other
bots were probably rampant
but they still won
wow that was 2014?
feels like yesterday
Tom
@moT01
Dec 11 2018 17:04
I wonder if people are using the guide much
Christopher McCormack
@cmccormack
Dec 11 2018 17:05
I know I've learned a lot from it by reviewing these PRs :)
but I don't think a few of us count as people
Tom
@moT01
Dec 11 2018 17:08
well, I guess there is that advantage - I have learned some things from reviewing them
Christopher McCormack
@cmccormack
Dec 11 2018 17:09
I wonder how good the FCC SEO is
get it high enough and those guides could surface near the top for a lot of search results
Tom
@moT01
Dec 11 2018 17:10
I was just looking into that
I know it's real high for some things
but I can't find any of the guides
Christopher McCormack
@cmccormack
Dec 11 2018 17:13
hmm I wonder if meta tag is still used for SEO and, if so, how a guide would have meta added
Tom
@moT01
Dec 11 2018 17:15
not sure
a lot of the fcc medium articles show up high
searching react it has the #4 spot
Christopher McCormack
@cmccormack
Dec 11 2018 17:16
but those get linked to from other sites which is great for the algorithm
Nate Mallison
@NJM8
Dec 11 2018 17:25
If I am working on branch A, need to jump to branch B, do some work, merge to master, then jump back to branch A, merge to master, will merging branch A overwrite what I did in branch B?
Also what if I want what I do in branch B to be in branch A, I have to rebase right?
Christopher McCormack
@cmccormack
Dec 11 2018 17:29
@NJM8 in your first scenario you didn't merge master to A or B correct?
and the second, did you merge B into master already?
Jason Luboff
@JLuboff
Dec 11 2018 17:31
Wouldn't you get a merge conflict?
Christopher McCormack
@cmccormack
Dec 11 2018 17:31
depends on the change
if it's a small project merges should be fine I believe. If there are a lot of changes being made all the time, rebasing a branch on top of master might be better
Spyrantis Theodoros
@thodorisanta
Dec 11 2018 17:50
First time seeing this systax and i wanna ask. [operator]); is this the return part? how exactly does it work?
const arithmetic = (a, b, operator) => ({
  'add'     : a + b,
  'subtract': a - b,
  'multiply': a * b,
  'divide'  : a / b
}[operator]);
Christopher McCormack
@cmccormack
Dec 11 2018 17:56
@thodorisanta where are you seeing that?
Spyrantis Theodoros
@thodorisanta
Dec 11 2018 17:58
@cmccormack just a function im practicing with that takes 2 numbers and an operator string as a value
that was one of the given answers
Christopher McCormack
@cmccormack
Dec 11 2018 17:59
ok... where are you seeing it?
Spyrantis Theodoros
@thodorisanta
Dec 11 2018 17:59
i did it with a switch. But some guy did it like that and im curious on how it works
what exactly do you mean? where im seeing the [operator]); ?
Christopher McCormack
@cmccormack
Dec 11 2018 18:00
no where are you seeing this block of code
Spyrantis Theodoros
@thodorisanta
Dec 11 2018 18:00
in a site that lets you practice javascript
Christopher McCormack
@cmccormack
Dec 11 2018 18:00
jeeze like pulling teeth here
Spyrantis Theodoros
@thodorisanta
Dec 11 2018 18:01
someone once told me we are not "allowed" to mention other sites as a part of "advertisement"
Christopher McCormack
@cmccormack
Dec 11 2018 18:01
you can access object properties using the brackets notation
Spyrantis Theodoros
@thodorisanta
Dec 11 2018 18:01
does it even matter?
oh
Christopher McCormack
@cmccormack
Dec 11 2018 18:01
so if the operator is a string, it would lookup the property
yeah it matters if we want the context of the question
Nate Mallison
@NJM8
Dec 11 2018 18:08
@cmccormack No merges from master to branch, just branch to master. I'm on a branch working on some features that will take awhile, but I want to jump into another to make some quick fixes. Merge that into master so they have it in production. Then go back to feature branch and merge it into master later
Christopher McCormack
@cmccormack
Dec 11 2018 18:09
you can rebase your changes on top of master on the branch you still want to work on
Nate Mallison
@NJM8
Dec 11 2018 18:10
Ok, and assuming none of my changes in either branch conflict it will be ok?
Christopher McCormack
@cmccormack
Dec 11 2018 18:10
even if they do, just fix the conflict then git rebase --continue
odds are you would want the quick fixes to master to be in your long term branch
thinking hot fix or something
rebasing long term onto master will move your current commits on top of master so merging back later should be easier
Nate Mallison
@NJM8
Dec 11 2018 18:12
So far I'm the only one working on the front end one feature at a time, so we have yet to have two branches. I could just fix them on my current branch, merge it to master then keep working on my current branch and merge again. But I want to do it the right way and learn more complex work flows with git
Christopher McCormack
@cmccormack
Dec 11 2018 18:12
Just remember - I don't do this very often as I am not a developer by trade, just read a lot on rebasing/merging
Nate Mallison
@NJM8
Dec 11 2018 18:12
Ok
Wait what
you aren't?
Christopher McCormack
@cmccormack
Dec 11 2018 18:12
nope
network engineer
Nate Mallison
@NJM8
Dec 11 2018 18:12
A wolf in sheep's clothing all this time!!!
Christopher McCormack
@cmccormack
Dec 11 2018 18:13
haha I never hid that!
Nate Mallison
@NJM8
Dec 11 2018 18:13
Lol I know I just always forget
I'll make a practice directory and try things out
Christopher McCormack
@cmccormack
Dec 11 2018 18:15
this may help
I've read it a few times and always get a few little extra tidbits out each time
yayne
@yayne
Dec 11 2018 18:27
@moT01 Thanks... i did with width 100% and with others parameter
Spyrantis Theodoros
@thodorisanta
Dec 11 2018 18:49
if i have an array lie arr = [1,2,'a','b'] and i wanna remove the strings from the array and only keep the numbers. shouldnt the regular expression for it be
let newArr = [];
newArr = arr.match(/\d/g);
or am i missing something
Jason Luboff
@JLuboff
Dec 11 2018 18:49
.match() is a string method, not array method
I would probably use .filter()
Spyrantis Theodoros
@thodorisanta
Dec 11 2018 18:51
@JLuboff something like newArr = arr.filter(a => a == /\d/g); ?
Jason Luboff
@JLuboff
Dec 11 2018 18:52
You'd want to use .test(), as far as I know you can't check equality against regex
.test() will return a boolean
I want to hide this one way carousel on the last slide - I check for it using $("#carousel-section .owl-item.active").nextAll().length; which throws the right value when I console log it in the browser but in the click event its always 3 what am I doing wrong?
Mike Smith
@MikeSS281986
Dec 11 2018 18:59
hey everyone. im having a damned time figuring this out. how come when i run this, i cant return true or false but i can console log true or false?
let validNumber = (arr) => {
    let result = arr.reduce((total, n) => {
      return total + n;
    });
    if(result % 10 === 0) {
      return true;
    } else {
      return false;
    }
  }

validNumber([2,2,6,0]);
so this code here would be true, can condole log true but not return it. i even tried
return result % 10 == 0 ? true : false;
Brad
@bradtaniguchi
Dec 11 2018 19:01
@MikeSS281986 Where are you doing the console log?
Jason Luboff
@JLuboff
Dec 11 2018 19:01
The return value would only show in console.log unless you're writing it to the DOM or something
Spyrantis Theodoros
@thodorisanta
Dec 11 2018 19:04
@JLuboff maybe regular expressions isnt the way to go here. i did it like that return arr.filter(a => typeof a == "number"); :/
Mike Smith
@MikeSS281986
Dec 11 2018 19:06
i would have sub'd the return true/false for console.log true/false @bradtaniguchi
Brad
@bradtaniguchi
Dec 11 2018 19:07
@MikeSS281986 Ah
Jason Luboff
@JLuboff
Dec 11 2018 19:07
@thodorisanta If it works, it works :P
Brad
@bradtaniguchi
Dec 11 2018 19:07
let validNumber = (arr) => {
    let result = arr.reduce((total, n) => {
      return total + n;
    });
    if(result % 10 === 0) {
      console.log('result:' ,true);
      return true;
    } else {
      console.log('result:' , false);
      return false;
    }
  }

validNumber([2,2,6,0]);
Mike Smith
@MikeSS281986
Dec 11 2018 19:08
i was solving a problem in codewars and its needing to return true or false,
Brad
@bradtaniguchi
Dec 11 2018 19:08
You could console.log, and still return the value. Or you can console.log the output of the entire function:
console.log(validNumber([2,2,6,0]))
@MikeSS281986 That's fine, the console.log will spit out to the console, while the function still goes about and does its job
It should work, even for codewars
Mike Smith
@MikeSS281986
Dec 11 2018 19:09
let me give it a go.
i got it. i return the actual function.
that function was just one of others in a function. So i just returned it :)
Brad
@bradtaniguchi
Dec 11 2018 19:15
Yes, if yourr talking about the validNumber function being called within another function that returns its result yes.
Mike Smith
@MikeSS281986
Dec 11 2018 19:18
yep. had that "ah ha!"moment. since it return true or false, just return the function to get that. :)
brain farts happen to us all i guess.
Brad
@bradtaniguchi
Dec 11 2018 19:21
hehe yes totally (happened to my coworker yesterday)
Mike Smith
@MikeSS281986
Dec 11 2018 19:21
lo!
thanks all.
Brad
@bradtaniguchi
Dec 11 2018 19:24
np :D
Nate Mallison
@NJM8
Dec 11 2018 19:44
@cmccormack I haven't actually pulled in my master branch in awhile, just keep opening new branches from the old one and on the server they merge it into master: Your branch is behind 'origin/master' by 1400 commits, and can be fast-forwarded.
haha
Spyrantis Theodoros
@thodorisanta
Dec 11 2018 19:46
can i use .repeat().toLowerCase() to a string so that only the first letter will be capitalize ?
Nate Mallison
@NJM8
Dec 11 2018 19:47
repeat will repeat the string it is passed
toLowerCase will lowercase an entire string
Brad
@bradtaniguchi
Dec 11 2018 19:51
@NJM8 Man I freakout when I see more than 5 behind haha
Nate Mallison
@NJM8
Dec 11 2018 19:52
lol
I've just been branch hopping
Pagnito
@Pagnito
Dec 11 2018 20:13
Screen Shot 2018-12-11 at 3.13.31 PM.png
anyone know what this is about?
nvm
Zaza
@ForkInSpace
Dec 11 2018 21:11
Hola amigos!
yayne
@yayne
Dec 11 2018 21:23
Hi, background-image shrinks when i check its responsiveness to small device. I tried different ways but i can't. Is there anyways to solve it?
Pagnito
@Pagnito
Dec 11 2018 21:23
hey where do insert the link that i actually want to share
<a class="resp-sharing-button__link" href="https://facebook.com/sharer/sharer.php?u=http%3A%2F%2Fsharingbuttons.io" target="_blank" aria-label="Share on Facebook">
<i className="fab fa-facebook-square"></i>
</a>
  <a class="resp-sharing-button__link" href="https://facebook.com/sharer/sharer.php?u=http%3A%2F%2Fsharingbuttons.io" target="_blank" aria-label="Share on Facebook">
                <i className="fab fa-facebook-square"></i>
            </a>
Karma Drukpa
@coderkarma
Dec 11 2018 21:25
:wave:
Pagnito
@Pagnito
Dec 11 2018 21:29
i think i got it
Karma Drukpa
@coderkarma
Dec 11 2018 21:33
Hello folks need help on react props
This message was deleted
Aditya
@ezioda004
Dec 11 2018 21:38
What is it?
Aditya
@ezioda004
Dec 11 2018 21:40
title={title} where is the title coming from?
Karma Drukpa
@coderkarma
Dec 11 2018 21:40
@ezioda004 how would i return the props of the components .
@ezioda004 no where, I was trying to render.
got confuse with these
Pagnito
@Pagnito
Dec 11 2018 21:42
anyone know about share links. I want to have share links that show content on that social networks feed besides just a link
Karma Drukpa
@coderkarma
Dec 11 2018 21:42
const MediaCard = (title, body, imgURL) => {
  return (
    <div>
      <h2>{title}</h2>
      <p>{body} </p>
      <img src={imgeURL} />
    </div>
  );
};

export default MediaCard;
Aditya
@ezioda004
Dec 11 2018 21:42
@coderkarma You dont return the props of the component. It doesnt make sense, because you're directly rendering the <App> component, so no other props will be passed to it since its the top level component (unless ofc you use a HOF).
Yeah thats fine, as long as you pass the appropriate props to <MediaCard />
Karma Drukpa
@coderkarma
Dec 11 2018 21:45
yeah that's my confusion, could you show me how would i pass that.
Aditya
@ezioda004
Dec 11 2018 21:46
<MediaCard title={"title"} body = {"body"} imgURL = {"url"} />
So, the strings I'm using can be changed to other valid references
Karma Drukpa
@coderkarma
Dec 11 2018 21:55
is that how we pass the props like title, body, imgURL? when we render MediaCard component in Main Index.js file?
Sorry If i am not making sense, i am still trying to sink in on react.
yayne
@yayne
Dec 11 2018 21:56
Hi, background-image shrinks when i check its responsiveness to small device. I tried different ways but i can't. Is there anyways to solve it?
Aditya
@ezioda004
Dec 11 2018 21:58
@coderkarma Yes, thats how you pass props to a component. For the same reason hope you understand why you cant use title in app.js since no props is being passed to it.
Karma Drukpa
@coderkarma
Dec 11 2018 22:10
@ezioda004 what if there would if only one props in MediaCard component
@ezioda004
const MediaCard = (props) => {
  return (
    <div>
      <h2>{props.title}</h2>
      <p>{props.body} </p>
      <img src={props.imgurl} />
    </div>
  );
};

export default MediaCard;
is that would be the way to do it ?@aditya
Aditya
@ezioda004
Dec 11 2018 22:12
@coderkarma Oh I just noticed, your previous example was wrong
({title, body, imgURL}) is same as props
You have (title, body, imgURL) which is incorrect
({title, body, imgURL}) is destructuring props you can directly use title, body etc
Otherwise with props you'll have to use props.title, props.body etc
Karma Drukpa
@coderkarma
Dec 11 2018 22:24
@ezioda004 yes sir got working now. and cleared some confusion
thank you man
@ezioda004 one more question man.
can i write ternary condition like that in component.?
Jason Luboff
@JLuboff
Dec 11 2018 22:29
Yes you can
Aditya
@ezioda004
Dec 11 2018 22:30
Yeah sure
But I think its better you call the props as props only
const isOpen = props => ...
Karma Drukpa
@coderkarma
Dec 11 2018 22:30
Make a component called Gate that accepts 1 prop called "isOpen". When isOpen is true, make the component render "open", and when isOpen is false, make it render "closed".
Aditya
@ezioda004
Dec 11 2018 22:31
Or use destructuring:
const isOpen = ({isOpen}) => ...
Karma Drukpa
@coderkarma
Dec 11 2018 22:31
that is the condition but i don't see any value for doing that
Aditya
@ezioda004
Dec 11 2018 22:31
Wrong props :)
Karma Drukpa
@coderkarma
Dec 11 2018 22:33
how ?
Aditya
@ezioda004
Dec 11 2018 22:35
The props is passing it the component as <Gate isOpen = {true} />
Your component name is wrong too.
Pagnito
@Pagnito
Dec 11 2018 22:36
anyone can help me with a share link?
Jason Luboff
@JLuboff
Dec 11 2018 22:40
@ezioda004 Take your exams today?
Aditya
@ezioda004
Dec 11 2018 22:42
@JLuboff Yee, went well. I got one today too and its 4 am already lol
Jason Luboff
@JLuboff
Dec 11 2018 22:42
Its 4 am? Why are you even awake! lol
Karma Drukpa
@coderkarma
Dec 11 2018 22:42
@ezioda004 he never sleeps.
Brad
@bradtaniguchi
Dec 11 2018 22:43
I used to stay away until 4am, then I took an arrow to the knee
Karma Drukpa
@coderkarma
Dec 11 2018 22:43
@ezioda004 isOpen is our props right and we need to make a check if isOpen is true then render open if not render closed right what is wrong here.
import React from "react";

const Gate = isOpen => {
  return <div> {isOpen ? "open" : "closed"}</div>;
};

export default Gate;
Jason Luboff
@JLuboff
Dec 11 2018 22:45
@bradtaniguchi I'm guessing this is a quote from something?
Aditya
@ezioda004
Dec 11 2018 22:45
@JLuboff Lol I fell asleep at 11pm and woke up at 2am >.>
@coderkarma Yes but you need to destructure the prop like:
const Gate = ({isOpen}) => ...
I'd suggest you to look at MDN or fcc challenges for destructuring.
Karma Drukpa
@coderkarma
Dec 11 2018 22:46
ok
Aditya
@ezioda004
Dec 11 2018 22:47
@JLuboff Its from skyrim, dont tell me you never played it. Even smart fridges can run skyrim now
Brad
@bradtaniguchi
Dec 11 2018 22:47
Hell I didn't even play skyrim, but I know of that meme haha
Aditya
@ezioda004
Dec 11 2018 22:48
Dang, its a good game to no-life
Brad
@bradtaniguchi
Dec 11 2018 22:49
Oh yea, I've had my share. But I'm retired now :P
Aditya
@ezioda004
Dec 11 2018 22:50
Haha
Karma Drukpa
@coderkarma
Dec 11 2018 22:50

const Gate = ({isOpen}) =>

<div> {isOpen ? "open" : "close"}</div>;

@ezioda004 we must have div in component to return right?
Jason Luboff
@JLuboff
Dec 11 2018 22:52
@ezioda004 Nope...never played it
Not huge into that genre of games
Christopher McCormack
@cmccormack
Dec 11 2018 22:53
div is not a requirement, it's just often used to wrap components. JSX can only parse a single element, and all the child elements are called as Children to the createElement method
Aditya
@ezioda004
Dec 11 2018 22:53
@coderkarma With React fragment, its not mandatory:
const Gate = ({isOpen}) => (<> {isOpen ? "open" : "close"}</>);
@cmccormack Someones been reading Dans blog
Christopher McCormack
@cmccormack
Dec 11 2018 22:54
@ezioda004 no way man that's the first thing you gotta learn, how JSX is parsed!
Karma Drukpa
@coderkarma
Dec 11 2018 22:54
I was doing udemy courses on react but instructor seems teaching high level stuff like fragment, provider and and reducer , i was like damnn i am not quite there yet.
I had to stop and get to the react basic
Christopher McCormack
@cmccormack
Dec 11 2018 22:54
I don't think this example is good though, just returning a string not a component
Aditya
@ezioda004
Dec 11 2018 22:55
@cmccormack No, the first thing you learn is redux and quit web dev!
Christopher McCormack
@cmccormack
Dec 11 2018 22:55
I never bothered with Redux because I knew it would slow me down if I tried to learn it right away
Is there an easy way in Node to determine where an unhandledpromiserejection is thrown? LIke the line number in your code?
Aditya
@ezioda004
Dec 11 2018 22:56
I think Redux is quite elegant compared to something like MVC, but some of the things about redux still feels magical to me
Karma Drukpa
@coderkarma
Dec 11 2018 22:57
@cmccormack yes i don't understand the purpose of that either. I render the Get component to my index.js but i don't see that doing any difference.
Christopher McCormack
@cmccormack
Dec 11 2018 22:57
@coderkarma why are you using it then?
Karma Drukpa
@coderkarma
Dec 11 2018 22:58
@ezioda004 React is taking way long for me to understand but now i am understanding it in super slow pace.
Christopher McCormack
@cmccormack
Dec 11 2018 22:58
abstracting a string toggle to function component is all well and good but but you're hard coding the actual string so not reusable
Karma Drukpa
@coderkarma
Dec 11 2018 22:58
@cmccormack That was requirement. i was doing one exercise.
Christopher McCormack
@cmccormack
Dec 11 2018 22:59
@coderkarma oh
ok carry on then :)
Aditya
@ezioda004
Dec 11 2018 22:59
@coderkarma Keep at it, you'll get through!
Jason Luboff
@JLuboff
Dec 11 2018 22:59
@cmccormack Nothing in the stack trace for the rejection?
Christopher McCormack
@cmccormack
Dec 11 2018 23:00
no stack trace
Karma Drukpa
@coderkarma
Dec 11 2018 23:00
@ezioda004 thanks @cmccormack
Christopher McCormack
@cmccormack
Dec 11 2018 23:00
just (node:38338) UnhandledPromiseRejectionWarning: #<Object>
Jason Luboff
@JLuboff
Dec 11 2018 23:01
Oh.. time for some console.logs lol
Christopher McCormack
@cmccormack
Dec 11 2018 23:01
I know I should just handle them but good to know where it's coming from if you have a lot of code
Jason Luboff
@JLuboff
Dec 11 2018 23:02
Any reason its not associated with a catch block?
Aditya
@ezioda004
Dec 11 2018 23:03
Looks like Error object have .stack property
Maybe you could use that?
Christopher McCormack
@cmccormack
Dec 11 2018 23:03
@JLuboff because I didn't yet
@ezioda004 that would require knowing where the error was coming from :)
Jason Luboff
@JLuboff
Dec 11 2018 23:04
Man...stupid Target is lieing about shipping. It still maintains my TV will be here today when the tracking number still shows that UPS hasn't picked it up lol
Aditya
@ezioda004
Dec 11 2018 23:04
Add a .catch() in all the promises?
Christopher McCormack
@cmccormack
Dec 11 2018 23:05
@ezioda004 well of course I could do that :) there's gotta be some tool out there that can give more data for when you haven't added those yet though I bet
Aditya
@ezioda004
Dec 11 2018 23:06
Hmm, maybe chrome debugger for node? Not sure if that'd help tho
Handling error not my forte :D
Christopher McCormack
@cmccormack
Dec 11 2018 23:07
hmm yeah they do have a debugger now in Chrome forgot about that
good suggestion I'll look into it thanks
Brad
@bradtaniguchi
Dec 11 2018 23:09
vscode debugger :D
Also I finally got around to learning ngrx (redux for angular). Lots of boilerplate, but hot damn I "get it now", after slogging through the alternative
DMZ
@DMZ011
Dec 11 2018 23:12
hola!
hello world!
Brad
@bradtaniguchi
Dec 11 2018 23:13
Lets just say the alternative is not the best solution to most problems :?
Jason Luboff
@JLuboff
Dec 11 2018 23:16
Yo
Christopher McCormack
@cmccormack
Dec 11 2018 23:18
@DMZ011 yo
yayne
@yayne
Dec 11 2018 23:18
Hello friends, background-image shrinks when i check its responsiveness to small device. I tried different ways but i can't. Is there anyways to solve it?
DMZ
@DMZ011
Dec 11 2018 23:18
@JLuboff @cmccormack wassup!
Christopher McCormack
@cmccormack
Dec 11 2018 23:18
@bradtaniguchi hey man, at least you don't live in a swamp like @DMZ011
DMZ
@DMZ011
Dec 11 2018 23:18
haha
what kind of swamp
Christopher McCormack
@cmccormack
Dec 11 2018 23:18
@yayne you may need to provide a codepen or similar
@DMZ011 you tell me Ogre
DMZ
@DMZ011
Dec 11 2018 23:19
:joy_cat:
I started giving up on development
:(
too many things to knw
Brad
@bradtaniguchi
Dec 11 2018 23:19
Well, then I live in a post apocalyptic future with flying battleships :P
Christopher McCormack
@cmccormack
Dec 11 2018 23:20
@DMZ011 you know who would never give you up? x
Jason Luboff
@JLuboff
Dec 11 2018 23:20
@DMZ011 Just working away
DMZ
@DMZ011
Dec 11 2018 23:20
@cmccormack who
Jason Luboff
@JLuboff
Dec 11 2018 23:20
@cmccormack ...I...I should have known better
Christopher McCormack
@cmccormack
Dec 11 2018 23:20
@JLuboff yes, yes you should
@DMZ011 don't give up, get even!
Brad
@bradtaniguchi
Dec 11 2018 23:21
Getting rick rolled doesn't work as well anymore cuse I get an ad :/
Christopher McCormack
@cmccormack
Dec 11 2018 23:21
ouch
they should let volunteers donate to make that video ad free forever
I think enough trolls (and ogres) would donate
Jason Luboff
@JLuboff
Dec 11 2018 23:23
So whens the Google drinks and stuff
...I just discovered that you can view the dev tools for the Gitter desktop app
Christopher McCormack
@cmccormack
Dec 11 2018 23:29
@JLuboff in a couple hours :D
do they include the electron tab for that?
i'm guessing you're reading the electron docs huh?
Jason Luboff
@JLuboff
Dec 11 2018 23:30
No...just happen to hit F12 when Gitter was my main window instead of my browser
Its the chrome dev tools
Christopher McCormack
@cmccormack
Dec 11 2018 23:31
neat
Jason Luboff
@JLuboff
Dec 11 2018 23:31
Indeed
Christopher McCormack
@cmccormack
Dec 11 2018 23:31
I know you can leave that in your electron app as a dropdown option on the file navigator bar
whatever that is called
DMZ
@DMZ011
Dec 11 2018 23:32
menu? :P
Brad
@bradtaniguchi
Dec 11 2018 23:33
Its interesting, my OS shows nwjs icons when I get desktop noticiations for gitter... Is it really electron?
Christopher McCormack
@cmccormack
Dec 11 2018 23:34
I am just assuming since the chrome dev tools appeared
Jason Luboff
@JLuboff
Dec 11 2018 23:36
I'm pretty sure Gitter is built with Electron
Pagnito
@Pagnito
Dec 11 2018 23:36
damn i didnt think adding share links would be such a pain in the ass
Christopher McCormack
@cmccormack
Dec 11 2018 23:37
@Pagnito what is a share link
I mean... I know what it is but just for everyone else's benefit....
Pagnito
@Pagnito
Dec 11 2018 23:38
im not sure what u mean
Jason Luboff
@JLuboff
Dec 11 2018 23:40
HAHAHAHA HEY GUYS @cmccormack DOESN'T KNOW WHAT A SHARE LINK IS!!
But just so he knows, why don't you explain what it is
Christopher McCormack
@cmccormack
Dec 11 2018 23:41
/flee
DMZ
@DMZ011
Dec 11 2018 23:41
:joy_cat: so seriously.. what's a share link?
:P
Pagnito
@Pagnito
Dec 11 2018 23:42
u know how u can create like an image on istagram or see a post on facebook, and share that on some other platfrom
its done thru a share link
Brad
@bradtaniguchi
Dec 11 2018 23:43
One of those formatted, shortened likes right
Pagnito
@Pagnito
Dec 11 2018 23:44
im not sure, but its not rly a like, its like the thing we did in FCC quote generator
we had to create a share link to be able to share a quote
but i want to be able to share media
and have it show up on the feed of set platform properly
Christopher McCormack
@cmccormack
Dec 11 2018 23:45
that would be an embed code right?
the quote generator was an intent, which I believe is a bit different
but I also have no idea what I'm talking about
Pagnito
@Pagnito
Dec 11 2018 23:48
yea i cant remember exactly
but the idea is the same
facebook have their own share button
but its not customizable and its ugly
Christopher McCormack
@cmccormack
Dec 11 2018 23:51
ah yeah that does sound like it can get funky
Pagnito
@Pagnito
Dec 11 2018 23:52
yea, ive thought this would b like a half hour thing, its been like 4 hours
Brad
@bradtaniguchi
Dec 11 2018 23:53
Youd have to look into the docs for the platform. I think when you "share" something from your site/app on facebook you provide a link. That link goes to the page and gets some meta-data that is used by the platform.
When I say "that link goes to the page" I mean the platform goes out and gets all the nice meta data from the url specified