These are chat archives for FreeCodeCamp/HelpJavaScript

3rd
May 2018
JJ Megma
@megma_jj_twitter
May 03 2018 04:20
@Keggatron what are you have problem with?
Daniel Simeonov
@dbsimeonov
May 03 2018 05:03
:wave: morning
Dhaval Vira
@dhavalveera
May 03 2018 05:04
morning @dbsimeonov
Joseph
@revisualize
May 03 2018 05:28
Hello.
Markus Kiili
@Masd925
May 03 2018 05:30
Morning.
asumirio
@asumirioo
May 03 2018 07:11
Hello~
What is the best way to get start with vue.js?
Dhaval Vira
@dhavalveera
May 03 2018 07:13
you want to learn Vue.js ?
asumirio
@asumirioo
May 03 2018 07:13
Yeahhhh
Dhaval Vira
@dhavalveera
May 03 2018 07:13
try Udemy
asumirio
@asumirioo
May 03 2018 07:14
I tried that course by Maximilian, still confused 😭🌚
Dhaval Vira
@dhavalveera
May 03 2018 07:16
asumirio
@asumirioo
May 03 2018 07:17
Okay! Thank you 😊 😊
How do you find this frame?
Dhaval Vira
@dhavalveera
May 03 2018 07:18
@asumirioo which Frame ?
asumirio
@asumirioo
May 03 2018 07:18
vue.js
By comparing to others
Dhaval Vira
@dhavalveera
May 03 2018 07:18
I don't know, because I am still learning JavaScript
asumirio
@asumirioo
May 03 2018 07:19
Awww I see 😊
Dhaval Vira
@dhavalveera
May 03 2018 07:19
hm
Abhiinfo
@Abhiinfo
May 03 2018 09:31
Can anyone guide me on how to convert 24hrs new Date() format to 12 hrs format in js
Daniel Simeonov
@dbsimeonov
May 03 2018 09:35
Abhiinfo
@Abhiinfo
May 03 2018 09:43
@dbsimeonov is there any way to convert the whole datetime in 12 hrs format??
"Thu May 03 2018 03:08:20 GMT+0530 (India Standard Time)" this is the format I am looking for
Markus Kiili
@Masd925
May 03 2018 09:45
@Abhiinfo Did you try the toLocaleString method with 12h option set?
Daniel Simeonov
@dbsimeonov
May 03 2018 09:46
var time = new Date();
console.log(
  time.toLocaleString('en-US', { hour: 'numeric', hour12: true })
);
P.S Just found it on stackoverflow
Abhiinfo
@Abhiinfo
May 03 2018 09:46
Ok let me try this
Claudio Restifo
@Marmiz
May 03 2018 09:58
@Abhiinfo it's waaaaay easier to use a library when dealing with dates manipulation.
Moment.js or Luxon.js are the one that I know
Abhiinfo
@Abhiinfo
May 03 2018 09:59
Sure will try with that
SelinaXQ
@SelinaXQ
May 03 2018 14:30
Hi , I am working on "Seek and Destroy ". And I don't know why my code isn't right ? Could you please help me to find out?
Aditya
@ezioda004
May 03 2018 14:31
@SelinaXQ Can you post what you've attempted so far?
SelinaXQ
@SelinaXQ
May 03 2018 14:31

function destroyer(arr) {
// θ―·ζŠŠδ½ ηš„δ»£η ε†™εœ¨θΏ™ι‡Œ
var arr1 = arguments[0];
var arrDestroy = new Array();
for(var j = 0;j<arguments.length-1;j++){
arrDestroy[j] = arguments[j+1];
}
// return arrDestroy;

function destroyValue(value){
for(var i=0; i<arrDestroy.length;i++){
if(value!=arrDestroy[i]){
return value;
}

}

}

return arr1.filter(destroyValue);
//return arr.filter(destroyValue);
//return arguments[1];
}

destroyer([1, 2,5, 3, 1, 2, 3], 2, 3);

blob
blob
Nate Mallison
@NJM8
May 03 2018 14:33
Has anyone done udemy courses before? I can't figure out how to submit exercise code formatted.
SelinaXQ
@SelinaXQ
May 03 2018 14:36
the result is always arr1 or arguments[0]
Christopher McCormack
@cmccormack
May 03 2018 14:37
@SelinaXQ filter callback should return either true or false https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
@SelinaXQ you can paste your code formatted by surrounding your code in three backticks ``` on their own line:
```
Code
```
Ken Haduch
@khaduch
May 03 2018 14:42
@NJM8 = hi Nate - I have done some, but I'm not sure about submitting code? Which course are you taking? Are you trying to submit code into the chat room or somewhere else?
SelinaXQ
@SelinaXQ
May 03 2018 14:43
@cmccormack Thank u so much . I changed my code , but it can only detect the first parameter
CamperBot
@camperbot
May 03 2018 14:43
selinaxq sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1428 | @cmccormack |http://www.freecodecamp.org/cmccormack
Christopher McCormack
@cmccormack
May 03 2018 14:44
cookie bot is fixed!
SelinaXQ
@SelinaXQ
May 03 2018 14:44
blob
Christopher McCormack
@cmccormack
May 03 2018 14:44
@SelinaXQ put some console.log statements in at strategic points of your code, see what your variables are holding and make sure it matches with what you expect
SelinaXQ
@SelinaXQ
May 03 2018 14:45
blob
Nate Mallison
@NJM8
May 03 2018 14:46
@khaduch thanks I got it, it's the exercise code submission on complete Vue JS course, they just should adopt normal markdown formatting. you have to paste the code in, highlight it, then click the brackets button, but all indentation is lost. dumb.
CamperBot
@camperbot
May 03 2018 14:46
njm8 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3902 | @khaduch |http://www.freecodecamp.org/khaduch
Nate Mallison
@NJM8
May 03 2018 14:46
oh, it does indent it but not until you submit, weird
Christopher McCormack
@cmccormack
May 03 2018 14:46
@SelinaXQ also you may want to check out Array.prototype.indexOf
SelinaXQ
@SelinaXQ
May 03 2018 14:46
@cmccormack Ok , I will try again
@cmccormack Thank u so much!
CamperBot
@camperbot
May 03 2018 14:47
selinaxq sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
api offline
Ken Haduch
@khaduch
May 03 2018 14:47
@NJM8 - I just went into a course that I'm doing, and saw that same thing. If you make the indentations with spaces then they stay, it is unfortunate that it doesn't do tabs? But it looks like if you set up a code block then you can do tabs within it in the editor?
I wonder if you set up a bit of code (or some text,) highlight it and then paste your code into the code block that is in a grey box, if that will work?
Christopher McCormack
@cmccormack
May 03 2018 14:48
@SelinaXQ if you want to make your for loop work, you should only return false after the loop, not inside it, else you will never check more than the first item in the array
Nate Mallison
@NJM8
May 03 2018 14:48
yeah, I'm not spending a lot of time on it, I don't think anyone really looks at it. I got it to work with the code box so that's good enough. @khaduch
my first exercise input it stripped like half of the code out when I submitted it, and you can't edit it
SelinaXQ
@SelinaXQ
May 03 2018 14:52
@cmccormack OK, I got it.
Christopher McCormack
@cmccormack
May 03 2018 14:53
@SelinaXQ :thumbsup:
SelinaXQ
@SelinaXQ
May 03 2018 14:58
blob
@cmccormack I gave up the for loop and used indexOf . The problem is solved . Thank u again!
CamperBot
@camperbot
May 03 2018 14:59
selinaxq sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
api offline
Christopher McCormack
@cmccormack
May 03 2018 15:00
@SelinaXQ nice job! much less code, easier to read :)
SelinaXQ
@SelinaXQ
May 03 2018 15:02
@cmccormack yeah~ thank u :smile:
Danny Chan
@chandanny
May 03 2018 15:10
hello

Dear Danny,

We’re very happy to offer you a Bertelsmann Data Science Challenge Scholarship. We received applications from many talented and motivated candidates, but yours truly stood out.

i got it
Christopher McCormack
@cmccormack
May 03 2018 15:10
@chandanny congratulations!
Nate Mallison
@NJM8
May 03 2018 15:10
congrats Danny
Danny Chan
@chandanny
May 03 2018 15:10
@cmccormack @NJM8 thank you
CamperBot
@camperbot
May 03 2018 15:10
chandanny sends brownie points to @cmccormack and @njm8 :sparkles: :thumbsup: :sparkles:
:cookie: 427 | @njm8 |http://www.freecodecamp.org/njm8
:star2: 1429 | @cmccormack |http://www.freecodecamp.org/cmccormack
Danny Chan
@chandanny
May 03 2018 15:11
i am from asia
this is only one scholarship don't have resident required and i can apply it
i am still not believe i can got it
Christopher McCormack
@cmccormack
May 03 2018 15:12
Is it German?
Blauelf
@Blauelf
May 03 2018 15:33

Talking about https://www.udacity.com/bertelsmann-data-scholarships ?

Bertelsmann definitely is a powerful name in Germany. The Bertelsmann Stiftung umm... is not exactly well-received by all (see "Criticism" chapter). But, you know, best democracy money can buy.

Christopher McCormack
@cmccormack
May 03 2018 15:36
Interesting, thanks for the info
mstellaluna
@mstellaluna
May 03 2018 15:58
@chandanny congrats :clap:
I'm not sure you are aware but FCC has a data science room with amazing people in it here on gitter and a forum page too if you need help
chenqian
@M-cq
May 03 2018 17:07
var myStr=\ \t \b \r \n ; why it is not right? thanks for your help
Blauelf
@Blauelf
May 03 2018 17:10
You need " around to make it a string literal, like var myStr = "whatever goes into your string";. Not sure if it is the right string then, but now it isn't even a string.
Joseph
@revisualize
May 03 2018 17:29
I wonder if this recruiter lady is going to be mad at me.

Thank you for the additional information regarding this Office 365 Technical Support Analyst opportunity.
I have a few questions before I can evaluate an answer to your question.
What is the duration of the contract?
Is this a 1099 or a W-2 contract position?
The role description is quite lacking, do you have a more detailed description of this opportunity?

I've gathered a few salary options for W-2 roles within this same role spectrum:
https://www1.salary.com/WA/Seattle/Technical-Support-Analyst-III-salary.html
https://www1.salary.com/WA/Technical-Support-Analyst-III-salary.html
https://www1.salary.com/WA/Seattle/Technical-Support-Analyst-II-salary.html
https://www1.salary.com/WA/Technical-Support-Analyst-II-salary.html

What is market rate for an opportunity like this?

I look forward to hearing back from you regarding this opportunity.

Thanks for your time,

Nate Mallison
@NJM8
May 03 2018 17:34
tech support paying 90K? better know your product, haha
Gulsvi
@gulsvi
May 03 2018 17:58
@revisualize I think recruiters may respond better if you tell them your market rate and requirements
Joseph
@revisualize
May 03 2018 18:36
@NJM8 You have to look at the cost of living in an area. Would you want to make 50k living in Manhattan, Los Angeles? (Seattle is on par with LA costs. A 1 bedroom apartment is costing ~$2100 a month within 5 miles of downtown Seattle.)
Nate Mallison
@NJM8
May 03 2018 18:55
@revisualize Sure but you need to know your product better than the 10 people they can outsource your job to in other countries. I know all the ins and out about location, quality of service, etc etc, and a lot of that kind of service is coming back. Still, they aren't going to give you that off the bat. I bet that is 5-10 years of service
@cmccormack yikes
@cmccormack I guess it's a positive and a negative, yes you have a team of people trying to make things safe, but can they stay ahead of all the people trying to hack things
Christopher McCormack
@cmccormack
May 03 2018 19:00
@NJM8 there is always a tradeoff between security and convenience
Nate Mallison
@NJM8
May 03 2018 19:01
yes, and I assume if I wrote stuff myself for everything it would be super convenient, and not secure at all. haha
Christopher McCormack
@cmccormack
May 03 2018 19:07
Exactly
Joseph
@revisualize
May 03 2018 19:13
@NJM8 You're assuming that it is just a general technical support role. This is for a on-prem Microsoft Exchange migration to Office 365 and supporting 200+ users during the migration process. I've done a full on-prem to Office 365 migration.
@NJM8 I also have 15 years of IT Operations (Network Administration, Systems Administration, Help Desk, Tech Support and I ran an IT department of one... me.)
Mike Haslam
@Ongomobile
May 03 2018 20:30
Hello Groovy Guys and Gals
I am playing around with react in a stateful component
I am trying to figure out how to set the value of a number input to a value saved in state.
The reason I want the input to show this state is because I also want to implement a change event handler so a number could be manually implemented also.
Here is a codepen if anyone want to have a look https://codepen.io/Ongomobile/pen/bMReJg?editors=1111
Thanks for having a look
Christopher McCormack
@cmccormack
May 03 2018 20:51
@Ongomobile the idea of components is to have a hierarchy - make a generic top level component like <App /> where you can keep the state, and make each clicker a component. If you make them a component you can pass along the value you want as text for the button as well as the handler and you can reuse the component
your input should also be in a component, but you can also just keep it in App where your state lives if you want
if you insist on keeping it flat, you can use your handleChange to set the new state when a change occurs
Christopher McCormack
@cmccormack
May 03 2018 20:57
@Ongomobile not sure what youre doing in your increment/decrement but maybe try something simpler like
  decrement = () => {
    const { value } = this.state
    this.setState({ value: value > 0 ? value - 1 : value })
  }
Mike Haslam
@Ongomobile
May 03 2018 20:57
@cmccormack Thanks maybe I will be better off like you say jus was trying to wrap my head how this 1 component would work
CamperBot
@camperbot
May 03 2018 20:57
ongomobile sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1433 | @cmccormack |http://www.freecodecamp.org/cmccormack
Mike Haslam
@Ongomobile
May 03 2018 20:58
@cmccormack I will give that a try much better
Christopher McCormack
@cmccormack
May 03 2018 21:06
@Ongomobile and don't forget to update your value in your input change handler
  handleChange = (e) => {
   console.log('Handle change called')
    this.setState({value: e.target.value}) // <==
  }
Mike Haslam
@Ongomobile
May 03 2018 21:12
@cmccormack Thanks so if I understand you correctly destructor value from state then in the case of decrement method use a ternary to check if > 0 then decrement by 1 so would that mean I don't need qtyCount at all
CamperBot
@camperbot
May 03 2018 21:12
ongomobile sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
api offline
Christopher McCormack
@cmccormack
May 03 2018 21:25
@Ongomobile yes - you could use this.state.value but you're referencing it several times so I like to destructure first
@Ongomobile I didn't dig into why you were using qtyCount tbh
Mike Haslam
@Ongomobile
May 03 2018 21:32
What I am ultimately trying to accommplish is to have many of these components each will tally a quantity and save and display a sub total so for now just trying to get 1 working and figure out the architecture I have a working version in vanilla js
Mike Haslam
@Ongomobile
May 03 2018 21:46
Still not sure how to set the value of input?
Christopher McCormack
@cmccormack
May 03 2018 21:56
@Ongomobile you have a value attribute on your input with a value of this.state.value, if you want to change that value you have to update your state
state updates will propogate down to anything using that state
Mike Haslam
@Ongomobile
May 03 2018 21:56
Ok so would I call setState on that
Christopher McCormack
@cmccormack
May 03 2018 21:56
on what
Mike Haslam
@Ongomobile
May 03 2018 21:57
on the value of the input
Christopher McCormack
@cmccormack
May 03 2018 21:59
no you update state with your handlers. Your onChange should update state to reflect the new value entered, exactly how I showed you above :point_up: May 3, 2018 2:06 PM
Mike Haslam
@Ongomobile
May 03 2018 21:59
tried that
Christopher McCormack
@cmccormack
May 03 2018 21:59
e.target.value will provide the newly entered value if you do it by hand or with the up/down arrows
hold on let me reload your pen
value should not be a function, not sure why you added that
Mike Haslam
@Ongomobile
May 03 2018 22:01
COOL Ok I got it
Christopher McCormack
@cmccormack
May 03 2018 22:01
you already had most of the code just needed to update your handler
Mike Haslam
@Ongomobile
May 03 2018 22:02
what do you mean value as a function I just updated code
Christopher McCormack
@cmccormack
May 03 2018 22:02
yeah I see that but before you had a method - value={ () => ... }
doesn't matter looks better now
still some other bugs to work out but do you understand how state is set and updated now @Ongomobile ?
Mike Haslam
@Ongomobile
May 03 2018 22:06
A little more I will work on starting with a parent component thanks your help means a lot to me I am trying to wrap my head around how react actually works an not just spin up a. create react app
Christopher McCormack
@cmccormack
May 03 2018 22:07
state is probably the hardest part about react, understanding how to update it, how it propogates down, and how to modify parent state from a child
if you think of everything as a one way flow it helps - pass your state and handlers down as props, then use the handlers, bound to the parent that holds the state, to update state from the child
Mike Haslam
@Ongomobile
May 03 2018 22:08
I hope to get to redux and pure functions but have a long way to go
Christopher McCormack
@cmccormack
May 03 2018 22:08
in your example it's all in the same component so everything has the same scope, but it will be a little tougher when you break it apart
Not really, stateless functions are just normal functions that don't hold state or lifecycle methods
redux is something separate altogether though, I would probably recommend learning how to deal with state without it so you can see why you would want to use it
Mike Haslam
@Ongomobile
May 03 2018 22:09
I agree totally
so in this case my state would live in main component then be passed down to stateless components to display UI
Christopher McCormack
@cmccormack
May 03 2018 22:11
@Ongomobile you can take your current code and start breaking it out to components now to play with SFCs if you wanted, input could be one
Brad
@bradtaniguchi
May 03 2018 22:11
Not gonna lie, I still feel like "stage-management" is something that feels very fabricated
Christopher McCormack
@cmccormack
May 03 2018 22:11
@bradtaniguchi it's safer if you cant have components modifying it directly
I read something about Flux the other day as well that convinced me they needed it
@Ongomobile state should live in the lowest component that is parent to all children that need that state
Brad
@bradtaniguchi
May 03 2018 22:12
But like, how come theres so much going into state management, how does old apps (not just web applications, all applications) handle state?
Christopher McCormack
@cmccormack
May 03 2018 22:12
not necessarily the main component
@bradtaniguchi in a less safe way
if you wanted to you could just throw all your state in a single module but it could have side effects
Mike Haslam
@Ongomobile
May 03 2018 22:13
Cool I will give it a go
Brad
@bradtaniguchi
May 03 2018 22:14
state-management I feel like is a side-effect from having no side-effects haha. So like, if everything has no state (state-less-functions/state-less components or whaterver) then you need to handle the state somewhere else
Christopher McCormack
@cmccormack
May 03 2018 22:20
not every component requires it holds its own state, it instead depends on props handed down from parent
like a button doesn't need its own state but it may require a click handler passed down as a prop from a parent
Brad
@bradtaniguchi
May 03 2018 22:23
Yea that's fine, still not sure what's so great about redux still :/
Christopher McCormack
@cmccormack
May 03 2018 22:25
/shrug I still haven't used it
I believe the great part is not having to prop drill your state
and reducers allows you to shim functionality in too
Mike Haslam
@Ongomobile
May 03 2018 22:25
Is it that state lives in 1 place the store
Christopher McCormack
@cmccormack
May 03 2018 22:25
probably not useful for us noobs but maybe very useful for large sites
The store itself is just one piece
here I have a fun medium article one sec...
Mike Haslam
@Ongomobile
May 03 2018 22:26
actions dispatch
Christopher McCormack
@cmccormack
May 03 2018 22:26
and then read the follow up too
they did a really good job of making it easy to understand
Stephen James
@sjames1958gm
May 03 2018 22:27
@bradtaniguchi For small apps redux is not very useful.
I can see redux for application state, but still some components maintain very localized state.
Mike Haslam
@Ongomobile
May 03 2018 22:27
Thanks for the article
It's great so many ways to go and you can go your own way
Stephen James
@sjames1958gm
May 03 2018 22:28
@Ongomobile Sometimes it can be overwhelming trying to join the fray, too many options :)
Christopher McCormack
@cmccormack
May 03 2018 22:29
https://github.com/jamiebuilds/unstated Unstated seems pretty popular lately
Mike Haslam
@Ongomobile
May 03 2018 22:29
myself just trying to wrap my head around managing state
Christopher McCormack
@cmccormack
May 03 2018 22:29
@Ongomobile do it My suggestion is to use vanilla React until you get a handle on it at least
Redux uses Higher Order Components which can be pretty confusing itself
Mike Haslam
@Ongomobile
May 03 2018 22:30
@cmccormack that is exactly what I want to do
Christopher McCormack
@cmccormack
May 03 2018 22:32
And you can always ask @sjames1958gm when you need help :D
Mike Haslam
@Ongomobile
May 03 2018 22:33
Thanks
Christopher McCormack
@cmccormack
May 03 2018 22:33
I'm just kidding you can ask in here and someone will probably be around
Mike Haslam
@Ongomobile
May 03 2018 22:34
I thought that was the case ha ha
Cool
Christopher McCormack
@cmccormack
May 03 2018 22:34
Oh I forgot, latest React has the Context API for managing state as well
Stephen James
@sjames1958gm
May 03 2018 22:36
I think the latest Redux is using the Context API
Christopher McCormack
@cmccormack
May 03 2018 22:37
@Ongomobile here is an example project I made to show state passing down to children. I made it for those new to React, hopefully it's helpful
@sjames1958gm does it still use HOCs?
I remember reading something like that but wasn't sure if they also changed the syntax
Stephen James
@sjames1958gm
May 03 2018 22:37
@cmccormack I can't say for sure, but I think the API is the same so it would still use connect HOC
Christopher McCormack
@cmccormack
May 03 2018 22:41
I guess it isn't all that bad when you get used to it, but I keep reading all the love for render props and increased dislike with HOCs so I wonder if they'll change it
Christopher McCormack
@cmccormack
May 03 2018 22:59
@Ongomobile I gave you some bad advice earlier - when you're using previous state in your setState you should use the functional form. setState is asynchronous so if you try to use current state you may be using the incorrect value. https://reactjs.org/docs/state-and-lifecycle.html#state-updates-may-be-asynchronous
Mike Haslam
@Ongomobile
May 03 2018 23:02
@cmccormack I see I will try and wrap my head around that is that to avoid mutation?
anthonygallina1
@anthonygallina1
May 03 2018 23:03
Hi
Mike Haslam
@Ongomobile
May 03 2018 23:04
Hi @anthonygallina1
Christopher McCormack
@cmccormack
May 03 2018 23:05
@Ongomobile state updates are done in batches, so I assume if you had more than one update to the same state property, subsequent updates would use that new value instead of previous state
if you depend on previous state it could mess stuff up. I've never had the issue but it's good to know
anthonygallina1
@anthonygallina1
May 03 2018 23:07
@cmccormack thanks for the example. Well commented too :)
CamperBot
@camperbot
May 03 2018 23:07
anthonygallina1 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1434 | @cmccormack |http://www.freecodecamp.org/cmccormack
Christopher McCormack
@cmccormack
May 03 2018 23:07
@anthonygallina1 thanks :)
anthonygallina1
@anthonygallina1
May 03 2018 23:08
:thumbsup:
I didnt know you guys did React. I try to do React :( I studied with Cory etc. I love it. But seems it should be easier after a few years. Might be the keyboard to chair interface problem here.
:)
Conor Murphy
@cmurphy580
May 03 2018 23:14

i'm trying to compile my react file, but its not compiling. I'm stuck with this is in my terminal:

 ~/Desktop/Projects/Google Image Animation ξ‚° ξ‚  master ξ‚° npm start

> redux-simple-starter@1.0.0 start /Users/CMurphy/Desktop/Projects/Google Image Animation
> node server.js

has anyone had this issue?

anthonygallina1
@anthonygallina1
May 03 2018 23:15
emojis ?
Conor Murphy
@cmurphy580
May 03 2018 23:22
could it be a server.js problem
anthonygallina1
@anthonygallina1
May 03 2018 23:30
@cmurphy580 Iwas doing a task bar emoji the other day I think saw some thing similar in node. Trying think of my work around.