These are chat archives for FreeCodeCamp/HelpJavaScript

7th
Feb 2018
Keggatron
@Keggatron
Feb 07 00:34
Hi guys, I'm having an issue with my React app. I'm relatively new to React/Redux so I'm not entirely sure of what I'm doing. Anyway I have a component that is getting props from a reducer, however I'm unable to call those props from outside of the render function. Does this make any sense? Does anyone know what may be the cause of that?
Here's the code:
class ProductNew extends Component {
  renderProductField(field) {
    const { meta: { touched, error} } = field
    const className = `form-group ${touched && error ? 'has-danger' : ''}`

    return (
      <div className={className}>
        <label>{field.label}</label>
        <input 
          className="form-control"
          type="text"
          {...field.input}
        />
        <div className="text-help">
          {touched ? error : ''} 
        </div>
      </div>  
    );
  }

  onSubmit(values) {
    console.log(values);
  }

  render() {
    const { handleSubmit } = this.props;


    return (
       <div>{console.log(this.props.product)}</div>
)
}
function mapStateToProps({ newProduct }, ownProps) {
  return { product: newProduct[0][0] };
}

export default reduxForm({
  validate,
  form: 'ProductNewForm'
})(
  connect(mapStateToProps, { barcodeSearch })(ProductNew)
);
Christopher McCormack
@cmccormack
Feb 07 00:37
@Keggatron where are you trying to call it outside the render function?
Keggatron
@Keggatron
Feb 07 00:42
sorry I commented that out
give me a second
So I want it to be called in the renderProductField function
Keggatron
@Keggatron
Feb 07 00:48
basically I want the props coming back from my reducer to be available for use in a form to add a new product with that info
Christopher McCormack
@cmccormack
Feb 07 00:50
I may not be able to help as I still haven't bothered to actually implement redux but was hoping I could spot any issues any how
you should show what isn't working
Stephen James
@sjames1958gm
Feb 07 01:35
@Keggatron Are you making sure you have an initial state that is compatible with what you are trying to do here?
Your initial rendering will have the initlal state
Tiago Correia
@tiagocorreiaalmeida
Feb 07 10:16
good morning guys
Markus Kiili
@Masd925
Feb 07 10:16
@tiagocorreiaalmeida Morning.
Sweet Coding :)
@SweetCodingInc
Feb 07 10:57

Folks.. I could use some help... I've applied for a job interview and I have been given this task as an assignement. Based on which the recruitment process would proceed.
This is similar to wikiviewer project on fcc. Just run it and try to fuck it up.
Note: styling is not considered in assessment (including responsiveness)
Help me find out cases where it would break

https://sweetcodinginc.github.io/FCCWikiViewer/#

Zunaid Aslam
@Zunaid-Aslam
Feb 07 13:41
Hello guys,
Can you check this link out? I am having problem understanding the problem. I actually solved it accidentally lol . Please go through the forum question and you will understand. It's about the Mutations question.
https://forum.freecodecamp.org/t/stuck-at-basic-algorithm-challenge-mutations/173307
Zunaid Aslam
@Zunaid-Aslam
Feb 07 13:49
What is the difference between these two codes?
function mutation(arr) {
  var lCap = [];
  for (var i=0; i<arr.length; i++){  
    lCap[i]=arr[i].toLowerCase();
  }
  var split = lCap[1] ;
  for (var j=0; j<lCap[1].length; j++) {
   if (lCap[0].indexOf(split[j]) < 0)   
     return false;
}
   return  true;  
}
mutation(["hello", "hey"]);
function mutation(arr) {
  var lCap = [];
    for (var i=0; i<arr.length; i++){
    lCap[i]=arr[i].toLowerCase();
  }
  var split = lCap[1] ;
    for (var j=0; j<lCap[1].length; j++) {
   if (lCap[0].indexOf(split[j]) > 0)   
    return true; 
}
   return  false;  
}
mutation(["hello", "hey"]);
Nate Mallison
@NJM8
Feb 07 13:50
Inside of your for loop j, place a console.log(lCap[0].indexOf(split[j]));
So that you can see what that code is returning at each iteration
Zunaid Aslam
@Zunaid-Aslam
Feb 07 13:50
It gives -1 for hello and hey which is false
Hmm, I am doing it in freecodecamp site. I will try console log and see
I just changed the sign and logic of true/false and the cod doesn't work for all. Even though it supposed to work.
Nate Mallison
@NJM8
Feb 07 13:51
ok, I don't remember if that will work or not, it may log it in your browsers log
Zunaid Aslam
@Zunaid-Aslam
Feb 07 13:52
I will try in chrome - console
First one solved the problem
Second solve many except for 3.... it didnt solve hello and hey
Nate Mallison
@NJM8
Feb 07 13:53
Yes, so I think what you want to learn to understand is what happens when you look for the index of 'L' in 'hey'
Tiago Correia
@tiagocorreiaalmeida
Feb 07 14:40
hey @cmccormack
yesterday readed around you found an hosting service for 5 dolars where you could host node projects?
Nate Mallison
@NJM8
Feb 07 14:42
@tiagocorreiaalmeida I think he was talking about DigitalOcean
I'm using Heroku, free so far. :smile:
Christopher McCormack
@cmccormack
Feb 07 14:43
Yup digital ocean
You can also host free on glitch.me
I wanted something that stays up indefinitely and let's me use my own domain though
Nate Mallison
@NJM8
Feb 07 14:50
Yeah there are definitely pluses and minuses to both
Tiago Correia
@tiagocorreiaalmeida
Feb 07 15:24
@cmccormack the idea is keep it up all the time :D , you can set a start script as in glitch/heroku or things are different there?
Christopher McCormack
@cmccormack
Feb 07 15:44
@tiagocorreiaalmeida I believe you can setup a process manager and set your node js file to run all the time, even start back up if the server gets rebooted or whatever. It's just an ubuntu (or whichever VM you chose) box so you have to do the work yourself, but I've found the guides really useful. https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04
Tiago Correia
@tiagocorreiaalmeida
Feb 07 15:44
will give it a look thanks @cmccormack
CamperBot
@camperbot
Feb 07 15:44
tiagocorreiaalmeida sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1306 | @cmccormack |http://www.freecodecamp.org/cmccormack
Christopher McCormack
@cmccormack
Feb 07 15:44
np
Tiago Correia
@tiagocorreiaalmeida
Feb 07 15:45
I think finally will try out the framework you mentioned, materialize I like their designs
Christopher McCormack
@cmccormack
Feb 07 15:47
It's great design but I'm not certain about the react version of it, I tried it out and it was a pain to get it to work the way I wanted, but it may be easier now, not sure
I'm still just using the css library in my react apps for now
Tiago Correia
@tiagocorreiaalmeida
Feb 07 15:48
hum I saw this yesterday https://react-materialize.github.io/#/
not sure if would help
Christopher McCormack
@cmccormack
Feb 07 15:52
same concept, these are pretty simple components so when I want to make changes it's actually much more difficult than if I just create my own wrappers with the className specified from the CSS library
but for quick projects I bet it's really great to use
Tiago Correia
@tiagocorreiaalmeida
Feb 07 16:01
in what parts did you had problems? just to get an idea
Christopher McCormack
@cmccormack
Feb 07 16:08
Just extending components can be difficult, that's all. Using it as-is is fine
Jason Luboff
@JLuboff
Feb 07 16:12
:wave:
Christopher McCormack
@cmccormack
Feb 07 16:12
@JLuboff yo what it is
Jason Luboff
@JLuboff
Feb 07 16:12
Tired..lol you?
Christopher McCormack
@cmccormack
Feb 07 16:14
Same, got up too early and went to the gym and I'm already out of energy for the day
but I shouldn't complain, I don't have a little baby waking me up all night :D
Jason Luboff
@JLuboff
Feb 07 16:16
I can't do the gym early in the morning, I like going in the evenings
Christopher McCormack
@cmccormack
Feb 07 16:17
Too many people at that time, can't get the equipment I want as easy :D
Jason Luboff
@JLuboff
Feb 07 16:17
given, if I was to do the gym in the morning I'd have to get up at like 4:30 since I'd have to go back home after (the showers at the gym is just one big open communial shower..I aint down for that)
Eh... I get there around 7, so people start clearing out around then but ya, sometimes it can be a pain
Christopher McCormack
@cmccormack
Feb 07 16:21
I bet, especially since you have to go to the office, I usually get to just go home afterward and work from home :)
Jason Luboff
@JLuboff
Feb 07 16:21
Well la de da, mr. fancy pants over here
Hell, I bet you aren't even wearing pants!
Christopher McCormack
@cmccormack
Feb 07 16:22
it's a bit cold up here so I am today :p
but many days it's sweatpants and a t-shirt
Jason Luboff
@JLuboff
Feb 07 16:24
Lucky. Given, my dress code isn't really strict but I still like to have a collar (polo or button down shirt but no dress shirts)
Christopher McCormack
@cmccormack
Feb 07 16:25
I'm hoping for the day my wife gets a remote job as well so we can sell our houses and live the digital nomad life
Jason Luboff
@JLuboff
Feb 07 16:26
sell our houses mean while over here...I can only dream of a single home
Christopher McCormack
@cmccormack
Feb 07 16:26
bought during the recession, it was a good time for us
hoping one day to have many that we rent out for some decent income
Markus Kiili
@Masd925
Feb 07 16:27
@JLuboff I work in an office wearing shorts and sandals all year.
Jason Luboff
@JLuboff
Feb 07 16:28
I imagine pricing is a bit lower over there too. For a shitty condo, you're looking at a minimum of $250,000 here. Anything semi-nice for condo/townhome is going to be $350,000+. Single framily home, if you're lucky, $450,000
@Masd925 I thought Finland is cold
Markus Kiili
@Masd925
Feb 07 16:28
Only outside the house is cold.
Christopher McCormack
@cmccormack
Feb 07 16:29
@JLuboff that really is nuts. The house we bought in Scottsdale has now more than doubled, but is still less than a single family home in your area it looks like
Markus Kiili
@Masd925
Feb 07 16:30
@JLuboff I am trying to find a new job and the greatest challenge will be wearing pants and a fancy shirt.
Jason Luboff
@JLuboff
Feb 07 16:31
@cmccormack Yup. Our goal is still to try and buy something closer to the end of the year so long as we can have enough saved for at least 3.5% (obiviousily more is better, but thats not going to happen)
Tiago Correia
@tiagocorreiaalmeida
Feb 07 16:31
if I had a job where I could use shorts and sadals all year I wouldnt be looking for nothing new @Masd925 :D
Jason Luboff
@JLuboff
Feb 07 16:31
@Masd925 Ya, I'd love to wear shorts to work. I have in past jobs but this one is slightly above allowing that
Christopher McCormack
@cmccormack
Feb 07 16:32
This is going to sound dumb but I actually miss wearing nice clothes to the office. I had a whole bunch of nice stuff and now I have no occassion to wear it :sob:
Markus Kiili
@Masd925
Feb 07 16:33
I actually wear shorts at home too, so I am quite anti-pants.
Jason Luboff
@JLuboff
Feb 07 16:34
I wear shorts at home all the time. Usually no shirt either.
Markus Kiili
@Masd925
Feb 07 16:35
Yeah. Nature has perfected the male body, so why not show it to everybody.
Christopher McCormack
@cmccormack
Feb 07 16:35
haha
Jason Luboff
@JLuboff
Feb 07 16:35
I concur
Sweet Coding :)
@SweetCodingInc
Feb 07 16:35
/ me made a firm decision to never visit finland
Markus Kiili
@Masd925
Feb 07 16:37
:(
Jason Luboff
@JLuboff
Feb 07 16:40
So whats everyone working on today?
Sweet Coding :)
@SweetCodingInc
Feb 07 16:41
Real time restify chat server with typescript and rxjs observables
Jason Luboff
@JLuboff
Feb 07 16:41
Sounds nifty
Markus Kiili
@Masd925
Feb 07 16:41
Thinking about an app that would show nearest leaving busses. I think I have the tools ready.
Jason Luboff
@JLuboff
Feb 07 16:42
@Masd925 You were thinking about that like 2 weeks ago
Markus Kiili
@Masd925
Feb 07 16:42
@JLuboff I am Human being, not Human doing.
Jason Luboff
@JLuboff
Feb 07 16:43
True..it did take you years to do the tribute and portfolio projects :P
Markus Kiili
@Masd925
Feb 07 16:44
Does anyone else wan't to beat me mentally. @JLuboff has warmed me up.
;)
Jason Luboff
@JLuboff
Feb 07 16:44
:joy:
All in good fun
Markus Kiili
@Masd925
Feb 07 16:45
Actually I had to do some research on the subject, because the bus info api docs are not too good.
Jason Luboff
@JLuboff
Feb 07 16:48
I find most API's docs to be..lacking..
Or my favorite as of late.. Node modules.
Christopher McCormack
@cmccormack
Feb 07 16:57
My company is hosting a ReactJS meetup in Tempe AZ on Feb 21 if anyone is interested in flying in :)
Jason Luboff
@JLuboff
Feb 07 16:57
@cmccormack You paying airfare? ;)
Christopher McCormack
@cmccormack
Feb 07 16:57
I'll give $0.02USD
Jason Luboff
@JLuboff
Feb 07 16:57
eh.. It's only a 6.5 hour drive
Christopher McCormack
@cmccormack
Feb 07 16:58
totally worth it, and I'll take you out to the bars on Mill Ave afterward
You could even crash in my spare room if you wanted
haha
I probably have enough room for a bunch of people if they don't mind sleeping on the couch/floor
Jason Luboff
@JLuboff
Feb 07 16:59
I don't know that my wife would let me go lol Not to mention its on a wednesday
Christopher McCormack
@cmccormack
Feb 07 16:59
I have an empty enclosed garage and I've thought about putting a bunch of bunk beds in there and calling it an incubator
I'll just happen to be in town for another meeting that day I have to attend so it works out perfect for me, but let me know if you decide to go! 6.5 hours isn't all that bad haha
Jason Luboff
@JLuboff
Feb 07 17:00
Are you going to change your name to Erlich Bachman?
Christopher McCormack
@cmccormack
Feb 07 17:01
Bachmanity
Jason Luboff
@JLuboff
Feb 07 17:02
:+1:
Muhammad Hasham
@MohammadHasham
Feb 07 18:56
can i make the backend projects locally and then deploy them? is it fine?
Christopher McCormack
@cmccormack
Feb 07 18:57
@MohammadHasham you should be able to as long as where you deploy will match your local env
Muhammad Hasham
@MohammadHasham
Feb 07 18:58
@cmccormack okay thanks
CamperBot
@camperbot
Feb 07 18:58
mohammadhasham sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1308 | @cmccormack |http://www.freecodecamp.org/cmccormack
Jason Luboff
@JLuboff
Feb 07 18:58
You can push to github then use either heroku or glitch to import from github (or you can use heroku cli but I don't care for it)
Christopher McCormack
@cmccormack
Feb 07 19:01
glitch is super fast and pretty simple
Jason Luboff
@JLuboff
Feb 07 19:02
I like Heroku's import feature over glitch's but I like glitch's built in text editor and have had less deployment issues with glitch
Christopher McCormack
@cmccormack
Feb 07 19:03
only thing I want to touch on either platform is the .env file if I'm already using github
that's why I like glitch so far
I haven't used Heroku in a long time though so I may be forgetting the process
Jason Luboff
@JLuboff
Feb 07 19:04
I like the text editor for the sake of making a small change I don't have to change locally, test, push to github, go into glitch, import ,etc
heroku is nice that it will auto- redeploy when your github repo is updated
Christopher McCormack
@cmccormack
Feb 07 19:06
@JLuboff definitely want to use branches then if it's going to update automatically!
Jason Luboff
@JLuboff
Feb 07 19:06
...I've never really used branches :(
I mean..I understand them..but
Christopher McCormack
@cmccormack
Feb 07 19:06
hmm maybe I'll try my webapp on heroku right now so I can see the results every night I push
@JLuboff not AS useful by yourself
I used to use them when working on a specific feature but now I'm lazy
Jason Luboff
@JLuboff
Feb 07 19:08
Oh well..I'm super lazy..so..
Christopher McCormack
@cmccormack
Feb 07 19:09
haha
Jason Luboff
@JLuboff
Feb 07 19:12
You ever get tired of typing while coding?
Brad
@bradtaniguchi
Feb 07 19:16
^no, my hands get their work-in 24/7. I like typing in general haha
@JLuboff
Christopher McCormack
@cmccormack
Feb 07 19:16
Typing, no, fixing formatting - yes. I wish I knew all the keyboard shortcuts
Jason Luboff
@JLuboff
Feb 07 19:16
Maybe I need an ergo friendly keyboard then
Christopher McCormack
@cmccormack
Feb 07 19:17
posture can make a big difference as well
Brad
@bradtaniguchi
Feb 07 19:17
@JLuboff I like all the keyboards I type in, they all have their own interesting qualities. I lucked out with my laptop tho, its keyboard is pretty fun (or so I have been told by others)
@cmccormack Yes definantly, especially if you want to do it for a while (#1 bad thing is using a laptop for work)
Jason Luboff
@JLuboff
Feb 07 19:18
@cmccormack I try to keep a good posture but..eh
Christopher McCormack
@cmccormack
Feb 07 19:18
@bradtaniguchi I do work on my macbook pro all the time and it's one of my favorite keyboards
2013, I hate the current model keyboard (I have one from work)
Brad
@bradtaniguchi
Feb 07 19:19
Laptops are bad (mac or not) for posture, main thing is your looking down all the time (you either slouch or strain your neck)
Christopher McCormack
@cmccormack
Feb 07 19:20
ah you meant for general posture, not just for arms/hands
Brad
@bradtaniguchi
Feb 07 19:21
Yea, Id say your wrists and neck are the most vulnerable if your at a deskjob. Laptops aren't good for either
Christopher McCormack
@cmccormack
Feb 07 19:23
I saw an ad on facebook for a product that you put on your back between your shoulder blades and it vibrates if you slouch. It looks super dorky but is probably pretty good for enforcing good bahavior
Brad
@bradtaniguchi
Feb 07 19:26
Sounds like it could be a spike or some torture device haha
Kelechi Chinaka
@ke1echi
Feb 07 19:30
your katas left beta quickly @Chrono79
Jason Luboff
@JLuboff
Feb 07 19:30
Who doesn't like to be tortured while working?
Kelechi Chinaka
@ke1echi
Feb 07 19:33
good lessons learnt too @Chrono79
Diego Mayer
@Chrono79
Feb 07 19:34
:+1:
@JLuboff For a year or more, we had a building in progress next to the office, and given how they used the drill, I think it was sculpted from a single block
Jason Luboff
@JLuboff
Feb 07 19:36
:joy:
Kelechi Chinaka
@ke1echi
Feb 07 19:44
what are you working on now @JLuboff
Christopher McCormack
@cmccormack
Feb 07 19:45
he's slackin
Tiago Correia
@tiagocorreiaalmeida
Feb 07 19:45
so I was going to use express-validator to make it easier to validate data when making an api
but Im finding this got get a bit big and ugly I would say
:D
to*
Christopher McCormack
@cmccormack
Feb 07 19:45
@tiagocorreiaalmeida I'm using that right now too, it's not so bad
you could just create a separate module for your validation
Jason Luboff
@JLuboff
Feb 07 19:46
@kelechy This weeks goals are: Deploy my C# fleet management application to the company (requires modifying the current database and a few small changes along with installing on individuals computers who use it). At the moment updating my conference room sign to use node and mongo to store the meetings (as opposed to IIS and PHP which doesn't work half the time). Then going to continue to work on a project for requests that is a new application for work
@cmccormack :angry:
Tiago Correia
@tiagocorreiaalmeida
Feb 07 19:46
I mean its great on the part that does all that I atualyl need it to do still a bit strange the amount of line of codes this will create me :D
Christopher McCormack
@cmccormack
Feb 07 19:46
you mean after it's transpiled?
Kelechi Chinaka
@ke1echi
Feb 07 19:47
:smile: thats alot @JLuboff
Jason Luboff
@JLuboff
Feb 07 19:47
@kelechy What about you?
Tiago Correia
@tiagocorreiaalmeida
Feb 07 19:47
router.post(
    "/",
    auth,
    [
        body("title")
            .trim()
            .isLength({ min: 4 })
            .withMessage("invalid-title-length"),
        body("review")
            .trim()
            .isLength({ min: 140 })
            .withMessage("invalid-review-length")
    ],
    async (req, res) => {}
);
I mean the amount of lines I will have if I need 2 validate like 10 fields
Kelechi Chinaka
@ke1echi
Feb 07 19:48
i am taking cs50 after school hours @JLuboff
Jason Luboff
@JLuboff
Feb 07 19:48
Nice, how's that?
Christopher McCormack
@cmccormack
Feb 07 19:49
@tiagocorreiaalmeida yeah but normal validation can be huge as well, and involve regex and other ugly code
Tiago Correia
@tiagocorreiaalmeida
Feb 07 19:49
yeah Im just thinking that this is the correct way of going?
Kelechi Chinaka
@ke1echi
Feb 07 19:49
alot of C code to fry the brain :smile: but am determined to put the effort @JLuboff
Jason Luboff
@JLuboff
Feb 07 19:50
@cmccormack @tiagocorreiaalmeida Purpose of express-validation for testing or for production?
@kelechy Thats a good attitude!
Tiago Correia
@tiagocorreiaalmeida
Feb 07 19:51
@JLuboff my idea was for production since this is gona be an api that I will make calls to
Christopher McCormack
@cmccormack
Feb 07 19:51
@tiagocorreiaalmeida it's working pretty well for me, It's a great syntax for validating. I still have to do a little validation within my mongo models but not too bad
Tiago Correia
@tiagocorreiaalmeida
Feb 07 19:52
I used to send standard messages to the client
Kelechi Chinaka
@ke1echi
Feb 07 19:52
thanks @JLuboff .. i hope to learn alot from the course
CamperBot
@camperbot
Feb 07 19:52
kelechy sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2322 | @jluboff |http://www.freecodecamp.org/jluboff
Tiago Correia
@tiagocorreiaalmeida
Feb 07 19:52
but maybe this time is better allready send the full msg from the back to front to avoid a switch later on
Yeah I looked at your github code a few seconds ago @cmccormack and I completly get the idea
Christopher McCormack
@cmccormack
Feb 07 19:52
@JLuboff it's middleware that handles some properties of req like body and lets you add simple chained validations
Tiago Correia
@tiagocorreiaalmeida
Feb 07 19:53
by tht I mean
go from this invalid-title-length
to this
The title minium length is 4 characters!
Christopher McCormack
@cmccormack
Feb 07 19:53
@tiagocorreiaalmeida oh that code is a bit of a mess right now, I've been trying to figure out how to add pre save validation to my models
Jason Luboff
@JLuboff
Feb 07 19:53
@cmccormack So production level then..?
Christopher McCormack
@cmccormack
Feb 07 19:54
@JLuboff yeah
@tiagocorreiaalmeida I don't understand, why not just change the message?
maybe I'm just not following what you're trying to do
Tiago Correia
@tiagocorreiaalmeida
Feb 07 19:55
I allready did sorry I talk alot that's why things get confusing, either way with all this validation the good part is that in post and others request after check that there's no errors
I can save it directly since it comes with the named database fields
so req.body contains the keys values that I need will make the response cleaner
        let post = {
            ...req.body
        };
Christopher McCormack
@cmccormack
Feb 07 20:00
@tiagocorreiaalmeida let me know if you come up with some neat tricks! I'm just now getting my head wrapped around some of this stuff
Tiago Correia
@tiagocorreiaalmeida
Feb 07 20:01
same here just coding and facing new issues to learn with them
I was like im gonna really validate 10 req.body fields one by one? and then started searching
Christopher McCormack
@cmccormack
Feb 07 20:02
Maybe you have too many fields :)
I was trying to make customSanitizers yesterday but had 0 luck with that - I feel like the documentation is kind of crap for some of this stuff
Tiago Correia
@tiagocorreiaalmeida
Feb 07 20:08
ahahaha could be the case but based on the subject they are atually quite few :D, hum didnt get quite the final idea of what you were trying to directly do, but if you give me an example maybe I can help
Christopher McCormack
@cmccormack
Feb 07 20:10
I wanted to make a custom sanitizer that isolated only unique choices from the submitted array. Thought it would look cleaner to do that in a sanitizer in the validation middleware than in the endpoint callback function
Tiago Correia
@tiagocorreiaalmeida
Feb 07 20:11
you mean a function that would validate data that comes in the request?
Christopher McCormack
@cmccormack
Feb 07 20:11
no sanitize
custom validators are easy
I use these as they are built in:
    sanitizeBody('title').trim(),
    sanitizeBody('shortName').trim(),
    sanitizeBody('choices.*').trim(),
but I wanted a custom option that let me use a callback function
Jason Luboff
@JLuboff
Feb 07 20:15
I like to santize my kitchen. Don't want any roque chicken juice
sanitizeKitchen('counter').trimFat();
Christopher McCormack
@cmccormack
Feb 07 20:18
hardy har
Jason Luboff
@JLuboff
Feb 07 20:19
thanks for the sympathy laugh
or..is it pity..
Christopher McCormack
@cmccormack
Feb 07 20:22
it's something! haha sorry wife came home for lunch so walked away
Jason Luboff
@JLuboff
Feb 07 20:23
Its all good...I'm eating lunch myself anyhow
Tiago Correia
@tiagocorreiaalmeida
Feb 07 20:23
@cmccormack never did it my self :\
Onome Sotu
@onomesotu
Feb 07 20:51
can someone help with the HTML entities problem?
Diego Mayer
@Chrono79
Feb 07 20:54
@onomesotu show your current code, sure
Onome Sotu
@onomesotu
Feb 07 20:55
I was just thinking the logic behind it
Diego Mayer
@Chrono79
Feb 07 20:56
And what do you have atm?
Onome Sotu
@onomesotu
Feb 07 20:57
Is there a way to get the Unicode equivalent of the entity? or do we have to hardcode the value? for example var s = '&amp;'?
I haven't written anything yet i'm just running the logic in my head
Diego Mayer
@Chrono79
Feb 07 21:00
Your goal is replacing the chars for the entities right?
Onome Sotu
@onomesotu
Feb 07 21:00
yes
is there a javascript method to get entities?
or rather string method?
Onome Sotu
@onomesotu
Feb 07 21:08
@Masd925 thanks @Masd925 I will check these out tomorrow
CamperBot
@camperbot
Feb 07 21:08
onomesotu sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4688 | @masd925 |http://www.freecodecamp.org/masd925
Diego Mayer
@Chrono79
Feb 07 21:09
using underscore seems a little too much
FlashHero
@FlashHero
Feb 07 23:51
var nameReducer=(state=data,action)=>{
  switch(action.type){
    case 'CHANGE_NAME':
    return {...state, name: action.payload}
    default:
    return state;
  }
}

var ageReducer=(state=data,action)=>{
  switch(action.type){
    case "CHANGE_AGE":
    return {...state, age: action.payload}
    default:
    return state;
  }
}

So let me get this straight, this code above is the same as

var combined=(state=data,action)=>{
  switch(action.type){
    case "CHANGE_AGE":
    return {...state, age: action.payload}
    case 'CHANGE_NAME':
    return {...state, name:action.payload}
    default:
    return state;
  }
}

right ?