10th
May 2018
Keggatron
@Keggatron
May 10 2018 00:10
there's no node_modules in my package.json
I ended up changing back down to node 6.11.2 and I was able to install my dependencies again
I first noticed this error trying to deploy to Heroku though as they said it might be causeed by npm
I'm getting a ! [remote rejected] master -> master (pre-receive hook declined) error
looking further up I'm getting that error again in the Heroku deploy log
but that's when I'm running version 8.9.3 of node
Nazar
@IsaakNazar
May 10 2018 04:59
hey everyone
anthonygallina1
@anthonygallina1
May 10 2018 05:00
hey hey
Nazar
@IsaakNazar
May 10 2018 05:02
@anthonygallina1 hey anthony, I have one DOM question
when you resize window width, and double click on hamburger, and resize back to normal size my menu disappearing, help
anthonygallina1
@anthonygallina1
May 10 2018 05:21
The hamburger? @IsaakNazar
Nazar
@IsaakNazar
May 10 2018 05:25
@anthonygallina1 when resize back > 650 px, the top menu should appear
not hamburger
anthonygallina1
@anthonygallina1
May 10 2018 05:25
@IsaakNazar Checking again
else { nav_cont.style.width = "100%"; }
could you stick it in there?
anthonygallina1
@anthonygallina1
May 10 2018 05:31
@IsaakNazar :point_up:
The desired style?
Line 17 JS
Nazar
@IsaakNazar
May 10 2018 05:33
@anthonygallina1 doesnt work, when resize >650 px
anthonygallina1
@anthonygallina1
May 10 2018 05:33
yup the else is none
right now
Nazar
@IsaakNazar
May 10 2018 05:35
@anthonygallina1 sorry, it works , but the hamburger menu doesnt toggle then
anthonygallina1
@anthonygallina1
May 10 2018 05:51
@IsaakNazar What I would do is export the pen To local then use dev tools inspect if you dont understand how it works. The fact that you can get a white background is a hint.
Nazar
@IsaakNazar
May 10 2018 05:51
@anthonygallina1 ok thanx :+1:
CamperBot
@camperbot
May 10 2018 05:51
isaaknazar sends brownie points to @anthonygallina1 :sparkles: :thumbsup: :sparkles:
:star2: 5877 | @anthonygallina1 |http://www.freecodecamp.org/anthonygallina1
anthonygallina1
@anthonygallina1
May 10 2018 06:00
@IsaakNazar Sorry was afk by the way that design is nice the way it is IMO. I would go with the transparent and use a appropiate color for the type that goes with the background if you use a image.
Francois Beyers
@Blusoup
May 10 2018 09:58
does anyone if it is possible to get the property value in the console. Say for example: location.pathname how can I see the function for that?
Claudio Restifo
@Marmiz
May 10 2018 10:03
console.log(location.pathname) ?
Francois Beyers
@Blusoup
May 10 2018 10:40
that still just gives the actual pathname.
Stephen James
@sjames1958gm
May 10 2018 11:41
@Blusoup What are you hoping to see?
location is a window object and pathname is a property on that object
Francois Beyers
@Blusoup
May 10 2018 12:01
i understand that, but I would like to see how that function is defined. When I'm looking at properties in the console I would like to see how they are created. Say for instance if someone has created a function in a JS script. I would like to see that function not just the function name. Hope that makes sense?
Nazar
@IsaakNazar
May 10 2018 12:04
what is the best way to make vertical lines like this?
Nazar
@IsaakNazar
May 10 2018 12:10
Christopher
May 10 2018 12:45

Hello,
I am working on the Inventory Update challenge at the moment and trying to push all values of the second array to the first if their item name is not identical.

I wrote out the following nested loop logic but it seems flawed. Why doesn't the loop only push the second array to the first as long as the name of the items aren't identical?

Here's the codepen:

As long as the item names are found in both arrays, I want to break the loop else I want to push the array to the first 2d-Array...

And in such an example does it actually make a difference for the logic which for-loop is on the "outside" and which one on the "inside"??

Christopher
May 10 2018 12:56
I think essentially my issue comes down to not being able to compare 2-d arrays... :)
I know that I have to compare every value with every other value, but I thought I would ensure this with implementing a basic nested for loop...
Stephen James
@sjames1958gm
May 10 2018 13:06
@bradley1492 Until your nested loop completes without a match you cannot push.
Since each value will not match some value of the other array - you will end up pushing every value.
@bradley1492 You could use the array function .every
@bradley1492 You would want the array that you are selecting items from to be outside, so you can test the selected item value against ALL of the values from the other array
Christopher
May 10 2018 13:10
@sjames1958gm Thanks for those tips, I have to think through this for a few minutes I think.. :)
CamperBot
@camperbot
May 10 2018 13:10
bradley1492 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9236 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
May 10 2018 13:18
Christopher
May 10 2018 13:46

@sjames1958gm Hm at the moment I have to admit I am still a bit lost. Even with every it seems for me like there are so many different possibilities.

Is the intention to use the every method on the 2d-array or with a for-loop on each sub-array?

Pieter Stokkink
@forkerino
May 10 2018 13:58
@IsaakNazar I'm thinking css with a ::before or ::after
@bradley1492 I didn't use .every. I put everything in one array, sorted the array and then used a .reduce to combine similar items. But obviously it can be solved in many different ways. It might be an idea to put .every in an if inside a loop, to check if a value is already in the array. If not, push to the array, else add the amount to the existing amount.
Christopher
May 10 2018 14:07
@forkerino hm thanks for the advice, I think I am just working on your solution with the loop and an if statement inside it.
CamperBot
@camperbot
May 10 2018 14:07
bradley1492 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2991 | @forkerino |http://www.freecodecamp.org/forkerino
Christopher
May 10 2018 14:32
@forkerino hm but if my array is let sorted = [ [2, "Hair Pin"], [3, "Half-Eaten Apple"], [67, "Bowling Ball"], [7, "Toothpaste"], [2, "Jars"] ];
I can't use every like sorted.every() because it's a 2d-array and every only works on single arrays. But how am I then supposed to work with every here?
Pieter Stokkink
@forkerino
May 10 2018 14:33
@bradley1492 .every works on arrays of any dimension
it just iterates over each element
and checks if the predicate is true
Christopher
May 10 2018 14:33
@forkerino ahhhhhhhhh
@forkerino okayyy this changes everything I think :)
Jason Luboff
@JLuboff
May 10 2018 15:07
:wave:
Christopher McCormack
@cmccormack
May 10 2018 15:16
:wave: morning all
Jason Luboff
@JLuboff
May 10 2018 15:17
Yo yo yo
Christopher McCormack
@cmccormack
May 10 2018 15:17
what's up?
Jason Luboff
@JLuboff
May 10 2018 15:18
The sky
Christopher McCormack
@cmccormack
May 10 2018 15:18
might even be the original Dad Joke!
Jason Luboff
@JLuboff
May 10 2018 15:19
Nah.... just working on a damn computer image still. Got it created, but deployment of it fails. Going to mount it with DISM and see if I can see whats going on (I have a suspicion... )
Whats up with you?
Christopher McCormack
@cmccormack
May 10 2018 15:19
Found a bug in my voting app this morning while goofing around and fixed that :D
Jason Luboff
@JLuboff
May 10 2018 15:20
What was the bug?
Christopher McCormack
@cmccormack
May 10 2018 15:20
Probably work on the nightlife app soon, I got it mostly setup
When voting on a poll, I had logic to determine if the poll short name and the user name in the path matched the doc you were voting on - well when I did my poll query I used a findOne and forgot that there can be multiple short names that are the same because they belong to different users
stupid bug but I did learn a couple things about how populate works
Jason Luboff
@JLuboff
May 10 2018 15:21
:+1:
Christopher McCormack
@cmccormack
May 10 2018 15:22
it was awesome that I randomly found it after closing a tab on my phone and seeing my voting app and then playing with it for a second, had I not I never would have noticed it existed
Need to start adding tests :(
Jason Luboff
@JLuboff
May 10 2018 15:23
...Ya... I need to add tests... i just have no idea where to start on them. So instead I just keep running through my app manually lol
Christopher McCormack
@cmccormack
May 10 2018 15:24
maybe there's some good YT videos on it, i'll have to look
I know how to make normal function tests, but then when it comes to DB queries or testing React components it's not as clear what the best way is
Would you create a separate testing DB for db tests?
Jason Luboff
@JLuboff
May 10 2018 15:26
I'm not even sure
Pieter Stokkink
@forkerino
May 10 2018 15:53
@cmccormack there are several approaches. If you want to do full end 2 end testing (complete with all the api calls), using a testing DB would be wise, especially if making lots of changes to it. You generally don't test the database directly, but the way the data ends up in your app. For React, puppeteer is a nice testing suite. I've been playing around with cypress.io for work lately and I really enjoy using that as well.
Jason Luboff
@JLuboff
May 10 2018 15:55
@forkerino Yo
Pieter Stokkink
@forkerino
May 10 2018 15:56
hey
Jason Luboff
@JLuboff
May 10 2018 15:56
Hows it going
Christopher McCormack
@cmccormack
May 10 2018 15:57
@forkerino I was hoping you would pop in, as you're the only one I know here that has to test in the real world :)
Pieter Stokkink
@forkerino
May 10 2018 15:57
Christopher McCormack
@cmccormack
May 10 2018 15:57
Nice!
Pieter Stokkink
@forkerino
May 10 2018 15:58
at least it is free for now
Christopher McCormack
@cmccormack
May 10 2018 15:58
One more course to add to the growing list haha
Pieter Stokkink
@forkerino
May 10 2018 15:58
the example uses react
@JLuboff I'm ok, need to catch up on some sleep
Christopher McCormack
@cmccormack
May 10 2018 15:58
not that long, maybe I'll watch today, thanks @forkerino
CamperBot
@camperbot
May 10 2018 15:58
cmccormack sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2992 | @forkerino |http://www.freecodecamp.org/forkerino
Pieter Stokkink
@forkerino
May 10 2018 15:58
yw
we'll get to 3k someday
Christopher McCormack
@cmccormack
May 10 2018 15:58
haha almost there!
Pieter Stokkink
@forkerino
May 10 2018 15:59
been almost there for months
Christopher McCormack
@cmccormack
May 10 2018 15:59
Randomly drop good links like that and you'll get there in no time :D
Pieter Stokkink
@forkerino
May 10 2018 16:00
haha
Jason Luboff
@JLuboff
May 10 2018 16:01
@forkerino thanks (now you're slightly closer)
CamperBot
@camperbot
May 10 2018 16:01
jluboff sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2993 | @forkerino |http://www.freecodecamp.org/forkerino
Pieter Stokkink
@forkerino
May 10 2018 16:01
oooh
Christopher McCormack
@cmccormack
May 10 2018 16:01
Unrelated to JS but related to @forkerino 's link - does anyone have a bookmarking-like tool or site they love? I used to use xmarks but lastpass bought it and stopped support a long time ago
OneTab is great but doesn't have cloud storage
Pieter Stokkink
@forkerino
May 10 2018 16:01
I'm using pocket
Jason Luboff
@JLuboff
May 10 2018 16:02
...I just use the browser's bookmarker... :joy:
Christopher McCormack
@cmccormack
May 10 2018 16:02
That's the one built into FF right?
used to be Read it later I think?
Pieter Stokkink
@forkerino
May 10 2018 16:02
Christopher McCormack
@cmccormack
May 10 2018 16:02
@JLuboff yeah if I only used one browser that would be fine
Pieter Stokkink
@forkerino
May 10 2018 16:03
cross browser
also works on mobile
Jason Luboff
@JLuboff
May 10 2018 16:03
@cmccormack Fair enough.. I actually have stuff split between FF and Edge...and only on my work computer which probably isn't ideal
Christopher McCormack
@cmccormack
May 10 2018 16:04
@forkerino I'll have to give it a try
I worry I'll end upwith 3k links like you though!
Pieter Stokkink
@forkerino
May 10 2018 16:05
@cmccormack a book
hahahaha
Christopher McCormack
@cmccormack
May 10 2018 16:05
haha
Pieter Stokkink
@forkerino
May 10 2018 16:05
This is very cool: http://meiosis.js.org/
check out the tutorial as well
It explains the principles behind many state management libraries
goes very deep
Christopher McCormack
@cmccormack
May 10 2018 16:06
Just when I was about to pick between Unstated and Redux for my next project you throw that out :D
@forkerino what do you guys use? Professional and Personal?
Jason Luboff
@JLuboff
May 10 2018 16:07
@forkerino Is this something to look into prior to React or afterwards?
Pieter Stokkink
@forkerino
May 10 2018 16:08
@JLuboff It helps if you know the basics of React. Get to it, it ain't that hard to learn.
:)
Christopher McCormack
@cmccormack
May 10 2018 16:08
I've not used but I would say learn how to use pure react first
Pieter Stokkink
@forkerino
May 10 2018 16:09
@cmccormack We use Redux, but are looking into Rematch as a wrapper now, because of ALL_THE_BOILERPLATE
Christopher McCormack
@cmccormack
May 10 2018 16:09
for shallow apps you don't need external state management at all
@forkerino in that you do not like all the redux boilerplate?
Pieter Stokkink
@forkerino
May 10 2018 16:09
at work, that is
@cmccormack it's not that bad, but I prefer the api of mobX for example (to which Rematch is closer)
I don't have time to do anything complex personally, although I might throw something together soon
Jason Luboff
@JLuboff
May 10 2018 16:10
@forkerino I wish I had more time in the day! Really trying to finish several projects at work along with learning SQL (as this is what will get me  at work). It is something on my today list though hah
Christopher McCormack
@cmccormack
May 10 2018 16:10
What about the new Context API? too simple?
Pieter Stokkink
@forkerino
May 10 2018 16:11
@cmccormack we don't use React, so that's not really possible
:)
Christopher McCormack
@cmccormack
May 10 2018 16:11
ohh I missed that haha
Pieter Stokkink
@forkerino
May 10 2018 16:11
AngularJS
plus Redux
We might change to another framework, but it will take a lot of work, not sure if we are ready to make that jump
Christopher McCormack
@cmccormack
May 10 2018 16:12
Is it worth checking out Angular?
Pieter Stokkink
@forkerino
May 10 2018 16:12
Still got a huge backlog
@cmccormack Meh. I'm not the biggest fan. Angular2+ might be ok, but then you will need TypeScript. We are still using Angular 1.6, (which is still actively developed by Google).
But I prefer React or Vue for simplicity
Christopher McCormack
@cmccormack
May 10 2018 16:14
I've been reading through the docs for some libraries and it seems you have to make a lot of compromises if you want to use TypeScript
sorry, some React libraries
This is where all of the different tools start to clash, can make it difficult
Pieter Stokkink
@forkerino
May 10 2018 16:16
Let's just forget about all the frameworks and just use Elm
:joy:
Actually, I like Elm
Christopher McCormack
@cmccormack
May 10 2018 16:19
I keep hearing whispers of Elm, I'll have to check it out
won't all languages eventually be able to compile to WASM? That will be interesting
Pieter Stokkink
@forkerino
May 10 2018 16:21
pssst.... Elm
Christopher McCormack
@cmccormack
May 10 2018 16:22
haha
weird no parens in elm
@forkerino that People Also Saved with Pocket is pretty interesting
I now know why you have 3500+ links :)
Pieter Stokkink
@forkerino
May 10 2018 16:28
true
I also have this nasty habit of saving articles linked to in articles, so it just spreads exponentially.
Christopher McCormack
@cmccormack
May 10 2018 16:32
@forkerino thanks for the tip though I'll try to use it
CamperBot
@camperbot
May 10 2018 16:32
cmccormack sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
api offline
Christopher McCormack
@cmccormack
May 10 2018 16:32
Pieter Stokkink
@forkerino
May 10 2018 16:32
too soon?
or just offline
or both
I'ma have myself some dinner.
later!
Christopher McCormack
@cmccormack
May 10 2018 16:33
Jason Luboff
@JLuboff
May 10 2018 16:33
See ya
May 10 2018 17:27
dinner geez I havent had breakfast :P
Pieter Stokkink
@forkerino
May 10 2018 17:30
Europed
7.30pm here
Christopher McCormack
@cmccormack
May 10 2018 17:31
@forkerino what are you UTC +2?
Pieter Stokkink
@forkerino
May 10 2018 17:31
yes
Christopher McCormack
@cmccormack
May 10 2018 17:33
@forkerino THANKS!
Ronique Ricketts
@RoniqueRicketts
May 10 2018 17:33
@cmccormack sup
Christopher McCormack
@cmccormack
May 10 2018 17:34
@RoniqueRicketts yo
Ronique Ricketts
@RoniqueRicketts
May 10 2018 17:34
@cmccormack wha e pree?
Christopher McCormack
@cmccormack
May 10 2018 17:34
@RoniqueRicketts wha?
Ronique Ricketts
@RoniqueRicketts
May 10 2018 17:35
Christopher McCormack
@cmccormack
May 10 2018 17:37
@RoniqueRicketts oh I see, patwah
@RoniqueRicketts nm man working bit by bit on my nightlife app now
Ronique Ricketts
@RoniqueRicketts
May 10 2018 17:37
lol yes a patwha
Christopher McCormack
@cmccormack
May 10 2018 17:38
This is a frontend/backend project so if you want, when I get to the part where the backend serves the frontend I can send you the source
May 10 2018 17:38
oh whats the backend in? (Node?)
Jason Luboff
@JLuboff
May 10 2018 17:40
Node fo sho
Christopher McCormack
@cmccormack
May 10 2018 17:40
yes
Ronique Ricketts
@RoniqueRicketts
May 10 2018 17:40
@cmccormack that's good bruv I haven't started mine yet
Christopher McCormack
@cmccormack
May 10 2018 17:40
setting it up now for a simple React page
keep getting distracted by work :D
May 10 2018 17:41
You going to do any tests on the backend code (or tests in general hehe) I need some examples :P
Ronique Ricketts
@RoniqueRicketts
May 10 2018 17:41
@cmccormack thats what's distracting me from code. Work... jeez
Christopher McCormack
@cmccormack
May 10 2018 17:42
@bradtaniguchi I think I may try to in this project, usually my testing is just making sure I try to capture every condition
Jason Luboff
@JLuboff
May 10 2018 17:42
I'm struggling with getting Windows Deployment services working right. Just trying to get a working image :'(
Maybe I'll tkae a break to do some coding
Christopher McCormack
@cmccormack
May 10 2018 17:43
@JLuboff can't you just call Microsoft and have them walk you through?
Jason Luboff
@JLuboff
May 10 2018 17:43
@cmccormack I'm sure for some :moneybag: :moneybag:
Christopher McCormack
@cmccormack
May 10 2018 17:44
@JLuboff I bet you guys have some kind of site license with support
Jason Luboff
@JLuboff
May 10 2018 17:45
Ehhhhhhh I don't think so... or atleast it's never been mentioned to me in my 4.5 years here :joy:
Christopher McCormack
@cmccormack
May 10 2018 17:46
you could be missing out on lots of free (to you) support!
Jason Luboff
@JLuboff
May 10 2018 17:48
True.. but.. I'm pretty sure he would have mentioned it by now.. there's been other times where that would have been useful if we had it that he hasnt mentioned anything
Christopher McCormack
@cmccormack
May 10 2018 17:50
they may not know either - just throwing it out there :D
Jason Luboff
@JLuboff
May 10 2018 17:51
I'll check into it, doesn't hurt to do so
Christopher
May 10 2018 18:11

Hello,
can anyone help me why the following logic isn't working?

for (let i = 0; i < sorted.length; i++){
if(arr1.every(function(element){
return element == sorted[i];
}) = true) {
console.log("true");
}
}

Here's my codepen

CamperBot
@camperbot
May 10 2018 18:11
:bulb: to format code use backticks!  more info
Kudzu
@czhower
May 10 2018 18:13
If you are in a recent ES you can shorten it to make it easier to read too:
for (let i = 0; i < sorted.length; i++){
if(arr1.every((element) +> element == sorted[i];})) {
console.log("true");
}
}
since its an array, better yet, use a for of loop
May 10 2018 18:14
This code seems like its doing double the work here
Kudzu
@czhower
May 10 2018 18:14
for array, better yet. use for of instead of for
Christopher
May 10 2018 18:14
@czhower thx I'll change it
CamperBot
@camperbot
May 10 2018 18:14
bradley1492 sends brownie points to @czhower :sparkles: :thumbsup: :sparkles:
Kudzu
@czhower
May 10 2018 18:15
and array has methopds do what you want... also typo the +> should be =>
you can use for of and filter and make it a single line
or 3 with the body in a block.
Christopher
May 10 2018 18:16
@czhower I suspected filter of playing a role here, I just wanted to first get a basic solution down
Kudzu
@czhower
May 10 2018 18:16
something like:
for (const x of arr1.filter((e) => e ==x;) {
console.log("true");
}
thats just ad hoc, so it might have some small typos/syntax errors, but thats the idea
Christopher
May 10 2018 18:17

@czhower hm but

for (let i = 0; i < sorted.length; i++){
if(arr1.every((element) => element == sorted[i]})) {
console.log("true");
}
}

Is also not working ..

Kudzu
@czhower
May 10 2018 18:18
use the debugger, trace it. Thats a key skill most JS devs seem to not learn.
Christopher
May 10 2018 18:18
@czhower debugger?
Kudzu
@czhower
May 10 2018 18:18
Christopher
May 10 2018 18:19
@czhower whats a debugger, I only know the console
Kudzu
@czhower
May 10 2018 18:19

exactly..... the debugger is the force of any software dev... I cant believe so many JS boot camps never even touch it. Its like learning to drive a car without learning how to read a traffic light or use the brakes.

in most browsers, its Ctrl-shift-J - a whole new world in there that will let you watch your code as it runs.

The Moz one is a horrible UI, the Chrome one much better.
this is TS, but its same debugger for raw JS:
Thats Chrome. FF can do the same, but I swear some drunkard did the UI for FF's debugger.
Kudzu
@czhower
May 10 2018 18:25

Without a debugger, you are just guessing at what goes wrong.... as code gets more complex, that becomes practically impossible.

In your case though, your every might be the problem, but I dont know exactly what your goal is, just guessing from your code.

Pieter Stokkink
@forkerino
May 10 2018 18:28
@bradley1492 right now you are checking if every element in arr1 is equal to sorted[i], I guess you want to check if any element is equal to it?
in which case .some is better
or you can do the inverse
Nate Mallison
@NJM8
May 10 2018 18:29
@bradley1492 In your code from the code you need to write == true, with single equals you are trying to set the value true not check the value against true
And in the one suggested by cz you need to get rid of the lone open curly bracket
Kudzu
@czhower
May 10 2018 18:31
If checking true, in most cases you dont need to check against it at all. Truthiness will take care of it.
Christopher
May 10 2018 18:32
@czhower I am often using the console, I hope this is what you mean by debugger.
I forgot yeah, true doesn't have to be checked.
Kudzu
@czhower
May 10 2018 18:33
well console is a tiny bit.. but thats like having a PC today with only text mode.. no graphics. Do youreself a huge favor and investigate the full debugger, at least for watches and tracing.
using console.log only is how things were debugged in the 1960s :)
Christopher
May 10 2018 18:34
@czhower @forkerino my goal was to check for every item name in the sorted array if it has a duplicate in arr1
I wanted to loop through the sorted array and then check every item name against every item name of the arr1
@czhower hahahah I'll investigate further into debugging thx
CamperBot
@camperbot
May 10 2018 18:35
bradley1492 sends brownie points to @czhower :sparkles: :thumbsup: :sparkles:
api offline
Nate Mallison
@NJM8
May 10 2018 18:35
@bradley1492 I would also suggest to break it down instead of putting something like arr1.every inside the if condition, do the arr1.every set to a variable, then do if (var), it's easier to reason about
Kudzu
@czhower
May 10 2018 18:36
if you are just chekcing one array against another, you can just loop and do an indexof to see it exists in the other array.
Christopher
May 10 2018 18:36
@NJM8 alright sounds reasonable yes
Kudzu
@czhower
May 10 2018 18:36
or there is a Contains function too I think in later ES specs.
Pieter Stokkink
@forkerino
May 10 2018 18:36
.includes
Kudzu
@czhower
May 10 2018 18:36
Im working in about 5 languages concurrently so I dont remember, but googlge will turn it up.
Nate Mallison
@NJM8
May 10 2018 18:37
ha
it should be contains
Christopher
May 10 2018 18:37
@czhower .includes I tried the other day but then @sjames1958gm told me it was not compatible with 2d-arrays
Christopher McCormack
@cmccormack
May 10 2018 18:37
Thanks MooTools :(
Nate Mallison
@NJM8
May 10 2018 18:37
I always right contains then wonder why it isn't working, haha
Pieter Stokkink
@forkerino
May 10 2018 18:37
Christopher
May 10 2018 18:37
hence I should be using something else like every
Kudzu
@czhower
May 10 2018 18:37
2D or jagged? you can always use a jagged if you control the decl.
A jagged array is an array of arrays..its like a 2D, but the lang sees them as separate arrays.
Pieter Stokkink
@forkerino
May 10 2018 18:38
@bradley1492 you will need to check indexes of both sorted[i] and the element to see if these match
as in sorted[i][1] === element[1] to check if the second element of the subarray matches
Nate Mallison
@NJM8
May 10 2018 18:38
@bradley1492 contains only works on 1-d is correct..... but you don't need the quantity to compare it, so make a new array of just the item names and use that to compare too
many ways to do it
Pieter Stokkink
@forkerino
May 10 2018 18:39
or use .some
with a callback comparing the correct things
Christopher
May 10 2018 18:40
@forkerino but I thought with .every I could just "scan" the whole 2d array and check if any of the elements in the whole 2d array are identical to another item name in another array?!
Nate Mallison
@NJM8
May 10 2018 18:41
.every is for testing if all items in an array pass a testing condition
Kudzu
@czhower
May 10 2018 18:41

Definition and Usage

The every() method checks if all elements in an array pass a test (provided as a function).

The every() method executes the function once for each element present in the array:

If it finds an array element where the function returns a false value, every() returns false (and does not check the remaining values)
If no false occur, every() returns true

Note: every() does not execute the function for array elements without values.

Note: every() does not change the original array

every is not same as "for each"
every checks that EVERY element matches your condition - if so it returns true, else false.
Nate Mallison
@NJM8
May 10 2018 18:42
const areAllNums = [1,2,3,4].every(num => typeof(num) === 'number');
Pieter Stokkink
@forkerino
May 10 2018 18:43
@bradley1492 you could check if every element DOESN'T match
or you could check if .some element DOES match
it's same same but different
Nate Mallison
@NJM8
May 10 2018 18:44
@forkerino Can you try this again and tell me the results in the console? https://www.natethedev.com/arrayFlattenComparisons/
Christopher
May 10 2018 18:44
@forkerino My Idea was to check if every element doesn't match
Pieter Stokkink
@forkerino
May 10 2018 18:45
@bradley1492 that is a valid idea, but the code above checks if all elements do match (i.e. all elements being the exact same)
@NJM8 checking...
Nate Mallison
@NJM8
May 10 2018 18:46
Stephen James
@sjames1958gm
May 10 2018 18:46
@bradley1492 The problem with includes and two-d arrays is the the includes will compare
the array references:
var x = [1, 2, 3];
var arr = [x, [2, 3, 4]]
arr.includes(x); // matches x because they refer to the same array
true
arr.includes([2, 3, 4]); // doesn't match [2, 3, 4] because the two [2, 3, 4] arrays are different references
false
Kudzu
@czhower
May 10 2018 18:47
That isnt a 2 day array, thats an array with an array inside as one of the elements.
Christopher
May 10 2018 18:47
@NJM8 thx a lot
CamperBot
@camperbot
May 10 2018 18:47
bradley1492 sends brownie points to @njm8 :sparkles: :thumbsup: :sparkles:
Kudzu
@czhower
May 10 2018 18:47
x is a 1D array, and so is arr. but elem[1] of x is an array itself. A 2D array has 2 sets of indexes
Stephen James
@sjames1958gm
May 10 2018 18:48
@czhower So arr[0][1] is 3
Kudzu
@czhower
May 10 2018 18:48
I dont think JS has 2D arrays, I think you have to use jagged arrays to achieve that.
technically no, thats a jagged array but the end result is nearly identical.
and thats still only 2D, not 3.
Pieter Stokkink
@forkerino
May 10 2018 18:49
@NJM8
steamrollArray deep test average: 18.806000000040513msecs
lodash flattenDeep deep test average: 14.109999999636784msecs
flat deep test average: 10.065999999787891msecs
steamrollArray shallow test average: 2.1100000004662434msecs
lodash flatten shallow test average: 1.4680000002408633msecs
flat shallow test average: 1.720999999815831msecs
I'm not getting the averages
Kudzu
@czhower
May 10 2018 18:49
each index is a D, ie 3 indexed, 3D... 2 indexes.. 2D
Pieter Stokkink
@forkerino
May 10 2018 18:49
at least not the first one.
Nate Mallison
@NJM8
May 10 2018 18:49
@forkerino thanks, those are the averages, I changed it a bit
CamperBot
@camperbot
May 10 2018 18:50
njm8 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2994 | @forkerino |http://www.freecodecamp.org/forkerino
Christopher McCormack
@cmccormack
May 10 2018 18:50
6 more!
Kudzu
@czhower
May 10 2018 18:50
or an array of arrays can act as a 2D as well, but strictly speaking are not a 2D array .
Nate Mallison
@NJM8
May 10 2018 18:50
I still want to know how the results from your computer are so different from mine
@czhower I think you are correct from a CS perspective JS doesn't have 2D arrays, it just has arrays of arrays or nested arrays, but we JS heathens call them 2D anyways.
Kudzu
@czhower
May 10 2018 18:52
yes, but I was explaining it from a technicality standpoint. Most devs who make a career of it will eventually learn more than just JS, and so its never too early to use the proper terminology.
Nate Mallison
@NJM8
May 10 2018 18:55
technically js doesn't really have arrays either
Kudzu
@czhower
May 10 2018 18:55
JS teahces a LOT of bad coding habits - so never to early to learn the bad parts - easier to chagne before it becomes habbits.
yeah, they are just quasi-objects made to act lik arrays, but they are mostly indistinguisable.
Stephen James
@sjames1958gm
May 10 2018 18:55
JS doesn't teach anything
Kudzu
@czhower
May 10 2018 18:56
yes, it does. Devs assume if something exists, that it must be the "right" way to do things. And without guidance, it becomes canon.
The majority of JS devs are horrible coders because they never progress past "just making it work". And for many who just want \$, I suppose thats enough. And it creates a huge market for others how have to fix that stuff
Nate Mallison
@NJM8
May 10 2018 18:59
@czhower I'm partial to the Kyle Simpson frame of mind, JS let's you do a lot of things really fast without knowing much, and a certain someone in response to that released a well respected book that teaches you to avoid "The Bad Parts". What one should really do if investing in programming career and not a simple front end dev career is to really understand how JS works and how it differs from other languages. I think we are pretty much on the same page, it's just not JS's fault though, if netscape knew what was going to happen they may have put a few more people on the project. It's a result of underestimating the power of the internet.
Kudzu
@czhower
May 10 2018 19:00
JS even today continues to evolve in poor ways rather than proper. If JS is all a dev ever sees...... a JS dev to be good must learn more than just how to make things work.
Christopher
May 10 2018 19:01

@forkerino @czhower I changed the code to the following now:


function check(element){
return element !== sorted[i][1];
}

for(let i = 0; i < sorted.length; i++){
if(arr1.every(check)){
arr1.push(sorted[i]);
}
}

But how should I prove the callback function with the relevant loop informationa --> in this case the [i] variable if I am not providing the callback inside the for-loop?

Kudzu
@czhower
May 10 2018 19:02
Get it working first, but Id still inline that function and use for of instead of for. the for of chagne is really easy:
for(const x of sorted){
if(arr1.every(check)){
arr1.push(x);
}
}
then
Nate Mallison
@NJM8
May 10 2018 19:03
True, I don't disagree, but the governing body can't just make changes that are going to break 100,000,000 websites. It is what is now. Besides. To play devils advocate, with the speed of things, how many JS website built now aren't going to be completely rebuilt in 5-10 years purely because of tooling and bigger idea improvements.
Someone building Stripe? Yes, they need to know their stuff, buliding a website for a mom and pop pizza place? who cares
Kudzu
@czhower
May 10 2018 19:04
They dont have to break anything. but even when they add stuff, its still done in a very hacky way
Its like 3 steps forward, 2 back every friggin time they make a new ES spec.
Nate Mallison
@NJM8
May 10 2018 19:05
True, a few of the changes I scratched my head over after really understanding the details
Kudzu
@czhower
May 10 2018 19:05
And it makes it worse, because next rev they have to "refix" that and now they have backwards compat to think of.
Nate Mallison
@NJM8
May 10 2018 19:05
I still mostly like it more than C, I don't want to worry about allocating enough memory and stuff like that. It's a good feeling to get it right, but still feels like a lot of work I shouldn't have to do.
Christopher
May 10 2018 19:06
@czhower alright thx
Kudzu
@czhower
May 10 2018 19:06
I mean come on.. JS invented in 95 and years were 2 digits?????? And that kind of stuff just continues today.. only looking to the very short term on everything... never even mid term.
Not really good to compare against C which is a low level language from the 60s. Thats like comparing a yugo against a Model T.
Nate Mallison
@NJM8
May 10 2018 19:07
My biggest issue is inconsistency in naming and usage conventions.
I think you meant Ferrari and Model T, hahaha
Kudzu
@czhower
May 10 2018 19:07
JS is here, we deal with it for now. But no one chooses JS because its a good lang, we choose it because its the lang of the browser.
no way I would ever call JS a Ferrari....
Christopher
May 10 2018 19:07
@czhower you mean get the callback working?
Nate Mallison
@NJM8
May 10 2018 19:07
haha
Kudzu
@czhower
May 10 2018 19:08
the callback you have a param problem with i
anything you want to use you have to pass as an arg.
Christopher
May 10 2018 19:08
@czhower ahhh so I can't use it like that
Kudzu
@czhower
May 10 2018 19:09
correct
Christopher
May 10 2018 19:09
@czhower in my case I have to use it inside the loop, not decalring it before
Kudzu
@czhower
May 10 2018 19:09
check is not inside the loop.... it refs i..... Have to go.. back in a few hours.
Christopher
May 10 2018 19:09
@czhower alrigt thx
CamperBot
@camperbot
May 10 2018 19:09
bradley1492 sends brownie points to @czhower :sparkles: :thumbsup: :sparkles:
api offline
Nate Mallison
@NJM8
May 10 2018 19:11
@bradley1492 Maybe just do it all with regular for-loops before getting into the higher order functions
then once if works and you have the logic down you can refactor
Christopher
May 10 2018 19:11
@NJM8 but for .every I need a callback?!
@NJM8 you mean the callback function as higher-order-function do you?
Nate Mallison
@NJM8
May 10 2018 19:12
.every is a higher order function
Christopher
May 10 2018 19:13
@NJM8 hm but I seem even more lost, not being able to use .every in my case
Nate Mallison
@NJM8
May 10 2018 19:13
higher order functions are functions that give you extra capabilities, like .every that checks all elements, or .some that does the same for one element
Christopher
May 10 2018 19:15
@NJM8 higher order functions are functions that take callback functions as arguments?
Christopher McCormack
@cmccormack
May 10 2018 19:15
Nate Mallison
@NJM8
May 10 2018 19:16
yes
they take callbacks and have more power
Christopher
May 10 2018 19:16
@cmccormack thanks I try to read mdn first for most of the stuff
CamperBot
@camperbot
May 10 2018 19:16
bradley1492 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1442 | @cmccormack |http://www.freecodecamp.org/cmccormack
Nate Mallison
@NJM8
May 10 2018 19:17
for (let i = 0; i < arr1.length; i++) {
for (let j = 0; j < arr2.length; j++) {
if (arr1[i][1] === arr2[j][1]) {
// do work
} else {
// do other work
}
}
}
I got rid of the if statements work so that you can figure that out yourself, just a simple double loop, for every element in array one, check every element in array two, if it's the same, add the quantity, if not add the whole item
Christopher
May 10 2018 19:19
@NJM8 hm I'll play around with this for a minute thx
CamperBot
@camperbot
May 10 2018 19:19
bradley1492 sends brownie points to @njm8 :sparkles: :thumbsup: :sparkles:
api offline
Nate Mallison
@NJM8
May 10 2018 19:19
for (let i = 0; i < arr1.length; i++) {
console.log(arr[i])
for (let j = 0; j < arr2.length; j++) {
console.log(arr2[j])
if (arr1[i][1] === arr2[j][1]) {
// do work
} else {
// do other work
}
}
}
run that one just as it is, you should see the arr1 item log then all arr2 items log, then the second arr1 item then all arr2 items again
sure thing, gtg good luck
Christopher
May 10 2018 19:25

@NJM8 hm I have been at this stage before where it now grows my arr1 to 138 or something :). This is what I did:

I don't think this is the way to check if all an itemname of arr2 has no duplicates in arr1...
And if I turn around the loop structure I get an infinite loop..

Christopher
May 10 2018 19:30
@NJM8 Which was why I then changed to .includes and then to .every
Pieter Stokkink
@forkerino
May 10 2018 19:42
Yes, you loop over the array and for every element that doesn't match (which can be all of them, you push something to the other array).
What you need to do is only push of none of the items match.
I'm not sure it is possible to do with a nested for without having some sort of flag which says whether or not you found a match.
Or use .every/.some to make this check and lose the inner loop.
Tiago Correia
@tiagocorreiaalmeida
May 10 2018 19:47
hello everyone
if someone can give a hand or two, allready tried a few stuff and not working
Pieter Stokkink
@forkerino
May 10 2018 19:48
@bradley1492 something like if (arr1.every(e => e[1] !== arr2[i][1])) {
@tiagocorreiaalmeida did you add the scope to the request?
Christopher McCormack
@cmccormack
May 10 2018 19:49
dangit
Tiago Correia
@tiagocorreiaalmeida
May 10 2018 19:49
I tried, or maybe im getting the idea of passing the scope wrong?
let me show what I already tried
Pieter Stokkink
@forkerino
May 10 2018 19:49
show us how you did
yes
Tiago Correia
@tiagocorreiaalmeida
May 10 2018 19:50
tried this
    passport.use(new GoogleStrategy.Strategy({
}, async (accessToken, refreshToken, profile, done) => {
try {
console.log(profile);
} catch (e) {
done(null, false);
}
}));
and this
router.get("/login-google", passport.authenticate('google', { scope: "https://www.googleapis.com/auth/plus.login" }));
wait now works hum
not fair
:D
Christopher McCormack
@cmccormack
May 10 2018 19:50
@tiagocorreiaalmeida the docs have this:
app.get('/auth/google',
passport.authenticate('google', { scope: ['profile'] }));
Tiago Correia
@tiagocorreiaalmeida
May 10 2018 19:51
somehow its allready working @cmccormack sorry to spam the chat and bother :D
Christopher McCormack
@cmccormack
May 10 2018 19:51
@tiagocorreiaalmeida haha that long url just gives you plus.login
no worries I'm going to implement my auth very soon so this is good to see
Tiago Correia
@tiagocorreiaalmeida
May 10 2018 19:52
yeah, tought it would be hard with react but then just had an idea and this is pretty simple :D
Christopher McCormack
@cmccormack
May 10 2018 19:52
nope React has almost nothing to do with the backend
Tiago Correia
@tiagocorreiaalmeida
May 10 2018 19:52
yeah but you have to handle a few stuff when implementing this kind of oatuhs
Christopher McCormack
@cmccormack
May 10 2018 19:52
Sure as an API
Tiago Correia
@tiagocorreiaalmeida
May 10 2018 19:54
yup, still doing the vote app?
Christopher McCormack
@cmccormack
May 10 2018 19:54
nah I think I finished
started nightlife but first making a nice boilerplate for Express/mongo/mongoose/babel/webpack/etc...
Tiago Correia
@tiagocorreiaalmeida
May 10 2018 19:55
I see, I normally just go for create-react-app and the backend just as usual
looking at the project
Christopher McCormack
@cmccormack
May 10 2018 19:56
eh I've been doing my stuff manually since I started so I could understand it and now I have a good set of tools that I know how they work
but I spend a little time each project looking through the docs to see if I could have done stuff a better way
oh and this project I'm playing with preact instead of React
was super simple to setup
Christopher
May 10 2018 19:57
@forkerino thx yes I'll concentrate on the every solution once more tomorrow I think thx for the help
CamperBot
@camperbot
May 10 2018 19:57
bradley1492 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2995 | @forkerino |http://www.freecodecamp.org/forkerino
Tiago Correia
@tiagocorreiaalmeida
May 10 2018 19:57
looks fine and also good design, materialize on point :D congrats the functionality is all there. never heard of it will give a look
Christopher McCormack
@cmccormack
May 10 2018 19:58
@tiagocorreiaalmeida preact creates way smaller bundles
that, along with a compression plugin for webpack, and it's much tinier than react
@tiagocorreiaalmeida I think this was all I needed in my webpack config to get preact working:
    resolve: {
alias: {
"react": "preact-compat",
"react-dom": "preact-compat",
},
Eunice Park
@eunicode
May 10 2018 20:03
I have a question about using let and const, what if you declare a variable in a block, but you want it to have function-wide scope?
Christopher McCormack
@cmccormack
May 10 2018 20:03
@eunipa test it :)
Eunice Park
@eunicode
May 10 2018 20:04
@cmccormack Uh I get "variableblahblah is not defined"
Christopher McCormack
@cmccormack
May 10 2018 20:05
@eunipa children have access to parent's scope but not the other way around
don't think that has anything to do with let and const though
Eunice Park
@eunicode
May 10 2018 20:06
@cmccormack Right. The thing is, I want a variable I declared in a block statement, like say an if statement, to be available in another block statement, like the block statement of a for loop, like I would if I were using the var keyword. All this is being done inside of a function, the two blocks are on the same level of nesting
Christopher McCormack
@cmccormack
May 10 2018 20:07
declare it outside then. If it will change, use let, if not use const
May 10 2018 20:07
^
always use const first, I only use let in certain cases.
Eunice Park
@eunicode
May 10 2018 20:08
But isn't that redundant? It seems like using var would be better? But ppl say it's better to stop using var
Gulsvi
@gulsvi
May 10 2018 20:09
I think I've hit that issue before - var works great, but neither let nor const work. Can you show the code @eunipa or an example?
May 10 2018 20:09
let someThing;
if (blah) {
console.log(someThing);
}
if (otherBlah) {
console.log(someThing);
}
Eunice Park
@eunicode
May 10 2018 20:13
For example
function titleCase(title, minorWords) {
const lowerCaseTitle = title.toLowerCase();
const arrayWords = lowerCaseTitle.split(" ");
console.log("arrayWords", arrayWords);

const upperCaseArray = arrayWords.map( elm => {

if (minorWords) {
const arrayMinorWords = minorWords.split(" ");
console.log("arrayMinorWords", arrayMinorWords);
}

for (let i = 0; i < arrayMinorWords.length; i++) {
if (elm === minorWords[i]) {
return elm;
} else {
const firstLetter = elm.charAt(0).toUpperCase();
const restOfWord = elm.slice(1);
return firstLetter + restOfWord;
}
}
});

console.log(upperCaseArray);

}

titleCase('')
Christopher McCormack
@cmccormack
May 10 2018 20:14
@eunipa really you want to try and form your code so you can use const just about everywhere. The ability to change a variable is what we want to avoid in the end, as it can lead to unwanted side effects
May 10 2018 20:16
I don't think this is a good example
ehutchllew
@ehutchllew
May 10 2018 20:17
var still has a place in the JS world, albeit it is used sparingly. I do generally define my variables using let or const.
May 10 2018 20:18
titleCase('who cares', '') and titleCase('some arg') both explode regardless of the usage of const here
Eunice Park
@eunicode
May 10 2018 20:20
Sorry about that, the code is a work in progress. If I were to summarize want I want to do, I'd say, what if you use an if statement to check if a parameter exists. And if the parameter (a string) exists, you want to convert it into an array of words, and assign that array of words to a variable. And then you want to use that variable later in a for loop.
That kind of goes into detail on what's happening
I see your point, it's an extra line of code to declare the variable first
Christopher McCormack
@cmccormack
May 10 2018 20:22
@eunipa maybe make a function that takes in the comparison you are doing in the if statement and returns an array of words if the parameter exists
ehutchllew
@ehutchllew
May 10 2018 20:22
@eunipa if that's the structure you want to go with, you would be right to use var
Tiago Correia
@tiagocorreiaalmeida
May 10 2018 20:26
@cmccormack maybe will try it out once I build my client side
Eunice Park
@eunicode
May 10 2018 20:27
@gulsvi Thanks, I'll have to read more about whether it is proper or not to declare variables in an if block. That article says "So, my rule of thumb is to use const whenever possible, let if I need to change the value of the variable at a latter state and forget about var." Which basically means I won't be able to declare variables in an if block.
CamperBot
@camperbot
May 10 2018 20:27
eunipa sends brownie points to @gulsvi :sparkles: :thumbsup: :sparkles:
:star2: 2718 | @gulsvi |http://www.freecodecamp.org/gulsvi
Christopher McCormack
@cmccormack
May 10 2018 20:27
@eunipa you only declare them in a block if you're going to use them in a block, but not outside
Tiago Correia
@tiagocorreiaalmeida
May 10 2018 20:27
looks like you know python @cmccormack :D
Christopher McCormack
@cmccormack
May 10 2018 20:27
@tiagocorreiaalmeida yeah
Tiago Correia
@tiagocorreiaalmeida
May 10 2018 20:27
that's atually pretty nice
Pieter Stokkink
@forkerino
May 10 2018 20:27
@eunipa you can use a default for the parameter and lose the if altogether.
Christopher McCormack
@cmccormack
May 10 2018 20:28
@tiagocorreiaalmeida I don't use it as much now that I can use node on servers :)
Pieter Stokkink
@forkerino
May 10 2018 20:28
@eunipa otherwise do something like
let arrayMinorWords
if (minorWords) {
arrayMinorWords = ...
}
Jason Luboff
@JLuboff
May 10 2018 20:29
I'm really bad about mainly using let... only really use const in my require portion and a few other spots.. should probably go through my code and determine what variables don't change and change them to const though
Eunice Park
@eunicode
May 10 2018 20:29
@cmccormack That makes sense. I'm just used to the var keyword and it having function wide scope. Thank you for your help.
CamperBot
@camperbot
May 10 2018 20:29
eunipa sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1443 | @cmccormack |http://www.freecodecamp.org/cmccormack
Gulsvi
@gulsvi
May 10 2018 20:30
function splitLetters(str) {
if(str) {
const letterArray = str.split('');
console.log("letterArray", letterArray); // "letterArray" ["a", "b", "c"]
}

console.log("outside if: ", letterArray) // undefined unless letterArray declared with var
}

splitLetters("abc");
Tiago Correia
@tiagocorreiaalmeida
May 10 2018 20:30
yeah true @cmccormack :D im learning it but on a really slow mode
Eunice Park
@eunicode
May 10 2018 20:30
@forkerino Thank you for your suggestion. I'll research more about default parameters (ES6?).
CamperBot
@camperbot
May 10 2018 20:30
eunipa sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2996 | @forkerino |http://www.freecodecamp.org/forkerino
Gulsvi
@gulsvi
May 10 2018 20:30
or, do as Forkerino put up there
Christopher McCormack
@cmccormack
May 10 2018 20:31
@tiagocorreiaalmeida best way to learn is to build something - people seem to like making web scrapers as their first project that they actually enjoy, using Beautiful Soup
Tiago Correia
@tiagocorreiaalmeida
May 10 2018 20:32
I made a tictactoe a few days ago... :D
Pieter Stokkink
@forkerino
May 10 2018 20:32
@eunipa yeah, I think that is ES6, but you can also assign minorWords to an empty string if it is undefined (that was the ES<6 way):
minorWords = minorWords || ''
default params is basically function (array, minorWords = '') {
Tiago Correia
@tiagocorreiaalmeida
May 10 2018 20:32
but also had to create an exe that would merge pdf's and took me something like 9 lines and a package from pip
Gulsvi
@gulsvi
May 10 2018 20:33
const isn't as simple as "don't use const if you change the value", for example:
const myArr = [1, 2, 3];
myArr.push(4);
console.log(myArr); // [1, 2, 3, 4]
[myArr[0], myArr[1]] = [myArr[1], myArr[0]];
console.log(myArr); // [2, 1, 3, 4]
^ That works fine
Eunice Park
@eunicode
May 10 2018 20:33
@forkerino Wow, thanks a lot. I didn't know you could do that.
CamperBot
@camperbot
May 10 2018 20:33
eunipa sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
api offline
Eunice Park
@eunicode
May 10 2018 20:34
CamperBot
@camperbot
May 10 2018 20:34
eunipa sends brownie points to @ehutchllew and @bradtaniguchi :sparkles: :thumbsup: :sparkles:
Eunice Park
@eunicode
May 10 2018 20:37
@gulsvi According to MDN, you can't change the value of a constant through re-assignment, but it looks like you can manipulate the value.
Christopher McCormack
@cmccormack
May 10 2018 20:39
@eunipa you could do something like this and never even need a variable:
function titleCase(sentence, minorwords) {

return sentence.toLowerCase().split(' ').map((word) => (
minorwords.includes(word) ? word : word[0].toUpperCase() + word.slice(1)
)).join(' ')
}

console.log( titleCase('this is a sentence', ['is', 'a', 'the', 'if']) )
Eunice Park
@eunicode
May 10 2018 20:43
@cmccormack pure brilliance. I didn't know you could use the include method on strings.
Jason Luboff
@JLuboff
May 10 2018 20:43
There is both a string and array method for includes
Eunice Park
@eunicode
May 10 2018 20:43
@cmccormack But, your method doesn't work if there is no argument for minor words
Christopher McCormack
@cmccormack
May 10 2018 20:44
@eunipa alternatively:
function titleCase(sentence, minorwords) {

return sentence.toLowerCase().split(' ').map((word) => (
~minorwords.indexOf(word) ? word : word[0].toUpperCase() + word.slice(1)
)).join(' ')
}

console.log( titleCase('this is a sentence', ['is', 'a', 'the', 'if']) )
Jason Luboff
@JLuboff
May 10 2018 20:44
@cmccormack ~ bitwise operator?
Christopher McCormack
@cmccormack
May 10 2018 20:45
function titleCase(sentence, minorwords = []) {

return sentence.toLowerCase().split(' ').map((word) => (
~minorwords.indexOf(word) ? word : word[0].toUpperCase() + word.slice(1)
)).join(' ')
}

console.log( titleCase('this is a sentence', ['is', 'a', 'the', 'if']) )
console.log( titleCase('this is another sentence'))
Eunice Park
@eunicode
May 10 2018 20:46
@cmccormack @JLuboff What is this sorcery lol? Thanks again, I guess I'll have to research bitwise operators
CamperBot
@camperbot
May 10 2018 20:46
eunipa sends brownie points to @cmccormack and @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2411 | @jluboff |http://www.freecodecamp.org/jluboff
api offline
Christopher McCormack
@cmccormack
May 10 2018 20:47
or just
function titleCase(sentence, minorwords) {
return sentence.toLowerCase().split(' ').map((word) => (
minorwords && minorwords.indexOf(word) !== -1 ? word : word[0].toUpperCase() + word.slice(1)
)).join(' ')
}

console.log( titleCase('this is a sentence', ['is', 'a', 'the', 'if']) )
console.log( titleCase('this is another sentence'))
@eunipa don't, that's just me being a dork.
well, do so but not on our account :)
updated the one above to not use the bitwise
The ~ basically changes the -1 to a 0, which is a falsey value
ehutchllew
@ehutchllew
May 10 2018 20:49
I don't think I've ever seen a bitwise operator in the wild.
Jason Luboff
@JLuboff
May 10 2018 20:50
YESSS!! Completely unrealted to this (and programming..)...but looks like my image is finally deploying properly!!
Christopher McCormack
@cmccormack
May 10 2018 20:52
@ehutchllew you can swap values using xor!
let a = 1
let b = 2
a = a ^ b
b = a ^ b
a = a ^ b
console.log(a, b) // 2 1
I think there is a shorter way but I forget
Kaz Baig
@kbaig
May 10 2018 20:53
[a, b] = [b, a];
Christopher McCormack
@cmccormack
May 10 2018 20:53

@kbaig

bitwise operator

Kaz Baig
@kbaig
May 10 2018 20:53
Oh you mean shorter while still using bitwise
Christopher McCormack
@cmccormack
May 10 2018 20:54
yeah
Kaz Baig
@kbaig
May 10 2018 20:54
gotcha
Christopher McCormack
@cmccormack
May 10 2018 20:54
I thought there was a two-liner but I can't remember
Jefferson
@jeffersonnnn
May 10 2018 20:54
@JLuboff congrats
Christopher McCormack
@cmccormack
May 10 2018 20:54
maybe I'm just thinking 2 variable only
Jason Luboff
@JLuboff
May 10 2018 20:54
@jeffersonnnn Thanks..but apparently I spoke too soon.. failed at 92% :cry:
CamperBot
@camperbot
May 10 2018 20:54
jluboff sends brownie points to @jeffersonnnn :sparkles: :thumbsup: :sparkles:
Jason Luboff
@JLuboff
May 10 2018 20:56
But it's so close I can taste it
Jefferson
@jeffersonnnn
May 10 2018 20:56
@JLuboff oh wow. Argh, i get this. Half the time, i find that the logic parts of our apps are not a problem. Bring in the pretty parts, and all hell is let loose lool sigh
Keep at it!
Jason Luboff
@JLuboff
May 10 2018 20:56
I aint stopping, thats for sure
Jefferson
@jeffersonnnn
May 10 2018 20:58
now that's the spirit. We will become masterss. *does the Yogi salute
No one should ask me what the yogi salute is. I haven't watch any Star Wars movie :'(
Jason Luboff
@JLuboff
May 10 2018 20:59
I've watched every star wars movie and don't know what a yogi salute is hah
Christopher McCormack
@cmccormack
May 10 2018 21:00
@kbaig your way is much cleaner though :)
ehutchllew
@ehutchllew
May 10 2018 21:00
@cmccormack lol, i spent about half a day trying to figure out situations where I'd use these operators, but... I just don't know bit code well enough.
Jefferson
@jeffersonnnn
May 10 2018 21:01
@JLuboff how do i start with it. Which is the first. I was always a Star Trek Buff. I think i read every paper back i could lay my hands on. Now Star Trek is my thangg
Jason Luboff
@JLuboff
May 10 2018 21:03
@jeffersonnnn I watched them in order of release (4, 5, 6, 1, 2, 3, 7, Rogue One, 8). Thats only becuses when I first started watching them, only 4, 5, 6 existed. Now, you can search online for the best order. I know some people say to completely forget about watching 1
May 10 2018 21:17
Now the new question is if you liked episode 8 or not, hehe ignite the fury XD
Jefferson
@jeffersonnnn
May 10 2018 21:17
@JLuboff 1 must have traumatized people. Anyhoo, i will have look for a week soon and really dig in. Sadly, Sublime is a jealous lover :D
Eunice Park
@eunicode
May 10 2018 21:17

@cmccormack This is a late update, but thank you very much for explaining why the bitwise not operator works. This is what I understand from MDN: a bitwise operator changes a number/its operand to a binary representation, performs a binary operation, and then returns a number.

If minorWords.indexOf(word) === -1, the bitwise not changes the -1 to a 0, which is falsy.
But how did you bypass the "minorWords is not defined" message when no argument is given for that parameter?

Edit: nevermind. If no argument is given, it's undefined which is falsy.
Edit2: Wait, actually, I think that's where the default parameters come in?

CamperBot
@camperbot
May 10 2018 21:17
eunipa sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
api offline
Jefferson
@jeffersonnnn
May 10 2018 21:18
Star Wars viewing order: i shall find you and i shall watch you * in Liam Neeson voice
May 10 2018 21:19
I remember thinking star wars was all about jar jar binks and darth maul XD
I was to little to know what I was missing haha
Jason Luboff
@JLuboff
May 10 2018 21:19
@bradtaniguchi I'm not going to say I hated it. But I was quite disappointed. I wasn't able to watch it until it was available digitally, and while I had heard the hate...I tried to go into it with an open mind...but..it just..ugh..
May 10 2018 21:21
I liked it, it had its flaws but some of the hate it gets I disaggree with. (I liked what happened to Luke, it sucks, but I liked it haha)
I can see waiting like 30 years and end up being disapointed haha
Jason Luboff
@JLuboff
May 10 2018 21:23
Fuck man..I didn't wait 30 years but still. Here's my issues: In TFA, Poe is made out to be a very respectable pilot. In TLJ, he is made out to be a pompous, egotisitcal asshole with no respect for authority. The mary poppin's scene was fucking ridiclious. Many scenes that just didn't make sense.. I could go on but I don't want to upset myself further
May 10 2018 21:26
yes let the hate flow thru you :P. But in all seriousness Its a bummer Carrie Fisher pasted away, she was going to be key in episode 9 I guess. I think thats why they had her flying around in space, kinda a tease. But now that aint gonna happen :/
Jason Luboff
@JLuboff
May 10 2018 21:27
But... Leia was not anywhere near as strong in the force as Luke...if anything she was just force sensitive but not really a force user. However..I digress. It does me no good
May 10 2018 21:28
Well never know so it doesn't matter haha
Jason Luboff
@JLuboff
May 10 2018 21:30
Part of me is going off of now defunct expanded universe.. so.. I should probably forget everything I knew
May 10 2018 21:32
Yea I think thats another thing, its one thing if there was never an expanded universe so people have nothing to compare to, and years and years of all that stuff going against whatever comes out
Jason Luboff
@JLuboff
May 10 2018 21:32
sigh
Jason Luboff
@JLuboff
May 10 2018 21:48
I really hate when I know how to do something but I totally forget how..
May 10 2018 22:01
Thats me all the time
Jason Luboff
@JLuboff
May 10 2018 22:03
I'm just like "bruh...you're better than this"
Jason Luboff
@JLuboff
May 10 2018 22:35
I might be failing at programming right now..but my image server officially works lol so one fail one success..I'll take it
May 10 2018 22:45
:thumbsup:
I got thru the mess I made earlier, cleaning up the mess I made trying to get stuff to work, and fixing edge cases
Jason Luboff
@JLuboff
May 10 2018 22:56
:+1:
May 10 2018 23:00
Damn I freaken tired tho, and its too late for coffee :/
Jason Luboff
@JLuboff
May 10 2018 23:03
Don't you work until 8?
Bjorn van de Peut
@bjorno43
May 10 2018 23:05
Coffee doesn't help in the short run anyway. It takes time for coffee to kick in as it mostly relies on caffeine. Energy drinks work far better in the short run because of the sugar rush. And they don't last as long as coffee either :laughing:
Jason Luboff
@JLuboff
May 10 2018 23:09
I'd probably argue that energy drinks arent very good for you (not that coffee necessarily is either)
plus sugar crash aint no joke
Bjorn van de Peut
@bjorno43
May 10 2018 23:10
Absolutely true. But it works if you want to stay awake for another hour but able to crash after that
Jason Luboff
@JLuboff
May 10 2018 23:11
Fair enough
Bjorn van de Peut
@bjorno43
May 10 2018 23:14
I've got DSPS and some other sleeping issues. It's both a curse and a blessing. I can stay awake up to 3 / 4 days straight if I don't take my meds. My brain will cease to function more and more though, lol
Jason Luboff
@JLuboff
May 10 2018 23:14
That...that doesn't sound good lol
I can sleep a solid 8 hours and still feel tired..so I have that going for me... :joy:
Bjorn van de Peut
@bjorno43
May 10 2018 23:15
Ghehe no it's not. But on the other hand: I'll never need drugs :laughing: On the third day I start hallucinating like crazy xD
Jason Luboff
@JLuboff
May 10 2018 23:16
I donm't think I'd be too into that
Bjorn van de Peut
@bjorno43
May 10 2018 23:17
It's like you're dreaming. But your dreams mix themselves with the real world. Very, very strange
It's not as scary as you think. The difference with drugs is that you're very much aware what's real and what not
Jason Luboff
@JLuboff
May 10 2018 23:21
I'll take your word for it :D
Bjorn van de Peut
@bjorno43
May 10 2018 23:21
Haha
May 10 2018 23:29
:sake: :feelsgood:
come here :elephant:
const trash = :elephant: :snake: :gem:
Jason Luboff
@JLuboff
May 10 2018 23:31
@AdelMahjoub :wave: It's been a little while, how's it going?
May 10 2018 23:32
@JLuboff :wave: fine thanks, making a big tour of languages and game engines
CamperBot
@camperbot
May 10 2018 23:32
adelmahjoub sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2412 | @jluboff |http://www.freecodecamp.org/jluboff
May 10 2018 23:33
and I found the easiest language someone can learn http://www.lua.org/
the luanguage + the standard librairy could sit in a tiny little space in your head
Bjorn van de Peut
@bjorno43
May 10 2018 23:36
I'd go for Unreal engine though. It's completely free these days and you can use Javascript or C# I believe. Or Unity engine. Same thing
May 10 2018 23:36
and found the lord of rings ? https://haxe.org/
I prefer Godot
I'm familiar with composition/delegation learnign godot was fast
open source, completly free, run on linux, plenty of bugs, perfect
Bjorn van de Peut
@bjorno43
May 10 2018 23:38
I've got no exp with Godot. Unreal and Unity were the obvious choices for me cuz I've finished my master in C# :laughing:
May 10 2018 23:38
they added C# support for the v3
and c++ with gdnative
and .. Visual scripting, what a coincidence :laughing:
Bjorn van de Peut
@bjorno43
May 10 2018 23:39
lol
Jason Luboff
@JLuboff
May 10 2018 23:42
@AdelMahjoub What would you use Lua for?
May 10 2018 23:43
@JLuboff mostly for games using the Love2D framework, but it seems very popular for embedded
Bjorn van de Peut
@bjorno43
May 10 2018 23:43
Ok worst question of the day: "Why is my JS function not working when I call it with this button: <button onlclick='someFunction()' disabled> :laughing:
May 10 2018 23:44
@JLuboff and yeah Corona sdk, absolutly have to try sdk, you'll get surprised how easy you can write native mobile apps with it
Jason Luboff
@JLuboff
May 10 2018 23:45
Interesting
May 10 2018 23:46
it is promoted as a game engine but could be easily used for any kind of app
Bjorn van de Peut
@bjorno43
May 10 2018 23:46
I remember trying native mobile app development on Android back when android 3 was still a thing. When I realised I needed 40+ lines of code for a simple Hello World app, I cried in a corner for 5 minutes and gave up on it xD
May 10 2018 23:47
it depends on what you wnt to build but javascript + cordova is absolutly fine for a lot of apps
but also in the js world there is this really interesting framework
but, it state uses a framework without using a framework
Christopher McCormack
@cmccormack
May 10 2018 23:55
@bjorno43 onclick is spelled wrong?
Jason Luboff
@JLuboff
May 10 2018 23:56
I was figuring it was due to disabled but..ya.. misspelled onclick would also do it
Bjorn van de Peut
@bjorno43
May 10 2018 23:56
@cmccormack Ye sorry, that's just my mistake xD But ye, the issue was the button being disabled
Jason Luboff
@JLuboff
May 10 2018 23:59
:wave: See everyone tomorrow