These are chat archives for FreeCodeCamp/HelpJavaScript

4th
Nov 2018
Pagnito
@Pagnito
Nov 04 2018 03:34
so react.lazy() basically another code spltting way
ya seems so
Christopher McCormack
@cmccormack
Nov 04 2018 03:39
that's my understanding
makes sense don't want to load components that don't need to be loaded until they are needed
especially if, once loaded, they have to keep rendering somehow
Pagnito
@Pagnito
Nov 04 2018 03:49
so react.lazy() basically now replacing loadable?
oh i guess not yet
loadable works with ssr and lazy doesnt
Randell Dawson
@RandellDawson
Nov 04 2018 06:51

Any regex gurus who can lend a hand?

const regex = /^(?:\/)(first1(?:\/middle)|first2)(?:\/)(second1|second2)/
const path = '/first1/middle/second2/abc/xyz';
let matches = path.match(regex);
console.log(matches);

I am struggling with the above regex, because I don't practice them enough. I want the above code to display an array which looks like:

[ 'first1', 'second2' ]
chenqian
@M-cq
Nov 04 2018 10:45
arr.filter(d => d)
may i ask what does "(d=>d)" mean?
alpox
@alpox
Nov 04 2018 11:00
@M-cq Thats an identity function. basically a function which returns its only parameter
equivalent to:
function (d) {
  return d;
}
chenqian
@M-cq
Nov 04 2018 11:03
thank you so much
@alpox thanks
so can i write it as ```(d)=>{return d}
so can i write it as (d)=>{return d}
alpox
@alpox
Nov 04 2018 11:05
@M-cq You can if you want, yes. d => d is using shorthand notation
chenqian
@M-cq
Nov 04 2018 11:05
thank yo
chenqian
@M-cq
Nov 04 2018 11:14
function bouncer(arr) {



  return arr.filter(d => d);
} 

bouncer([7, "ate", "", false, 9]);
//return [7,"ate",9]
i wonder how it can get the result as [7,"ate",9]
Jefferson
@jeffersonnnn
Nov 04 2018 12:23
sigh. guys, help please? i am trying to feed the value of my textbox into my javascript function but i can't even get it to show up as an alert on my screen ffs. Can i get anyone look at the HTML and JS? Here is the code:
js
function submitMe() {
    var value = document.getElementById('test').value;
    alert(value);
}

html
<button onclick="submitMe('test')" id="testButton">here is where the magic happens!</button><br>
Markus Kiili
@Masd925
Nov 04 2018 13:13
@jeffersonnnn Are you linking the js at the end of body, or inside some document ready like event handler?
Lia-Sue-Kim
@Lia-Sue-Kim
Nov 04 2018 13:38
How long it takes to learn basics of JS
And for learning and practicing purpose where to find exercises for basic JS
Markus Kiili
@Masd925
Nov 04 2018 13:48
@Lia-Sue-Kim It depends what you include in JS. Basics can be learned quite fast, but things like objects, constructors and prototype chain takes a long time to really learn. Ajax and dom manipulation are also tough subjects. For me it took about two years to feel competent with all of those.
FCC has exercises for JS.
Jefferson
@jeffersonnnn
Nov 04 2018 13:55
@Masd925 if i understand your question, i have it in another tab. actually codepen.io
Lia-Sue-Kim
@Lia-Sue-Kim
Nov 04 2018 15:41
@Masd925 People teach the same thing differently. But video tutorials doesn't cover everything.
So I thought books are ok but there are different books only for JS
And it blows your mind if you follow different sources for the same thing
at the same time
Lia-Sue-Kim
@Lia-Sue-Kim
Nov 04 2018 16:56
Why can't we use plain English for programming?
Like "Hey Javascript please do this or that " or Hey PHP create a login system and enter lol
Christopher McCormack
@cmccormack
Nov 04 2018 17:10
That's declarative programming, it exists. Underneath it's still imperative because you still have to convert the logic into something the processor can actually use
I have a hard enough time telling family members how to get to my house, imagine a computer trying to understand your words. There are efforts to make this easier, I believe Wolfram is trying to make it so any data you need is easily accessed using simple commands
Daniele Tortora
@Floroz
Nov 04 2018 17:19
Hi, could you help in understanding why this is not working: "Declare and initialize a variable total to 0. Use a for loop to add the value of each element of the myArr array to total."
// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line
var total = 0;

for (var i = 0; i < myArr.length; i++) {
total += myArr[i];
}
Christopher McCormack
@cmccormack
Nov 04 2018 17:23
@Floroz this looks ok to me, are you supposed to return something from a function? Can you link the exercise?
Dany Din
@danydin
Nov 04 2018 17:24
someone can help me read short backend code?
Daniele Tortora
@Floroz
Nov 04 2018 17:24
@cmccormack I believe there was some sort of glitch on the text processor... as after grabbing a coffee and running it again.... it passed.
mystery of javascript
Christopher McCormack
@cmccormack
Nov 04 2018 17:25
@Floroz :thumbsup:
yeah could be
@danydin can try
please don't post in multiple channels at the same time though
Lia-Sue-Kim
@Lia-Sue-Kim
Nov 04 2018 17:25
I'm trying to understand where browser stores memory @cmccormack as variable for example if you write
let cars = 5;
or
var cars = 5;
Where it actually stores this memory or var ? I mean is it stored in hard drive or with the help of programming language it stores somewhere on the browser?
Christopher McCormack
@cmccormack
Nov 04 2018 17:26
The browser is an application, applications are assigned a certain amount of memory to use for storing these values
Dany Din
@danydin
Nov 04 2018 17:27
can we do it over the mic
Christopher McCormack
@cmccormack
Nov 04 2018 17:27
@danydin please delete that and post it in codepen or another online site
it also helps to only share the relevant code
Lia-Sue-Kim
@Lia-Sue-Kim
Nov 04 2018 17:28
Ok thank you
Where you truly understand things you are learning in programming ?
Christopher McCormack
@cmccormack
Nov 04 2018 17:29
@Lia-Sue-Kim there's more to it, I highly recommend reading up on computer architecture, it's fascinating
Lia-Sue-Kim
@Lia-Sue-Kim
Nov 04 2018 17:29
Do you have to understand how computers work
Ohh i see
Christopher McCormack
@cmccormack
Nov 04 2018 17:29
Not as much as you used to, but it doesn't hurt to have a good grasp on the fundamentals
@danydin Please use Codepen or Codesandbox when posting large amounts of code, because it disrupts the chat for everyone and could be considered spamming according to our Code of Conduct.
Dany Din
@danydin
Nov 04 2018 17:31
but i want to underrstand it over the mic @cmccormack
Christopher McCormack
@cmccormack
Nov 04 2018 17:32
@danydin that's fine but those are two different things. Hopefully someone here is willing to discuss over voice chat but you should ask first, and you still must share the code outside of the channel if it's going to be a large wall of code
Do you have any specific questions you would like to ask?
Dany Din
@danydin
Nov 04 2018 17:33
it wasnt large
i need to understand parts of the code
and it will take you long time write a porper explaiantion
Lia-Sue-Kim
@Lia-Sue-Kim
Nov 04 2018 17:37
@danydin If you can't get what you are typing it's better to watch again or read again tutorial that you are learning from
and then when you make a small whatever project or mini project you do. If you can't get the result you were expecting
ask people what how you did it and what you were expecting from the code and what you got as result
Dany Din
@danydin
Nov 04 2018 17:39
thats why i came here
but no one helps
Lia-Sue-Kim
@Lia-Sue-Kim
Nov 04 2018 17:40
That's how the University OF Michigan and others teach
Christopher McCormack
@cmccormack
Nov 04 2018 17:40
@danydin you expect people to get on a chat with you and you don't share your code in a way that is permitted, you have to volunteer something if you want help, everyone here is a volunteer
Pagnito
@Pagnito
Nov 04 2018 19:40
@cmccormack hey
Christopher McCormack
@cmccormack
Nov 04 2018 19:40
yo
Pagnito
@Pagnito
Nov 04 2018 19:40
do u use typescript?
Christopher McCormack
@cmccormack
Nov 04 2018 19:41
not yet
Pagnito
@Pagnito
Nov 04 2018 19:41
dang
gonna have to catch brad
as i remember hes a typescipt fanatic
Christopher McCormack
@cmccormack
Nov 04 2018 19:44
yup him and a couple others I think
Pagnito
@Pagnito
Nov 04 2018 19:44
worrd
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:20
@cmccormack Hey there
@Pagnito I use typescript if you have any questions
Christopher McCormack
@cmccormack
Nov 04 2018 20:21
@Giveback007 hey how's it going?
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:21
Oh you know, just trying to publish an npm package and trying to figure some stuff out
I miss this chatroom!
Christopher McCormack
@cmccormack
Nov 04 2018 20:22
haha come in more often then! some of us just leave it up at work as a welcome distraction :)
What package are you publishing?
I am trying to import it in another project and its a no go
so I'm trying to figure out how I need to make it noticable by other projects after the npm install <name>
Also I am looking for some remote work
Christopher McCormack
@cmccormack
Nov 04 2018 20:26
don't you need a package.json?
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:26
I have a package.json
Pagnito
@Pagnito
Nov 04 2018 20:26
@Giveback007 sweet thnx, i have a question, do u use https://github.com/Microsoft/TypeScript-React-Starter#typescript-react-starter?
i kind of want to set it up myself?
Christopher McCormack
@cmccormack
Nov 04 2018 20:27
I think you need a package.json and a main property in that file that points to the file to load, like index.js
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:27
@Pagnito I created a boilerplate creator just for that purpose
try it out
Christopher McCormack
@cmccormack
Nov 04 2018 20:27
that said I have never made my own package outside of tutorials so good luck :)
Pagnito
@Pagnito
Nov 04 2018 20:27
k
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:27
it's much simpler then the starter
everything works out of the box including redux and hot reloading
even install all the packages for you :)
Pagnito
@Pagnito
Nov 04 2018 20:29
sweet i appreciate it, ima look over and remake it myself cuz i always want to be able to know whats happening before i use other ppls boilerplates
so ur using babel to transpile ts?
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:29
Look at the pacage.json in the "copy-files" to get an idea
no that is for hot reloading
it keeps app state on code update
I'm using ts-loader
Christopher McCormack
@cmccormack
Nov 04 2018 20:30
@Giveback007 there isn't a copy-files that I see
Pagnito
@Pagnito
Nov 04 2018 20:30
ur data.json looks like a package.json
@Pagnito sorry you are right
i called it that way
to prevent a mix up
Pagnito
@Pagnito
Nov 04 2018 20:31
oh i didnt know u can rename package.json
i thought package was a keyword of sorts
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:32
this project takes the json and edits it
that json is not for this project

basically its a node.js project that will create a new project for you with everything installed.

And I will have a pacage.json for this project

ahh... I must be making it very confusing
Pagnito
@Pagnito
Nov 04 2018 20:33
lol
Christopher McCormack
@cmccormack
Nov 04 2018 20:34
how is npm going to know how to run a script? doesn't npm run just show you which scripts are available?
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:34
best you can do is download it and run it
Pagnito
@Pagnito
Nov 04 2018 20:34
i get it
run.js?
that one creates those files?
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:34
it's a node.js cli
Christopher McCormack
@cmccormack
Nov 04 2018 20:34
oh sorry node not npm
Pagnito
@Pagnito
Nov 04 2018 20:34
why did u choose to do it that way?
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:34
yeah it will create a folder for you
outside of this project
I like to do a lot of project
and it takes an hour to set up a new project
Christopher McCormack
@cmccormack
Nov 04 2018 20:35
I started doing something like this too, but it basically just overwrote package.json and the .git config
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:35
this does it in 2 mins and I can start coding
Christopher McCormack
@cmccormack
Nov 04 2018 20:35
but it was just a github repo
hope you get it working 100%
Pagnito
@Pagnito
Nov 04 2018 20:36
but cant u just make a boilerplates without running code to create files?
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:36
@Pagnito what do you mean?
ah yes, I wanted it to run all the comands on auto
Pagnito
@Pagnito
Nov 04 2018 20:36
like most boilerplates u clone and just run npm install and it doesnt create a package.json, the clone comes with it
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:37
like git init, npm intsall
Pagnito
@Pagnito
Nov 04 2018 20:38
so if i clones someones repo boilerplate that comes with a packge.json do i have to git init for it to be saved on my computer?
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:38
well, I guess different ways to do it
well, this allows me to create projects rapidly
Christopher McCormack
@cmccormack
Nov 04 2018 20:39
@Giveback007 you're trying to import it into another project? How does that work?
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:39
I never have to clone again
@cmccormack ah, we are having 2 conversations here
Pagnito
@Pagnito
Nov 04 2018 20:39
OOOOOOH
Pagnito
@Pagnito
Nov 04 2018 20:39
i get it
u just run that one command one ur computer
love it
Christopher McCormack
@cmccormack
Nov 04 2018 20:39
@Giveback007 oh that's why I was confused
I was referring to your first query earlier haha
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:40
@Pagnito yup, I guess I'm not very good at explaining/selling, but it sounds like the delivery was great :D
Pagnito
@Pagnito
Nov 04 2018 20:40
dude that is fckn genius
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:41
Pagnito
@Pagnito
Nov 04 2018 20:41
im gonna look over ur whole thing and redo my own version, even tho i dont have to, but i always want to know whats happening in my project\
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:41
also for rapid development
@Pagnito yes, I encourage it.
@Pagnito Look at my webpack file it has comments in it
Pagnito
@Pagnito
Nov 04 2018 20:41
@Giveback007 ok
Christopher McCormack
@cmccormack
Nov 04 2018 20:42
@Giveback007 will the git init wipe out the cloned git configuration?
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:42
@cmccormack for?
Christopher McCormack
@cmccormack
Nov 04 2018 20:43
@Giveback007 proxy-state
err
sorry other one
haha
TS thing
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:44
I am not sure
I think it will say that it is already initialized
@cmccormack why are you trying to do that anyways?
Christopher McCormack
@cmccormack
Nov 04 2018 20:45
I'm not doing anything
just asking as I saw it in your run.js
but how do you expect people to get your repo without cloning it?
when you clone I believe it comes with the .git no?
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:46
no when you run it it create a neighbor folder
so it never touches the original folder
so you can use this to rapidly create project after project
as fast as you can double click
Christopher McCormack
@cmccormack
Nov 04 2018 20:47
ah gotcha
didn't look too close
thanks
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:47
it even does the npm install for you git init and first commit
Capture.PNG
This is the main section
@cmccormack so what have you been up to?
it's been so long since we spoke
Christopher McCormack
@cmccormack
Nov 04 2018 20:53
@Giveback007 not much new, still trying to learn but still working my networking job
things are good though so no complaints
how is that place you're at? still there?
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:54
@cmccormack I quit prematurely, thinking I would find work quickly as full-time remote
I haven't landed anything yet
It's hard to prove personal capability with just one year of experience on a resume.
Christopher McCormack
@cmccormack
Nov 04 2018 20:56
yeah I hear ya
make sure you go through backchannels as well, many companies don't publically advertise their positions
at least not on job boards
but they may have their own
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:58
I'm a little down on the job application process atm.
Christopher McCormack
@cmccormack
Nov 04 2018 20:58
hit up USAA I know they're hiring like 4000 devs
Dovydas Stirpeika
@Giveback007
Nov 04 2018 20:58
wha...
I can't... my soul is drained
I need to find in person things
no degree and one year experience I get filtered by all the resume bots
Christopher McCormack
@cmccormack
Nov 04 2018 21:01
FCC has had the creator of https://cultivatedculture.com/ on a few of their podcasts. I know he's selling a product but he has some damn good advice
may want to find the podcasts at least
it's all about being aggressive in the search, not even using job boards
Pagnito
@Pagnito
Nov 04 2018 21:05
@Giveback007 u started coding a year ago?
Christopher McCormack
@cmccormack
Nov 04 2018 21:05
I have to run for a bit but keep your spirits up, keep applying, only way it's going to happen
Dovydas Stirpeika
@Giveback007
Nov 04 2018 21:05
@Pagnito I started working a year ago
@cmccormack tnx man
Pagnito
@Pagnito
Nov 04 2018 21:05
ah
Dovydas Stirpeika
@Giveback007
Nov 04 2018 21:05
@cmccormack see you around
Pagnito
@Pagnito
Nov 04 2018 21:36
we no longer need to config uglifyjs in webpack config right?
it comes with it in prod right?
Pagnito
@Pagnito
Nov 04 2018 22:40
@Giveback007 hey do u use typescript on the backend?
Dovydas Stirpeika
@Giveback007
Nov 04 2018 22:41
well I don't write a lot of back-end code, but ya I've done it
I avoided doing it in this projects simply because I wanted it to work with 0 dependencies
Pagnito
@Pagnito
Nov 04 2018 22:42
what do u mean?
Dovydas Stirpeika
@Giveback007
Nov 04 2018 22:43
well the project for generating a boilerplates
its a node.js project
it doesn't have any TS source code
Pagnito
@Pagnito
Nov 04 2018 22:43
ah
Dovydas Stirpeika
@Giveback007
Nov 04 2018 22:43
I wanted to be able to start it without needing to install anything
Pagnito
@Pagnito
Nov 04 2018 22:44
i feel u
in a sense if i use typescript in react, i dont really need to use propTypes, right?
Dovydas Stirpeika
@Giveback007
Nov 04 2018 22:44
https://github.com/Giveback007/AV-cms
here is a nodejs project i never finished that is using TS
you can get away with it
Pagnito
@Pagnito
Nov 04 2018 22:45
"target": "es6"
what does this mean
i thought that was supposed to be es5
Dovydas Stirpeika
@Giveback007
Nov 04 2018 22:46
its what version of JS your TS will compile in to
node can run on ES6
Pagnito
@Pagnito
Nov 04 2018 22:47
aah
Dovydas Stirpeika
@Giveback007
Nov 04 2018 22:47
where as its best to support ES5 for browsers
Pagnito
@Pagnito
Nov 04 2018 22:47
i see
Pagnito
@Pagnito
Nov 04 2018 23:58
@Giveback007 what are source maps