These are chat archives for FreeCodeCamp/HelpJavaScript

23rd
Apr 2018
anthonygallina1
@anthonygallina1
Apr 23 2018 01:19
Any one on that is good with node?
Joseph
@revisualize
Apr 23 2018 01:25

I'm still stuck on this shit:

  var ammountToCustomer = Number( ( cash - price ).toFixed(2) ); 

  cid.reverse(); // reverse the cid to work from largest denoms down to smallest.

  var change = cid.reduce( function ( accumArr , currentArr , index) {
                                      var noteValue = BANKNOTES[currentArr[0]];
                                      var availableInDrawer = currentArr[1] ;
                                      if (false) {
                                      }
                                      return accumArr;
                                  } , []);

  if ( Number( ammountToCustomer.toFixed(2) ) > 0) {
        return "Insufficient Funds";
  }
  if ( cid.every(function (val) { return Number( val[1].toFixed(2) ) === 0; }) ) {
        return "Closed";
  }
  // Here is your change, ma'am.
  return change;
}

I know that somewhere I need to do a:

accumArr.push( [ currentArr[0] , someValue ] );

And somewhere else I need to do a
ammountToCustomer = Number( ( ammountToCustomer - someValue ).toFixed(2) );

So frustrating.
I can kind of see stuff.
The if (false) was me playing with junk because I didn't know what the hell I was supposed to do.
anthonygallina1
@anthonygallina1
Apr 23 2018 01:35
```
Waypoint: Iterate Through an Array with a For Loop

// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

for (var i = 0; i < ourArr.length; i++) {
  ourTotal += ourArr[i];
}

// 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++) {
   console.log(total += myArr[i]);
}
Hmm that didnt help i have both sys up No fire blowing out of the battery back up. And trying @revisualize
anthonygallina1
@anthonygallina1
Apr 23 2018 01:46
@revisualize can you stick it in a pen. With expected out put?
Joseph
@revisualize
Apr 23 2018 01:51
I'm still thinking through my issue.
anthonygallina1
@anthonygallina1
Apr 23 2018 01:53
forEach?
Seems over complicated though
Joseph
@revisualize
Apr 23 2018 01:54
I'm sitting here with 5 index cards and a few pennies, nickels, dimes, quarters and two fives and 3 ones trying to think about the problem.
I have actual money sitting in front of me. LOL!
anthonygallina1
@anthonygallina1
Apr 23 2018 01:55
:thumbsup:
Jason Luboff
@JLuboff
Apr 23 2018 15:08
@tiagocorreiaalmeida I am now... but going to be stepping away in a minute lol
Christopher McCormack
@cmccormack
Apr 23 2018 15:21
@JLuboff talking to yourself again?
Jason Luboff
@JLuboff
Apr 23 2018 15:25
@cmccormack I find I have the best conversations with myself
Christopher McCormack
@cmccormack
Apr 23 2018 15:26
They all are depending on how solipsistic you are :D
Jason Luboff
@JLuboff
Apr 23 2018 15:26
:P
Have a decent weekend? @cmccormack
Christopher McCormack
@cmccormack
Apr 23 2018 15:28
@JLuboff yeah man first one we could just chill all weekend in Flagstaff without having to travel or go to family event
I made the best steak ever too, smoking it with mesquite for like 30 min then searing, so good!
How was yours?
Jason Luboff
@JLuboff
Apr 23 2018 15:58
@cmccormack It's always nice to be able to just...relax lol. Decent, went to my nephews track meet and a friends birthday dinner on saturday and didn't do a whole lot on Sunday
Christopher McCormack
@cmccormack
Apr 23 2018 15:59
@JLuboff I used my relaxing time to work on my Voting app haha
Just about finished it, now adding some validation stuff for React
Jason Luboff
@JLuboff
Apr 23 2018 15:59
Awesome, I'm sure your voting app is much more robust than mine is :)
Christopher McCormack
@cmccormack
Apr 23 2018 16:00
in the end does about the same thing though haha
and probably with a much larger file size
Jason Luboff
@JLuboff
Apr 23 2018 16:01
True..but for example..I don't have any validation
Christopher McCormack
@cmccormack
Apr 23 2018 16:01
but I really wanted to dig into some different tools and functionality, it was fun
Jason Luboff
@JLuboff
Apr 23 2018 16:01
Mine also isn't really a "full-stack" app since I'm not using React or angular or anything like that
Christopher McCormack
@cmccormack
Apr 23 2018 16:01
I don't think it required that though?
as long as it's frontend + backend?
JS/HTML/CSS/Node basically?
Jason Luboff
@JLuboff
Apr 23 2018 16:02
Correct, not required
Christopher McCormack
@cmccormack
Apr 23 2018 16:02
so yours is full stack :)
I may try out Vue for my next project
Jason Luboff
@JLuboff
Apr 23 2018 16:03
but I think thats their idea of things, is to have you build it using MERN or MEAN just based on the foundation of the FCC Map (frontend -> data viz -> backend)
Christopher McCormack
@cmccormack
Apr 23 2018 16:03
it's tough to tell without them explicitly stating it I guess - they push templating during the backend stuff so I just assumed they expected that
Jason Luboff
@JLuboff
Apr 23 2018 16:05
Ya...maybe the next version will have better descriptors
Christopher McCormack
@cmccormack
Apr 23 2018 16:06
Maybe - really at the point of building webapps your requirement to stick with FCC is pretty minimal
you can basically start building whatever you want
Jason Luboff
@JLuboff
Apr 23 2018 16:06
True
Tiago Correia
@tiagocorreiaalmeida
Apr 23 2018 16:32
hey @JLuboff already got the thing I wanted going on either way thanks
CamperBot
@camperbot
Apr 23 2018 16:32
tiagocorreiaalmeida sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2408 | @jluboff |http://www.freecodecamp.org/jluboff
Christopher McCormack
@cmccormack
Apr 23 2018 16:33
cryptic
Jason Luboff
@JLuboff
Apr 23 2018 16:34
Super cryptic
Christopher McCormack
@cmccormack
Apr 23 2018 20:16
saw that
Tiago Correia
@tiagocorreiaalmeida
Apr 23 2018 20:16
ahahaha
the brocoli
Christopher McCormack
@cmccormack
Apr 23 2018 20:16
haha
Tiago Correia
@tiagocorreiaalmeida
Apr 23 2018 20:16
fuck man wrong picture
image.png
im having an issue with bcrypt and no idea why
if someone can give it a look
import bcrypt from "bcrypt";

export default (password) => {
    const salt = bcrypt.genSaltSync(10);
    return bcrypt.hashSync(password, salt);
}
I console log the argument passed and its there
I also did the same for salt and its everything there
but when I run it the error above shows up
router.post("/register", [
    body("email")
        .isEmail()
        .withMessage("Invalid email!"),
    body("password")
        .isLength({ min: 4 })
        .withMessage("The password minimum length is four characters!"),
    body("name")
        .isLength({ min: 1 })
        .withMessage("You need to write your name!")
], (req, res) => {
    const errors = validationResult(req);
    if (!errors.isEmpty()) return res.error(409, errors.array()[0].msg);

    const { email, name } = req.body;
    const password = encryptIt(req.body.password);

    try {
        connection.query("SELECT * FROM users WHERE email=?", [email], (err, user, fields) => {
            if (err) throw new Error(err);
            if (user) return res.error(409, "The email it's already in use by another user!");

            connection.query("INSERT INTO users SET ?", { email, name, password }, (err, user, fields) => {
                if (err) throw new Error(err);
                console.log(user);
                res.send(user.affectedRows);
            });

        });
    } catch (e) {
        res.error(500, "Something went wrong please refresh the page and try again", e);
    }
});
this is the route in cause its needed
the function its called encryptIt
Christopher McCormack
@cmccormack
Apr 23 2018 20:18
show your function
Tiago Correia
@tiagocorreiaalmeida
Apr 23 2018 20:19
its above
I use bcrypt
generate a salt
and then hash it
done this thousand of times
but today this aint being friendly :D
Jason Luboff
@JLuboff
Apr 23 2018 20:21
Did you try adding some pepper? I find it really enhances the flavor
Tiago Correia
@tiagocorreiaalmeida
Apr 23 2018 20:22
I guess it could make it more tasty
Christopher McCormack
@cmccormack
Apr 23 2018 20:22
did you test your function outside of your program?
just pass in text and number value?
Tiago Correia
@tiagocorreiaalmeida
Apr 23 2018 20:24
const test = encryptIt("teste");
same thinbg
same error
Christopher McCormack
@cmccormack
Apr 23 2018 20:26
How are you using import? with experimental flag?
Tiago Correia
@tiagocorreiaalmeida
Apr 23 2018 20:26
wait a second
Christopher McCormack
@cmccormack
Apr 23 2018 20:26
no
Tiago Correia
@tiagocorreiaalmeida
Apr 23 2018 20:27
two then :D
import bcrypt from "bcrypt";

export default (password) => {
    const salt = bcrypt.genSaltSync(10);
    const encriptedPassword = bcrypt.hashSync(password, salt);
    return encriptedPassword;
}
if I assing it to a variable works
strange I made it work really a few times just by returning the function itself with the arguments but well I dont know thanks tough you made me split this even more
Christopher McCormack
@cmccormack
Apr 23 2018 20:28
hmm require wraps your code, maybe by importing you're changing it, try requiring bcrypt instead maybe?
I'm still a little confused by how require works though even after reading several articles :)
Tiago Correia
@tiagocorreiaalmeida
Apr 23 2018 20:29
fu** me..
bcrypt expects a salt and a string
it literally says it on the error and im sending a number on the post request.. :D
Christopher McCormack
@cmccormack
Apr 23 2018 20:30
why is password a number?
Tiago Correia
@tiagocorreiaalmeida
Apr 23 2018 20:31
cause im using postman to make the request on the api and I forgot to wrap it around on double quotes :\
Christopher McCormack
@cmccormack
Apr 23 2018 20:31
ahhh
haha
Tiago Correia
@tiagocorreiaalmeida
Apr 23 2018 20:31
first the brocoli now this
Christopher McCormack
@cmccormack
Apr 23 2018 20:31
so why did changing your function work? did you also change your test?
Tiago Correia
@tiagocorreiaalmeida
Apr 23 2018 20:31
I just got the function back to what it was the issue was really pass a number to the bcrypt function
Christopher McCormack
@cmccormack
Apr 23 2018 20:33
well there you go
bilaal-s
@bilaal-s
Apr 23 2018 20:36
anyone know how to get mimum height on a grid row and maximum set to auto?
minmax(250px, auto) seems to mess up
Christopher McCormack
@cmccormack
Apr 23 2018 20:38
@bilaal-s nope sorry, CSS grid?
bilaal-s
@bilaal-s
Apr 23 2018 20:39
@cmccormack yup css grid, npnp thanks for responding
CamperBot
@camperbot
Apr 23 2018 20:39
bilaal-s sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1426 | @cmccormack |http://www.freecodecamp.org/cmccormack
Christopher McCormack
@cmccormack
Apr 23 2018 20:39
@bilaal-s you read all this I assume? https://developer.mozilla.org/en-US/docs/Web/CSS/minmax
bilaal-s
@bilaal-s
Apr 23 2018 20:40
no, will do (y)
Josh Queen
@Kohota107
Apr 23 2018 21:11
Evening guys
Can anyone give me a hint as to why my code doesn't work?

function getIndexToIns(arr, num) {
  arr.sort(function(a, b) {
    return a - b;
  });
  for (var i = 0; i < arr.length; i++){
    if (num > i && num <= i+1) {
      arr.splice(i+1,0,num);
    }
  }
  return arr;
}

getIndexToIns([40, 60, 70, 80, 20, 10], 50);
alpox
@alpox
Apr 23 2018 21:15
@Kohota107 What challenge is that? The name of the function tells me that a number (index) should be the result of the function call. But you return an array.
Tom
@moT01
Apr 23 2018 21:15
that if test doesnt look right
Josh Queen
@Kohota107
Apr 23 2018 21:15
It's the where do I belong challenge
But I haven't got to the index position yet
I just want to print the array with the integer in the right place
Then I'll worry about returning the index (which will be a lot easier!)
@moT01 can you give me a clue as to why?
Tom
@moT01
Apr 23 2018 21:16
if (num > i && num <= i+1) { ? so the same as if num === i+1
alpox
@alpox
Apr 23 2018 21:16
@Kohota107 num > i you compare the number with an index - your indices are 0-5, but the numbers are 10-80. You should be comparing the number with array elements, not indices
Josh Queen
@Kohota107
Apr 23 2018 21:17
Ahhhhh
Something's clicked
Thanks for the hint
Jason Luboff
@JLuboff
Apr 23 2018 21:21
@moT01 Haven't seen you around lately
Tom
@moT01
Apr 23 2018 21:24
i linger
i got all my certs - the few people that come around here looking for help usually get that help pretty quickly
and i actually was taking care of a grandparent the last few months
Diego Mayer
@Chrono79
Apr 23 2018 21:41
Hi, has anyone experience with Instagram API and access tokens? I need help with re-issuing a new token
Christopher McCormack
@cmccormack
Apr 23 2018 21:59
@Chrono79 sorry never used it, but good to see you!
Diego Mayer
@Chrono79
Apr 23 2018 22:00
Thanks, @cmccormack I'm juggling with several things at the moment and that is one of them
CamperBot
@camperbot
Apr 23 2018 22:00
chrono79 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1427 | @cmccormack |http://www.freecodecamp.org/cmccormack
Jason Luboff
@JLuboff
Apr 23 2018 22:23
@moT01 Congrats on the certs! I still need to do the data viz stuff.
Tom
@moT01
Apr 23 2018 22:34
@JLuboff thanks, got it just after the new year
CamperBot
@camperbot
Apr 23 2018 22:34
mot01 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2409 | @jluboff |http://www.freecodecamp.org/jluboff
Jason Luboff
@JLuboff
Apr 23 2018 22:39
I'll eventually get to data viz... (the year 2034..)
Christopher McCormack
@cmccormack
Apr 23 2018 22:41
@JLuboff we're all waiting so we can talk React
Jason Luboff
@JLuboff
Apr 23 2018 22:41
@cmccormack :(
Christopher McCormack
@cmccormack
Apr 23 2018 22:41
or whatever you choose to use I guess
Jason Luboff
@JLuboff
Apr 23 2018 22:41
React would be my go to I'd imagine
Christopher McCormack
@cmccormack
Apr 23 2018 22:43
It's pretty great
makes you think differently about how you code, which imho is a good thing
Jason Luboff
@JLuboff
Apr 23 2018 22:44
Indeed.
Looks like I'll have another project on the horizon
Christopher McCormack
@cmccormack
Apr 23 2018 22:47
Work?
Jason Luboff
@JLuboff
Apr 23 2018 22:47
Yup
Christopher McCormack
@cmccormack
Apr 23 2018 22:47
dang
did you finish the last?
Jason Luboff
@JLuboff
Apr 23 2018 22:47
Nope. Still working on it haha
Christopher McCormack
@cmccormack
Apr 23 2018 22:47
too much to do!
Jason Luboff
@JLuboff
Apr 23 2018 22:48
Yup.. not to mention I have to get a new server setup for Imaging (or see if my co-worker will..)
Christopher McCormack
@cmccormack
Apr 23 2018 22:56
make that guy do it
Jason Luboff
@JLuboff
Apr 23 2018 22:58
@cmccormack I'm going to try to...but he'll probably bitch about it :joy:
I'm the only one who'll actually use it
But...he setup the original one so
Christopher McCormack
@cmccormack
Apr 23 2018 22:59
everyone bitching about working
Jason Luboff
@JLuboff
Apr 23 2018 23:02
:P
The next project will probably be C#...unless I decide to do Electron...
Christopher McCormack
@cmccormack
Apr 23 2018 23:10
electron actually sounds fun let me us know if you do
Jason Luboff
@JLuboff
Apr 23 2018 23:12
:+1:
Probably be a little quicker to do it with C# (winforms are so stupid easy to make..you jsut drag and drop, but limited customization)
I really like the idea of Electron though. Essentially turn a web app into a standalone app. Kind of nice but still carries some of the same issues or limitations
Christopher McCormack
@cmccormack
Apr 23 2018 23:22
seems like a useful tool. I use more electron apps than not lately it seems, I'm on slack/vs code all the time
Jason Luboff
@JLuboff
Apr 23 2018 23:23
Here we go again... Mr. VS Code :P
Christopher McCormack
@cmccormack
Apr 23 2018 23:24
yeah man, everyone's doing it
Jason Luboff
@JLuboff
Apr 23 2018 23:24
Psh
I'll stick to my Atom...and VS Community
Brad
@bradtaniguchi
Apr 23 2018 23:25
electron apps = no ram
Jason Luboff
@JLuboff
Apr 23 2018 23:26
@bradtaniguchi explain?
Christopher McCormack
@cmccormack
Apr 23 2018 23:27
if you aren't using all your RAM then you're not using your RAM correctly!
Brad
@bradtaniguchi
Apr 23 2018 23:27
looks at how much ram atom takes up, with no files open (500mb)
Christopher McCormack
@cmccormack
Apr 23 2018 23:28
Atom is a hog I never really liked it, laggy and crashed a lot when I first used it
VS Code blows atom away, sorry @JLuboff :)
Jason Luboff
@JLuboff
Apr 23 2018 23:28
Err... then there's something wrong with your Atom lol. I have two files open and it's only using 40 MB...
Brad
@bradtaniguchi
Apr 23 2018 23:29
That sort of usage is unheard of for me XD
Christopher McCormack
@cmccormack
Apr 23 2018 23:29
I have VS Code open with tons of extensions and files open and it's only ~200MB
Brad
@bradtaniguchi
Apr 23 2018 23:29
I mean firefox is using 700mb, and it has 20 tabs open 24/7
Christopher McCormack
@cmccormack
Apr 23 2018 23:30
I have about 20 tabs open too and Chrome only using 650MB, not too shabby
Jason Luboff
@JLuboff
Apr 23 2018 23:30
,....12 tabs with FF... only 222 MB
What are you guys doing to your machines :joy:
Christopher McCormack
@cmccormack
Apr 23 2018 23:30
most of that really depends on your extensions
people don't realize something like an Ad Blocker uses a really big file(s) stored in memory for fast access, and complain their Chrome is slow compared to other browsers not running any extensions
Jason Luboff
@JLuboff
Apr 23 2018 23:31
None for FF
Brad
@bradtaniguchi
Apr 23 2018 23:31
all my electron apps (not gitter currently) are on firefox tho, so 4 chat apps, 4 heavy google apps, sheets, and documentation
Jason Luboff
@JLuboff
Apr 23 2018 23:31
Is gitter built in electron? It's only using 12 mb
Brad
@bradtaniguchi
Apr 23 2018 23:32
AFAIK yea its an electron app
the VScode guys must do heavy optimzations tho cuse its ram usage is really low compared to other electron apps.
Christopher McCormack
@cmccormack
Apr 23 2018 23:33
Microsoft really takes care of VS Code
They have almost monthly releases with tons of great changes
Brad
@bradtaniguchi
Apr 23 2018 23:35
MS makes good developer tools I have to give them that.
Christopher McCormack
@cmccormack
Apr 23 2018 23:35
As far as I know Visual Studio is still at the top
Gotta run for a bit ttyl
Jason Luboff
@JLuboff
Apr 23 2018 23:36
VS Community is pretty good as an IDE..I just still prefer atom over it for text editor. I run Atom on a vertical screen and it gives me the most working space
Ah damn.... I lied. Atom is using 280 MB. Windows 10 Processes get broken up into seperate sections even when you sort by name ><
Brittany Rutherford
@brittanyrutherford
Apr 23 2018 23:49
atom for the win!
Tom
@moT01
Apr 23 2018 23:50
notepad (original)
Jason Luboff
@JLuboff
Apr 23 2018 23:51
Oh man... I can't imagine using notepad lol
Brad
@bradtaniguchi
Apr 23 2018 23:51
hehe lies of windows
I mean I can go use vim and get those numbers..... but I'm still sane :P
Brittany Rutherford
@brittanyrutherford
Apr 23 2018 23:51
i love the intellisense in notepad
Tom
@moT01
Apr 23 2018 23:52
used notepad back in the day
Brittany Rutherford
@brittanyrutherford
Apr 23 2018 23:52
"back in the day" ... how old r u? :P
Brad
@bradtaniguchi
Apr 23 2018 23:53
Id carry notepad++ in a usb and felt like a cool kid
Jason Luboff
@JLuboff
Apr 23 2018 23:53
I used Dreamweaver back in the day
Brittany Rutherford
@brittanyrutherford
Apr 23 2018 23:53
usb? :/ u guys didn't have online storage? :S
Jason Luboff
@JLuboff
Apr 23 2018 23:54
Hell.. I used floppy disks for storing images
Brittany Rutherford
@brittanyrutherford
Apr 23 2018 23:54
:joy: OMG am in the wrong place
Jason Luboff
@JLuboff
Apr 23 2018 23:54
I'm only 29 though...not that old lol
Brittany Rutherford
@brittanyrutherford
Apr 23 2018 23:54
how to freak out new devs 101
aaah
that's not even in the old category
unless u r 45+ i guess
Jason Luboff
@JLuboff
Apr 23 2018 23:56
Now now, don't want to make anybody feel old :P
Tom
@moT01
Apr 23 2018 23:56
31
Brittany Rutherford
@brittanyrutherford
Apr 23 2018 23:56
i've seen some 40-50 on this site
but none of them mentioned floppy disks :joy:
Tom
@moT01
Apr 23 2018 23:56
notepad and these things called "textbooks" to build websites for something called netscape navigator
Jason Luboff
@JLuboff
Apr 23 2018 23:57
There are quite a few, they don't mention floppies, they mention BASIC, etc
Brittany Rutherford
@brittanyrutherford
Apr 23 2018 23:57
:joy:
i'll stick with js and atom
Jason Luboff
@JLuboff
Apr 23 2018 23:58
Time to head home, adios