These are chat archives for FreeCodeCamp/HelpJavaScript

29th
Jun 2018
Tom
@moT01
Jun 29 2018 00:27
what are you guys doing/playing? @cmccormack
Christopher McCormack
@cmccormack
Jun 29 2018 00:32
Codefights
just going through the exercises @moT01
Currently stuck on level-3 reverseParenthesis
Tom
@moT01
Jun 29 2018 00:42
oh yea - what do you have to do
Christopher McCormack
@cmccormack
Jun 29 2018 00:43
You get a string like "a(bcdefghijkl(mno)p)q" and you have to reverse whatever is in parens, from the inside out
I had it just fine when I thought it was all nested, then I ran into "abc(cba)ab(bac)c" and realized I'd need to do more work :D @moT01
Tom
@moT01
Jun 29 2018 00:44
ahh
so like mno would be reversed - then unreversed when you reverse the outer group
Christopher McCormack
@cmccormack
Jun 29 2018 00:46
yeah
Tom
@moT01
Jun 29 2018 00:47
i made an account over there a while back, never used it - is that part of the arcade area?
Christopher McCormack
@cmccormack
Jun 29 2018 00:47
you done codefights? shouldn't take long to get to this one
yeah arcade>intro number 13 I think
Tom
@moT01
Jun 29 2018 02:20
@cmccormack "codefights" is a little misleading - I thought it was going to more of a fight or race - that would be pretty cool to see - a race to see who can solve it faster
Christopher McCormack
@cmccormack
Jun 29 2018 02:21
There is races
Tom
@moT01
Jun 29 2018 02:21
where
Christopher McCormack
@cmccormack
Jun 29 2018 02:21
That's why I didn't like it at first, didn't want to feel pressured
I'm not sure @tiagocorreiaalmeida always posted them
I think it was codefights
It appears to show other people and their progress maybe that's like a race as well
Tom
@moT01
Jun 29 2018 02:22
that seems more of just a status
Christopher McCormack
@cmccormack
Jun 29 2018 02:27
Might be the challenges you can unlock
oh and the Tournements
Nate Mallison
@NJM8
Jun 29 2018 02:34
How can I push a value to a mongo array only if it doesn't exist in the array already
have to do manually?
Tom
@moT01
Jun 29 2018 02:35
if(doesnt exist) {
 array.push(value);
}
Nate Mallison
@NJM8
Jun 29 2018 02:37
:smile:
with Mongoose
have to use findAndUpdate and $addToSet
not $push
Jeff
@jargonfilter
Jun 29 2018 04:36
anyone else feel like the ES6 section lacks in clarity a little?
got to "ES6: Use Destructuring Assignment to Pass an Object as a Function's Parameters" and I'm really not clear on why the functions are structured the way they are. and because of that it took a while to figure out where the {min, max} destructuring code was supposed to go.
i don't understand how am i supposed to use destructuring method
Adish Jain
@Adishjain58
Jun 29 2018 07:22

function getLength(str) {
"use strict";

// change code below this line
const length = {len:str.length}; // change this
let{len}=length;
// change code above this line

return len; // you must assign length to len in line

}

console.log(getLength('FreeCodeCamp'));

what is the problem?
Stephen James
@sjames1958gm
Jun 29 2018 07:36
@Adishjain58 you need to use the following pattern
const { propertyName: variableName } = object;
@Adishjain58 In this case the propertyName is length, the variable name is len and the object is str
abraham anak agung
@padunk
Jun 29 2018 09:02
Hi all, how is this code work? const compose = (...functions) => x => functions.reduceRight((g, f) => f(g), x);
Did anyone really use this compose function in work?
Blauelf
@Blauelf
Jun 29 2018 09:28
Some people who do functional programming like it. In my opinion, those might be the ones that consider Haskell code "porn" (in the same sense as in cable porn, which is usually SFW) and eat Y combinators for breakfast. Underscore has an implementation of compose. They wouldn't if it wasn't used at all.
Claudio Restifo
@Marmiz
Jun 29 2018 09:36
A lot of modern library came with their own compose function in it as utility to help you . So yeah, it's widely used in working application as well
alpox
@alpox
Jun 29 2018 10:43
@padunk I use it at times
@padunk How it works is that it takes the functions from right to left and wraps them into each other to basically do:
const result = function1(function2(function3(function4(x))))
const functionToApply = compose(function1, function2, function3, function4);
const result = functionToApply(x);
Just reads nicer and you can create a new function out of multiple others with compose
Blauelf
@Blauelf
Jun 29 2018 11:48
@alpox How often do you have functions that chain that nicely? Do you design them that way, or are those library functions?
alpox
@alpox
Jun 29 2018 11:55
@Blauelf Not often. I design functions to work with chaining only if I see that they fit and its the most convenient way for me and/or the user of the code
I sometime made a validation library that worked well for me in the specific case of redux-form validations: https://www.npmjs.com/package/validation-msgs
Here I use my own way of function composition
To be fair, its not really chaining here either :D, just a similar use of the function pattern
Nate Mallison
@NJM8
Jun 29 2018 14:53
Who wants to help me with some cors issues, aren't they fun
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://natethedev-nightlifeappbackend.herokuapp.com/signup. (Reason: CORS header ‘Access-Control-Allow-Origin’ does not match ‘https://natethedev-nightlifeappfront.herokuapp.com/’).
app.use(cors({
  origin: app.get('env') === 'development' ? 'http://localhost:8080' : 'https://natethedev-nightlifeappfront.herokuapp.com/'
}))
alpox
@alpox
Jun 29 2018 15:04
@NJM8 What does the response header show?
Nate Mallison
@NJM8
Jun 29 2018 15:06
Screen Shot 2018-06-29 at 11.06.05 AM.png
thats just the options request, of course
Jason Luboff
@JLuboff
Jun 29 2018 15:09
Morning
Nate Mallison
@NJM8
Jun 29 2018 15:09
morning
alpox
@alpox
Jun 29 2018 15:10
Looks alright to me >.<
Nate Mallison
@NJM8
Jun 29 2018 15:10
I wish mongo cli queries didn't fail silently on incorrect case
db.Users vs db.users
even wrapped in a try catch print(e), no love
@alpox that's what I thought.
Is there a way to see your code on Heroku? like a file browser?
alpox
@alpox
Jun 29 2018 15:12
ssh
Jason Luboff
@JLuboff
Jun 29 2018 15:12
@alpox I'm almost done (finally) with that project that you had helped me with a while back (you helped me with my promises)
Nate Mallison
@NJM8
Jun 29 2018 15:16
huh. well my files on heroku are correct. wth
alpox
@alpox
Jun 29 2018 15:18
@JLuboff Hmm I do remember slightly :D
Nice! What is it for? :)
@NJM8 Can you try to remove the /at the end of the origin?
Also, sometimes characters can go weird, there are two different kinds of -(charcodes) in different charsets. Go sure its the right one :D
Jason Luboff
@JLuboff
Jun 29 2018 15:19
@alpox It's a web app for creating a MOC (Management of Change) request. Essentially allows anyone to make a request, then it goes through approvers, then action items to complete, then a final approval. All database stuff is handled via SQL (hence where the promises came in).
alpox
@alpox
Jun 29 2018 15:20
@JLuboff Sounds nice :) Did you do it for fun or for a specific usecase?
Jason Luboff
@JLuboff
Jun 29 2018 15:21
For work! It'll be my first production NodeJS app. (Well.. sort of.. I made some conference room signs, but they're fairly simplistic).
I think I have a fairly decent app structure and error handling, etc. So hopefully it'll run well
alpox
@alpox
Jun 29 2018 15:23
@JLuboff And you coult work on it alone? :D
I'm happy for you :) I don't have an app in production yet :/
Jason Luboff
@JLuboff
Jun 29 2018 15:24
I'm the only programmer. The old programmer/DBA is pretty much retired.. I'm taking over that position.
alpox
@alpox
Jun 29 2018 15:24
Aha alright :D so the only programmer in the house?
Nate Mallison
@NJM8
Jun 29 2018 15:25
@alpox nice catch, I think that is it. My other app doesn't have the slash. Testing now
Jason Luboff
@JLuboff
Jun 29 2018 15:25
Yup. Which is good and bad... lol
I'm all self-taught so I don't necessarily always know the best practices, etc
alpox
@alpox
Jun 29 2018 15:25
@JLuboff You can make your own best practices :D
Jason Luboff
@JLuboff
Jun 29 2018 15:26
Lol true
Nate Mallison
@NJM8
Jun 29 2018 15:26
don't forget to make backups
db.Iarenewprogrammer.drop().confirm('whoops')
haha
Christopher McCormack
@cmccormack
Jun 29 2018 15:27
is there such a thing as a frontup?
Nate Mallison
@NJM8
Jun 29 2018 15:27
context?
Jason Luboff
@JLuboff
Jun 29 2018 15:27
I have last I checked ~160 git commits both locally and remotely, my working folder (and thus local repo) is on network storage which is backed up daily, and the server is backed up daily (with the database being backed up daily, and transaction logs backed up hourly)
Christopher McCormack
@cmccormack
Jun 29 2018 15:27
context for frontup? You'll have to think about that one haha
Nate Mallison
@NJM8
Jun 29 2018 15:28
@JLuboff Gotta get those commits up. I commit each character and demand payment by commit volume
Jason Luboff
@JLuboff
Jun 29 2018 15:28
:joy:
Christopher McCormack
@cmccormack
Jun 29 2018 15:29
add/commit delete/commit => profit
Nate Mallison
@NJM8
Jun 29 2018 15:29
front up. verb informal. (tr) to pay (money) at the beginning of a business arrangement. to give one's best effort, esp in a physical contestwe have to front up in the scrum if we want to beat the All Blacks.
Christopher McCormack
@cmccormack
Jun 29 2018 15:29
not front up, frontup
like backup but frontup
Nate Mallison
@NJM8
Jun 29 2018 15:30
if you create a time machine
Christopher McCormack
@cmccormack
Jun 29 2018 15:30
haha
maybe everything that isn't a backup should be called a frontup
Nate Mallison
@NJM8
Jun 29 2018 15:31
just finished my nightlife coordination app, any feedback appreciated! https://natethedev-nightlifeappfront.herokuapp.com/home
it's a little rough around the edges, I'm not a fan of the UI. But I wanted to get it done ish functionally and leave the polishing for later
Christopher McCormack
@cmccormack
Jun 29 2018 15:33
@NJM8 looks awesome so far!
Not sure why there is an OK when loading though? Is that just to dismiss?
Any area I can test other check ins?
Doesn't seem to be responsive design either :p
I like the previous search option
Nate Mallison
@NJM8
Jun 29 2018 15:35
yeah no responsive. aint no body got time for that
you can click the ok to dismiss although it goes away on it's on. just thought it would be bad to not have the button
i am checked in somewhere in ithaca NY
Christopher McCormack
@cmccormack
Jun 29 2018 15:37
Actually learning flexbox I was able to get mine responsive really easily - just swap row for column, maybe some subelements column for row, whatever, it's pretty nice
Hw do you check out?
No favicon!
Nate Mallison
@NJM8
Jun 29 2018 15:37
although you might not find me, I pulled the saved location from the closest bar found to your search finds, so if you search for that actual location it may give different results than your latlng when doing find me
should use opencage data to get the city name from your latlng first
but don't have time
yeah responsive isn't hard with flex, I just need to get to some other work
oh yeah. checkout. haha
Christopher McCormack
@cmccormack
Jun 29 2018 15:39
You can use my favicon if you want, I drew it myself in paint :) . https://meetuptonight.mackville.net/images/favicon.ico
Nate Mallison
@NJM8
Jun 29 2018 15:39
it checks you out when you check in somewhere else. guess I forgot about checking out entirely
thanks, I'm used to all my front end apps that pull it from my root github pages repo
Christopher McCormack
@cmccormack
Jun 29 2018 15:40
I like the welcome back message
Nate Mallison
@NJM8
Jun 29 2018 15:40
ahh yes, ms paint
thanks. JWT FTW
Christopher McCormack
@cmccormack
Jun 29 2018 15:40
Find it easy enough to use?
Nate Mallison
@NJM8
Jun 29 2018 15:40
yes
Christopher McCormack
@cmccormack
Jun 29 2018 15:41
I stuck with express-session as I already knew how to use it but I may try JWT next time
Nate Mallison
@NJM8
Jun 29 2018 15:41
once you get used to the idea that the token is everything that's all you need
you can pull last login time and username from it so it's all you store in local storage, it's encrypted so no one else can do anything with it
so if you come back to my app in 25 hours it'll recognize you but ask you to login again to refresh token
Christopher McCormack
@cmccormack
Jun 29 2018 15:43
Yeah it's pretty cool - when I didn't understand sessions at all I was looking at it but there weren't many good examples compared to express-session
probably a few more now, this was mid last year
Nate Mallison
@NJM8
Jun 29 2018 15:44
I think if someone were even sniff all your network requests and get your password on login it's useless as they can't get the username from the JWT
although username is usually easier to guess
Christopher McCormack
@cmccormack
Jun 29 2018 15:44
with https they shouldn't get it then either
Nate Mallison
@NJM8
Jun 29 2018 15:45
yup
Christopher McCormack
@cmccormack
Jun 29 2018 15:47
that site has a horrible blocking modal
Jason Luboff
@JLuboff
Jun 29 2018 15:51
@NJM8 Checking it out now.. one thing.. why does the "You must log..." modal disappear before I hit Ok?
Actually seems like all modals do that
disappear before I can even finish reading some
It'd be nice if I could "uncheck" myself out
Christopher McCormack
@cmccormack
Jun 29 2018 15:52
@JLuboff no, you have to go now
Jason Luboff
@JLuboff
Jun 29 2018 15:53
NO!
Christopher McCormack
@cmccormack
Jun 29 2018 15:54
@JLuboff single handedly boosts the income of businesses in his area because he could not back out of obligations he accidentally made, news @11
Jason Luboff
@JLuboff
Jun 29 2018 15:55
Har har har
Jason Luboff
@JLuboff
Jun 29 2018 16:04
I hate checkboxes. That is all.
Nate Mallison
@NJM8
Jun 29 2018 16:04
@cmccormack Other's have said that but their content is fantastic. worth it to give them your email or whatever then unsubscribe
@JLuboff Yeah I guess the modal timer is fast. you think I should remove the button? I was undecided between slow/fast, button/no button
Jason Luboff
@JLuboff
Jun 29 2018 16:05
I would have no timer with a button, but thats me personally.
Nate Mallison
@NJM8
Jun 29 2018 16:05
personally I'm always at the bar. why check out
just going to be there in 12 hours again
just kidding
Jason Luboff
@JLuboff
Jun 29 2018 16:06
Eh... never been much of a bar person myself. Not a big drinker
Christopher McCormack
@cmccormack
Jun 29 2018 16:06
I would suggest getting rid of the button but having a timeout for the data - if it times out, display an error message like "Issue loading data, we'll continue to try in the background" then display it if it does come in
Nate Mallison
@NJM8
Jun 29 2018 16:07
meh neither. Some friends always bragging about drinking $75 worth of liquor to get smashed and I'm thinking yeah, I had two beers and I'm $60 richer than you. haha
Jason Luboff
@JLuboff
Jun 29 2018 16:09
Bar's are always so loud and crowded lol tough to talk with people
Nate Mallison
@NJM8
Jun 29 2018 16:16
We have a new awesome bar that serves fancy drinks but nothing crazy, and they don't play super loud music, and only allow like, 45 people in or something. Definitely a "I'm in my mid-30's and want a nice time out but hate college kids" bar
Kudzu
@czhower
Jun 29 2018 16:17
Sounds more like a lounge than a bar. These types are really common in Europe but somehow died out in the US in the 70s largely.
Christopher McCormack
@cmccormack
Jun 29 2018 16:19
We have lots of lounges in dense areas in the US
but almost none in the suburban areas
My guess is people don't want to drive to a lounge, but group up to go to large bars
Kudzu
@czhower
Jun 29 2018 16:20
Ive been out of the US nearly 20 years now, but compared to the EU I found them to be far and few between.
Jason Luboff
@JLuboff
Jun 29 2018 16:23
sigh... so much for being almost done with this project..
alpox
@alpox
Jun 29 2018 16:23
@JLuboff huh?
Jason Luboff
@JLuboff
Jun 29 2018 16:23
They keep adding shit on lol
To give you reference.. had what was supposed to be final review yesterday. The day before they came back with "Oh...we just actually read the requirements we need (from the agency) and we need this" ok, simple inclusion fine. Yesterday they added one more thing to that (not a big one). Now they've gone and talked with someone else in the company and making sound like there's going to need to be potentially a much different solution for that person./
It's my Welcome to Programming I guess :joy:
Nate Mallison
@NJM8
Jun 29 2018 16:25
as long as they understand it's not you
Jason Luboff
@JLuboff
Jun 29 2018 16:26
oh absolutely, they're the ones that are doing that
alpox
@alpox
Jun 29 2018 16:26
@JLuboff Absolutely. Welcome to programming :D
You wouldn't believe how many times you will program something just to throw it away in the next sprint or two
And how many new things they start to imagine
Jason Luboff
@JLuboff
Jun 29 2018 16:28
Ya.. frustrating but it is what it is, just gotta keep moving on.
Nate Mallison
@NJM8
Jun 29 2018 16:29
It's not much different else-ware. In my last job my boss ruined a project I oversaw because he refused to listen to me when I said I need X piece of equipment to make Y product because it was "too expensive" . So he outsourced the work to another place with X and spent 5 times as much over the course of 6 months.
Jason Luboff
@JLuboff
Jun 29 2018 16:30
Sounds about right
Nate Mallison
@NJM8
Jun 29 2018 16:30
And lost a potential contract for $5.25 million over 5 years. X costs $100k
I put in my notice 3 months later. When he asked if there was anything they could've done differently to keep me I said "You should've purchased the CMM" hahaha
I may or may not still be sore about it, lol
Jason Luboff
@JLuboff
Jun 29 2018 16:32
As an IT department with no budget...we have trouble at times getting things approved that we need. So I totally get that lol
Nate Mallison
@NJM8
Jun 29 2018 16:33
@cmccormack @JLuboff check out button implemented
Christopher McCormack
@cmccormack
Jun 29 2018 16:33
don't make us scroll now
Jason Luboff
@JLuboff
Jun 29 2018 16:33
Even though we had made recomendations for network connectivity redundance at certain locations....we didn't get such until we had an outage that cost if I remember correctly ~$1m
Nate Mallison
@NJM8
Jun 29 2018 16:34
yeah, I didn't get it. The machine was $1000/month on lease and he proceeded to pay someone else to do the work for $8750, and I could barely use what they had done. ugh
@JLuboff ouch
that seems like a lot for a company with one programmer
And I got rid of the modal timeout, just easier for now
Jason Luboff
@JLuboff
Jun 29 2018 16:35
We're an Oil company...so if production gets shut down...
Nate Mallison
@NJM8
Jun 29 2018 16:35
oh
then that's not very much
Jason Luboff
@JLuboff
Jun 29 2018 16:35
We're a small oil company...so it is still a lot lol
Christopher McCormack
@cmccormack
Jun 29 2018 16:37
@NJM8 shouldn't modal just go away when the bars are rendered?
Nate Mallison
@NJM8
Jun 29 2018 17:09
oh, yeah. that would be nice
The same modal is used for all the messages, I didn't make it very flexable
Christopher McCormack
@cmccormack
Jun 29 2018 17:10
You used vue? Can you pass some state when your fetch resolves to hide the modal?
Nate Mallison
@NJM8
Jun 29 2018 17:11
already done. :smile:
Christopher McCormack
@cmccormack
Jun 29 2018 17:12
oh cool
Nate Mallison
@NJM8
Jun 29 2018 17:14
bah. I should rewrite the modal animation so it fires after the data is removed. now the text disappears then the modal
Christopher McCormack
@cmccormack
Jun 29 2018 17:21
I experienced that on first tests as well, text disappearing early
Jason Luboff
@JLuboff
Jun 29 2018 17:25
damn & in my url requiring encoding
Christopher McCormack
@cmccormack
Jun 29 2018 17:32
@JLuboff always encode?
Jason Luboff
@JLuboff
Jun 29 2018 17:33
@cmccormack Que?
Ronique Ricketts
@RoniqueRicketts
Jun 29 2018 17:33
Hello one and all.
Christopher McCormack
@cmccormack
Jun 29 2018 17:33
@JLuboff always encode your urls so you never have to worry about it?
@RoniqueRicketts hey man how's it going?
Jason Luboff
@JLuboff
Jun 29 2018 17:34
@cmccormack Eh.. I had encoded the portion that I needed to.
@RoniqueRicketts Yo
Christopher McCormack
@cmccormack
Jun 29 2018 17:34
mhmm
Ronique Ricketts
@RoniqueRicketts
Jun 29 2018 17:34
@cmccormack I am good. Just here on the slave. I haven't been on here in a long time
@JLuboff whats up bruv?
Jason Luboff
@JLuboff
Jun 29 2018 17:35
Same ol' same ol
Christopher McCormack
@cmccormack
Jun 29 2018 17:37
A lot has changed, now @JLuboff owns Microsoft
or something like that
Jason Luboff
@JLuboff
Jun 29 2018 17:37
:joy:
I am getting close to going to taking my first of two SQL exams..
I got the exam voucher...with 2 potential retakes haha
Christopher McCormack
@cmccormack
Jun 29 2018 17:37
@JLuboff Maybe one day you'll be one of those fancy Microsoft Fellows
@JLuboff good luck on the exam though, let us know how difficult it is
@RoniqueRicketts you still coding in your free time?
Jason Luboff
@JLuboff
Jun 29 2018 17:39
Thanks.. I haven't scheduled it yet but... been studying alot
Ronique Ricketts
@RoniqueRicketts
Jun 29 2018 17:40
@cmccormack Yeah I do. But not much
Christopher McCormack
@cmccormack
Jun 29 2018 17:44
Some of us have been doing codefights recently if you want to find us on there
Ronique Ricketts
@RoniqueRicketts
Jun 29 2018 17:48
I can't fight my coding skills still young
Christopher McCormack
@cmccormack
Jun 29 2018 17:49
They aren't bad if you're doing the arcade, good ramp up and some tough ones interspersed
Ronique Ricketts
@RoniqueRicketts
Jun 29 2018 17:50
ill code watch hehe. Can I just cheer from the sidelines in the arena
Christopher McCormack
@cmccormack
Jun 29 2018 17:50
Maybe?
Ronique Ricketts
@RoniqueRicketts
Jun 29 2018 17:50
lol :)
Christopher McCormack
@cmccormack
Jun 29 2018 17:50
haha
Ronique Ricketts
@RoniqueRicketts
Jun 29 2018 17:50
gonna go arcade on code fight
Christopher McCormack
@cmccormack
Jun 29 2018 17:50
That would be cool, especially if you could get a notice when someone finishes one you did and you can see their code
do it!
Ronique Ricketts
@RoniqueRicketts
Jun 29 2018 17:51
let me log in :)
Christopher McCormack
@cmccormack
Jun 29 2018 17:52
I think I was able to knock out 15 of them yesterday, only two were somewhat difficult
Ronique Ricketts
@RoniqueRicketts
Jun 29 2018 17:53
your a good programmer so your can do these things with ease
BTW, I am so behind on chingu cohort
Christopher McCormack
@cmccormack
Jun 29 2018 17:53
Oh I forgot about Chingu
it's one of those words that I can never remember
I'm not a good programmer, just been doing algorithm challenges for a long time
I hope to one day be a good programmer though
Ronique Ricketts
@RoniqueRicketts
Jun 29 2018 17:55
Bruv u are. If I say your a good programmer then you are.
Christopher McCormack
@cmccormack
Jun 29 2018 17:55
Thanks man I appreciate it :D
Ronique Ricketts
@RoniqueRicketts
Jun 29 2018 17:55
Your welcome :)
Christopher McCormack
@cmccormack
Jun 29 2018 17:56
I wish I could code today, instead I have to move data back and forth between spreadsheets, which cannot be automated :(
Ronique Ricketts
@RoniqueRicketts
Jun 29 2018 17:56
damn bruv, I wish you fast copy and paste. :)
Christopher McCormack
@cmccormack
Jun 29 2018 17:57
hah thanks
thought I could take the day off as I have an all day change tomorrow but no luck
I don't even understand this
I have to go shopping for clothes tomorrow
Christopher McCormack
@cmccormack
Jun 29 2018 17:58
that sounds... fun?
I just have random clothes sent to me every few months
Ronique Ricketts
@RoniqueRicketts
Jun 29 2018 17:59
Not for me. I am the spender :'(
lol
Christopher McCormack
@cmccormack
Jun 29 2018 18:00
@RoniqueRicketts basically iterate over the array length -2 and store the product of array[i]*array[i+1] in a max, and update max if a bigger product is found
Jason Luboff
@JLuboff
Jun 29 2018 18:00
@cmccormack random cloths sent to you? You have one of those subsription boxes?
Christopher McCormack
@cmccormack
Jun 29 2018 18:00
There are quite a few exercises with the same basic premise
@JLuboff yeah Stitchfix and sometimes Trunk Club but Trunk Club is pretty expensive
I love the serendipity though - I often find stuff I would never pick at a normal store that I end up loving
Markus Kiili
@Masd925
Jun 29 2018 18:02
Evening.
Christopher McCormack
@cmccormack
Jun 29 2018 18:02
@Masd925 heya
@JLuboff you on codefights with jluboff?
Jason Luboff
@JLuboff
Jun 29 2018 18:05
@cmccormack Ya I am
I haven't tried any of the subscription boxes. I know what I like. Usually JCrew or Bonobos (albeit expensive so rarely get stuff). Used to like Banana republic more but... haven't cared for much of their stuff recently)
Christopher McCormack
@cmccormack
Jun 29 2018 18:06
I love Banana for work clothes, but they keep closing shops so I can't get there as much now. Their crew tshirts are the best though
Their traveler's pant is pretty great too
Jason Luboff
@JLuboff
Jun 29 2018 18:09
I've heard great things about their travelers and the newish pants that I'm forgetting the name of right now
But ya they're closing up around here too. Kind of sucks
The one near us that closed wasn't all that great though anyways. Had limited Slim fit shirts (casual) which is mainly what I look for
Christopher McCormack
@cmccormack
Jun 29 2018 18:11
Wish I knew what else was good out there but I HATE going to the store to shop for clothes
Once you find a place you like you don't want to go anywhere else
Jason Luboff
@JLuboff
Jun 29 2018 18:14
@cmccormack J.Crew is really my go to now. Quality is good. Price is decent as long as you wait for sales (40% off every couple months). Bonobos is really nice since they have a ton of different fits but expensive
Christopher McCormack
@cmccormack
Jun 29 2018 18:15
@JLuboff J.Crew got into trouble for trying to sell lower quality stuff for their normal prices, did they finally fix all that?
Jason Luboff
@JLuboff
Jun 29 2018 18:17
Their factory stores are known to mess with the prices, I stick with the mainline stuff. But they just started selling the factory stuff in mainline stores which sucks but just don't get anything thats 'Mercantile' unless it's a decent price
Christopher McCormack
@cmccormack
Jun 29 2018 18:18
Man I hate when they try to pass off the cheap stuff at normal price instead of just coming clean and stating the normal stuff is a higher price
Applies to everything, especially food
Jason Luboff
@JLuboff
Jun 29 2018 18:19
Ya it's sketchy
Markus Kiili
@Masd925
Jun 29 2018 18:29
I got the new job. Wife is very happy.
Ronique Ricketts
@RoniqueRicketts
Jun 29 2018 18:29
@Masd925 congrats
can't ya'll hook me up on one of those jobs
Jason Luboff
@JLuboff
Jun 29 2018 18:30
@Masd925 The one worked out? Congrats!
Markus Kiili
@Masd925
Jun 29 2018 18:30
@JLuboff Yeah. Lazy me.
Christopher McCormack
@cmccormack
Jun 29 2018 18:31
@RoniqueRicketts move to the mainland states plenty of jobs out here
@Masd925 congrats!
Markus Kiili
@Masd925
Jun 29 2018 18:31
Thanks.
Jeff
@jargonfilter
Jun 29 2018 18:34
could someone explain to me whats going on in ES6: Use Destructuring Assignment to Pass an Object as a Function's Parameters
specifically why the functions are structured the way they are
Ronique Ricketts
@RoniqueRicketts
Jun 29 2018 18:34
@cmccormack I wish I could, its hard to get document to travel :')
:'(
Jeff
@jargonfilter
Jun 29 2018 18:35
this is the code that works for it:
const stats = {
  max: 56.78,
  standard_deviation: 4.34,
  median: 34.54,
  mode: 23.87,
  min: -0.75,
  average: 35.85
};
const half = (function() {
  "use strict"; // do not change this line

  // change code below this line
  return function half({max,min}) {
    // use function argument destructuring
    return (max + min) / 2.0;
  };
  // change code above this line

})();
Christopher McCormack
@cmccormack
Jun 29 2018 18:36
@jargonfilter which part, are you concerned with?
Jeff
@jargonfilter
Jun 29 2018 18:37

a few things i dont understand.

why is half a const?

why are there so many nested functions? can't we just do:

const half = ({max, min}) => {
    return (max + min) / 2.0
}
Christopher McCormack
@cmccormack
Jun 29 2018 18:37
@jargonfilter half is assign an immediatly invoked function expression which will run immediatly and return an internal function, so half will end up being a reference to that internal function
You use const whenever you can to prevent side effects, changing a variable in place that something else may depend on
you cannot assign a variable after declaring it as a const, although if you assign an object or array to a const you can still update those objects as the const is just a reference to that object
Markus Kiili
@Masd925
Jun 29 2018 18:39
@jargonfilter I don't see the benefit of using that IIFE, so maybe it is just for learning purposes.
Christopher McCormack
@cmccormack
Jun 29 2018 18:39
@jargonfilter you could do that, but you may use something similar to the example if there was any state within the outer function that the inner function had access to
I agree I'm not sure why an iife is used here
But if you had another function with some state that returned a function, that would be more useful
Jeff
@jargonfilter
Jun 29 2018 18:40

ok so const works here because its an object. if i tried this same thing with a var it would fail since const can't update?

as far as teh immediately invoked function goes, can i not do the same thing with the shorter code i provided and just turn that into an immediately invoked function?

Christopher McCormack
@cmccormack
Jun 29 2018 18:40
that returned function would still have access to that state
@jargonfilter no var would work too
but we shouldn't use var anymore
Jeff
@jargonfilter
Jun 29 2018 18:41
sorry i meant a regular variable plugged into const i shouldnt have said "var"
Christopher McCormack
@cmccormack
Jun 29 2018 18:41
use let when you may change the assignment, const any other time
Jeff
@jargonfilter
Jun 29 2018 18:41
right
Christopher McCormack
@cmccormack
Jun 29 2018 18:41
with const you can never reassign
that's the benefit
Jeff
@jargonfilter
Jun 29 2018 18:41
except if its an object?
Christopher McCormack
@cmccormack
Jun 29 2018 18:42
no it will still only ever reference the object
but the object can be modified
you can never do
const obj = {};
obj = [];
Jeff
@jargonfilter
Jun 29 2018 18:42
ok, i guess its only passing the values through its not really changing the actual expression.
Christopher McCormack
@cmccormack
Jun 29 2018 18:42
but you can do
const obj = {};
obj.a = 1;
// { a: 1 }
Jeff
@jargonfilter
Jun 29 2018 18:42
ah right
i see
ok, so is it still necessary to nest all those functions?

could i not turn this

const half = ({max, min}) => {
    return (max + min) / 2.0
}

into an immediately invoked function some how?

Christopher McCormack
@cmccormack
Jun 29 2018 18:44
I think they did this because if you added the function globally it would first bind to the global object via hoisting
Is there an explanation on the side maybe?
i guess my understanding of hoisting was wrong. i thought the only functions that get hoisted were function declarations
but even then, why is that a problem in this case?

i'm also a little puzzled by this:

return function half({max,min})

it seems kind of weird to return the function that references itself. wouldn't that cause it to loop over and over?

Christopher McCormack
@cmccormack
Jun 29 2018 18:48
again I'm not sure why they used an iife
it works every way I tested it

ah no it doesn't

const half = function ({max, min}) {
    "use strict"; // do not change this line
  return (max + min) / 2.0;
}

SyntaxError: Non-simple parameter in strict mode (22:23)

I guess for strict mode maybe?
@jargonfilter function half is just a decorative name, it has no meaning in this context
you could remove half and it would work the same
Jeff
@jargonfilter
Jun 29 2018 18:50
why put it there at all then
Christopher McCormack
@cmccormack
Jun 29 2018 18:50
why indeed
Jeff
@jargonfilter
Jun 29 2018 18:50
this has been the most confusing lesson in FCC for me so far lol
Christopher McCormack
@cmccormack
Jun 29 2018 18:51
These are great questions, maybe open an issue requesting more explanation
Jeff
@jargonfilter
Jun 29 2018 18:51
ok. thanks, i thought i was going crazy
Christopher McCormack
@cmccormack
Jun 29 2018 18:51
I'm assuming they did not cover this in previous lessons though
I didn't run through the ES6 stuff yet
Jeff
@jargonfilter
Jun 29 2018 18:51
they cover destructuring in previous lessons but there wasnt anything leading up to the IIFE structure they used here
Markus Kiili
@Masd925
Jun 29 2018 18:52
And why in earth do they name it half too?
Jeff
@jargonfilter
Jun 29 2018 18:52
i had done a lot of the early JS stuff in the previous version of the site and came back to find everything changed so ive been going through ES6 stuff and i have to say the es6 stuff to me was not very clear.
Christopher McCormack
@cmccormack
Jun 29 2018 18:53
@Masd925 probably so we can link the two, that the half function reference is what is returned and stored in half - but I'd agree that's just more confusing
Jeff
@jargonfilter
Jun 29 2018 18:53
i'm pretty new with coding and JS. a lot of the previous lessons i was able to get through eventually but some of the simple ES6 things were kind of confusing due to the left side instructions.
Christopher McCormack
@cmccormack
Jun 29 2018 18:53
@jargonfilter You may be better off looking for some ES6 articles on medium or other sites, I remember when I first learned about ES6 diving into whatever I could find
Jeff
@jargonfilter
Jun 29 2018 18:54
good idea.
Jeff
@jargonfilter
Jun 29 2018 18:59
@cmccormack thanks for your help btw
Christopher McCormack
@cmccormack
Jun 29 2018 19:08
np
koder3
@koder3
Jun 29 2018 19:08
Hey guys
Christopher McCormack
@cmccormack
Jun 29 2018 19:08
@koder3 hi!
koder3
@koder3
Jun 29 2018 19:09
@cmccormack How you doing man
Christopher McCormack
@cmccormack
Jun 29 2018 19:09
Great trying to finish up some work so I can end early for the weekend
you?
koder3
@koder3
Jun 29 2018 19:10
Not so good haha. Stuck with trying to understand how bind() works.
Have read countless articles and videos but nothing doing xd
Christopher McCormack
@cmccormack
Jun 29 2018 19:11
@koder3 oh that's a fun one
koder3
@koder3
Jun 29 2018 19:11
100%
Christopher McCormack
@cmccormack
Jun 29 2018 19:11
I just read a good article the other day on it but I'd have to find it
koder3
@koder3
Jun 29 2018 19:11
"this" was another reason people hated javascript i can see why lmao
Christopher McCormack
@cmccormack
Jun 29 2018 19:12
Yeah I bet most people who understand it probably still do it wrong but know what the error is when they see it :)
koder3
@koder3
Jun 29 2018 19:13
its used in a 100 ways, thats what puts me off
Christopher McCormack
@cmccormack
Jun 29 2018 19:13
React kind of forced me to learn it as I didn't understand why methods that you passed down as props wouldn't always work
koder3
@koder3
Jun 29 2018 19:13
EXactly!
I was on a react tutorial
when i met bind() for the first time
Christopher McCormack
@cmccormack
Jun 29 2018 19:14
this is really just one thing but it looks like it's more than that
koder3
@koder3
Jun 29 2018 19:14
and here I am after two days xd
wait im not sure if its a coincidence but did you also take that react course on udemy
Christopher McCormack
@cmccormack
Jun 29 2018 19:15
I learned react on my own but later did some of the Udemy React/redux course just to see how it was
koder3
@koder3
Jun 29 2018 19:17
I see
Theres also apply and call
xD
Christopher McCormack
@cmccormack
Jun 29 2018 19:19
bind is basically to provide some kind of context to a method. sometimes context (this) can be lost so you'll get an error that undefined doesn't have the method you're calling
binding will bind that method to an object so there is context
apply and call are for breaking an item into separate arguments, but now you can just use object destructuring which looks a lot nicer imo
koder3
@koder3
Jun 29 2018 19:32
@cmccormack Thanks
richRocksCodeBlocks
@richRocksCodeBlocks
Jun 29 2018 21:09
Help help, gulp build set all of the css for my documentation project back to default. Im using webstorm on osx and I don't see it in the Local History. I have the window open in chrome but when I try to view the main.css file it shows me the local version that does not contain a days worth of code. Any ideas How I can get this back?
How can i obtain that css out of chrome? Any ideas?
Amit Patel
@AmitP88
Jun 29 2018 23:38
hey guys, I'm trying to solve the Profile Lookup challenge and I need some help understanding why my code isn't passing all the tests.
Here's my code:
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["JavaScript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(name, prop){
// Only change code below this line
    for(var i = 0; i < contacts.length; i++){
        if((name === contacts[i].firstName) && (contacts[i].firstName.hasOwnProperty(prop) === true)) {
            return contacts[i][prop];

        } else if(name !== contacts[i].firstName) {
            return "No such contact";

        } else if(contacts[i].firstName.hasOwnProperty(prop) === false) {
            return "No such property";
        }        
    }



// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
profile-lookup.png
Christopher McCormack
@cmccormack
Jun 29 2018 23:46
@AmitP88 you're returning in every condition, never giving the loop a chance to iterate past the first item
Amit Patel
@AmitP88
Jun 29 2018 23:46
ah I see
hmmm, so what do I write instead of return?
do I need to push the result to an outside empty variable?
and then return that updated variable?
Christopher McCormack
@cmccormack
Jun 29 2018 23:48
follow what the instructions say - if the contact exists then you're done iterating, but if the property doesn't then you have to return your failure message. The only time you will know that the contact doesn't exist is after the loop has completed
Amit Patel
@AmitP88
Jun 29 2018 23:51
I still don't understand what to do in terms of changing my code
I'm sorry I'm confused
sorry, I had to look at the solution
I think I was kinda close, but ugh, I just couldn't get it
Christopher McCormack
@cmccormack
Jun 29 2018 23:56
@AmitP88 walk through your loop slowly, look at each conditional you have and see what will happen. In most cases, you would be returning after the first contact name doesn't match
you gave up fast!
Amit Patel
@AmitP88
Jun 29 2018 23:56
actually I've been at this problem for the past few hours lol
Christopher McCormack
@cmccormack
Jun 29 2018 23:57
Did the solution provide the guidance you needed?
Amit Patel
@AmitP88
Jun 29 2018 23:58
yeah, I'm doing a comparison between my solution and the correct one. I have my solution commented out just above the correct one
// function lookUpProfile(name, prop){
// // Only change code below this line
//     for(var i = 0; i < contacts.length; i++){
//         if((name === contacts[i].firstName) && (contacts[i].firstName.hasOwnProperty(prop) === true)) {
//             return contacts[i][prop];

//         } else if(name !== contacts[i].firstName) {
//             return "No such contact";

//         } else if(contacts[i].firstName.hasOwnProperty(prop) === false) {
//             return "No such property";
//         }        
//     }

// // Only change code above this line
// }

function lookUpProfile(name, prop) {    
    for(var i = 0; i < contacts.length; i++) {
        if( (contacts[i]["firstName"] == name) && (contacts[i].hasOwnProperty( prop )) ) {
            return contacts[i][prop];

        }else if( (contacts[i]["firstName"] == name) && (contacts[i].hasOwnProperty( prop ) == false) ) {
            return "No such property";
        }
    }

    return "No such contact";
};
I'll have to study this solution carefully