These are chat archives for FreeCodeCamp/HelpJavaScript

16th
Jan 2018
dinesh
@1532j0004kg
Jan 16 2018 03:09
can anyone help me to install and run mongodb on 32bit os?
Keon Samuel
@keonsam
Jan 16 2018 03:15
if you can't install mongodb try mlab
dinesh
@1532j0004kg
Jan 16 2018 03:16
whats that?
Keon Samuel
@keonsam
Jan 16 2018 03:16
online mongodb database.
dinesh
@1532j0004kg
Jan 16 2018 03:17
So , Am i want to add any code?
Keon Samuel
@keonsam
Jan 16 2018 03:18
just a good suggestion containue trying to install mongodb.
dinesh
@1532j0004kg
Jan 16 2018 03:18
k
aRtoo
@artoodeeto
Jan 16 2018 04:14
hello fam why is add on closeClass.classList.add('modalClose'); not working. the error says cannot read property add of undefined
Ken Haduch
@khaduch
Jan 16 2018 04:33
@artoodeeto - it sounds like you might have either an undefined closeClass or classList. How are you setting closeClass? Or closeClass doesn't have a classList property...
aRtoo
@artoodeeto
Jan 16 2018 04:40
@khaduch all good now nbro. i just need to specify it because its returning an array. thanks
CamperBot
@camperbot
Jan 16 2018 04:40
artoodeeto sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3679 | @khaduch |http://www.freecodecamp.org/khaduch
Ken Haduch
@khaduch
Jan 16 2018 04:41
@artoodeeto :+1:
bilaal-s
@bilaal-s
Jan 16 2018 08:43
:wave:
aamirfreecode
@aamirfreecode
Jan 16 2018 08:53

var person = new Object();
console.log(person);
console.log(person.name);
person.name = "John";
person.yearOfBirth = 1962;
person.school = "B.N. InterCollege";

console.log(person);

why console.log(person.name) is undefined
console.log(person) just after person object is returning an empty object, but if we open that object in console there are all property and value, how can show all property and value before assigning it.
Blauelf
@Blauelf
Jan 16 2018 09:24

@aamirfreecode When you click on a logged object, it's evaluated when you click, otherwise you would have to create a deep copy of the object just for logging.

So when person is logged, it's empty, but afterwards it gets filled with key/value pairs, which you see in the console when clicking on the object.

person.name at the same time doesn't even exist. So there's no object that could be evaluated later.

This message was deleted
aamirfreecode
@aamirfreecode
Jan 16 2018 10:05
@Blauelf thanks
CamperBot
@camperbot
Jan 16 2018 10:05
aamirfreecode sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4673 | @blauelf |http://www.freecodecamp.org/blauelf
Happy-Ferret
@Happy-Ferret
Jan 16 2018 10:13

Any fellow Webextension devs?

I have this in one of my classes.

class CookieButton {
  get ButtonState() {
    return this.returnTest()
  }
  async returnTest() {
    var value = await browser.storage.local.get("buttonState")
    return value;
  }
}

Since I'm using await, I'd assume console.log(this.ButtonState) to return a valid value. Instead, it returns <unavailable>

Blauelf
@Blauelf
Jan 16 2018 12:45

@Happy-Ferret Not Webextension dev. Not much familiar with async/await either, but it seems to be a wrapper for promises, which I understand at least at a basic level.

Does this work for other promises (like var value = await Promise.resolve("dummy value");)? Maybe not async/await is the issue, but your permission of reading localStorage.

Blauelf
@Blauelf
Jan 16 2018 12:52
@Happy-Ferret Is ButtonState property meant to return a promise when read?
Pieter Stokkink
@forkerino
Jan 16 2018 13:04
@Blauelf await should wait until the Promise is either resolved or rejected.
Blauelf
@Blauelf
Jan 16 2018 13:04
But async wraps the value into another promise.
So this whole thing is almost the same as get ButtonState() { return browser.storage.local.get("buttonState"); } without all the async/await.
Pieter Stokkink
@forkerino
Jan 16 2018 13:09

I guess I don't understand the following from MDN completely, then:

When an async function is called, it returns a Promise. When the async function returns a value, the Promise will be resolved with the returned value.

I use generators most of the time, not async/await, so not completely comfortable with them yet.
Blauelf
@Blauelf
Jan 16 2018 13:12
Generators are the part I haven't used yet. I've read a few bits on 2ality, but found the reversal of control a bit challenging to understand.
Pieter Stokkink
@forkerino
Jan 16 2018 13:13
I use them in Redux Sagas a lot.
Nazar
@IsaakNazar
Jan 16 2018 13:55
:smile:
Jason Luboff
@JLuboff
Jan 16 2018 17:04
:wave:
Markus Kiili
@Masd925
Jan 16 2018 17:06
hmmm... wraps.
Jason Luboff
@JLuboff
Jan 16 2018 17:08
What kind of wraps?
Markus Kiili
@Masd925
Jan 16 2018 17:13
@JLuboff @Blauelf was mentioning wraps. Got me hungry.
Gersho
@Gersho
Jan 16 2018 17:14
lol
Jason Luboff
@JLuboff
Jan 16 2018 17:14
:joy:
Welp, it might only be morning but its a good day
Ronique Ricketts
@RoniqueRicketts
Jan 16 2018 18:21
HI guys I need some help with authentication. IDK anything about sessions and authtentications. If i set up my html
Sweet Coding :)
@SweetCodingInc
Jan 16 2018 18:21
@RoniqueRicketts I'm not telling you my password, okay?
Ronique Ricketts
@RoniqueRicketts
Jan 16 2018 18:22
@SweetCodingInc lol I am not asking u for it either. hehehe what is your password :)
Kaz Baig
@kbaig
Jan 16 2018 18:22
password
Ronique Ricketts
@RoniqueRicketts
Jan 16 2018 18:23
@kbaig you just got hacked 3:)
Kaz Baig
@kbaig
Jan 16 2018 18:23
rip
Matej Bošnjak
@mbosnjak01
Jan 16 2018 18:23
"Hi. we need your password to see if your account is working properly"
Jason Luboff
@JLuboff
Jan 16 2018 18:24
@RoniqueRicketts If you type your password into the chat, it will automatically change it to *'s. Like my password is **********
Matej Bošnjak
@mbosnjak01
Jan 16 2018 18:24
xDD
Kaz Baig
@kbaig
Jan 16 2018 18:24
"Hi. we need your password to see if your brain is working properly"
Jason Luboff
@JLuboff
Jan 16 2018 18:24
You have to make sure to put it between ` though
Gersho
@Gersho
Jan 16 2018 18:24
@JLuboff nice bait xD
Kaz Baig
@kbaig
Jan 16 2018 18:25
Imabrony420
Matej Bošnjak
@mbosnjak01
Jan 16 2018 18:25
too bad we can't make meme out of it
Kaz Baig
@kbaig
Jan 16 2018 18:25
did it work?
Ronique Ricketts
@RoniqueRicketts
Jan 16 2018 18:25
But seriously if I have a pug file with an pug form that will take user password and id how do I set up session so that the user can access for example a dashboard.
@mbosnjak01 Lies
Jason Luboff
@JLuboff
Jan 16 2018 18:25
@RoniqueRicketts Is this using Node?
Ronique Ricketts
@RoniqueRicketts
Jan 16 2018 18:25
@JLuboff fake news
Jason Luboff
@JLuboff
Jan 16 2018 18:25
If so, check out Passport.js
Gersho
@Gersho
Jan 16 2018 18:25
@kbaig we know your secret now
Ronique Ricketts
@RoniqueRicketts
Jan 16 2018 18:25
@JLuboff yup
Jason Luboff
@JLuboff
Jan 16 2018 18:25
Makes it easy
Ronique Ricketts
@RoniqueRicketts
Jan 16 2018 18:26
@JLuboff so I will I have to manage the session. or will passport handles all that. IDK anything about sessions.
Jason Luboff
@JLuboff
Jan 16 2018 18:26
@RoniqueRicketts Passport with handle the sessions using express-session
Gersho
@Gersho
Jan 16 2018 18:27
@mbosnjak01 django auth is built in, no code from me -> no bugs
Matej Bošnjak
@mbosnjak01
Jan 16 2018 18:27
ez life
Ronique Ricketts
@RoniqueRicketts
Jan 16 2018 18:29
@JLuboff oh so when we set up a session will it verify for each page in my dashboard? Lets say my dashboard have 3 distinct pages that needs password to view it, is that session that will handle the login process? If so will I have to check the session for each page?
Matej Bošnjak
@mbosnjak01
Jan 16 2018 18:29
nop
Ronique Ricketts
@RoniqueRicketts
Jan 16 2018 18:30
@mbosnjak01 who are you answering>?
Jason Luboff
@JLuboff
Jan 16 2018 18:30
@RoniqueRicketts You use passport as middleware but also check session if it changes some component of your layout (like showing the user name or something on the page)
Matej Bošnjak
@mbosnjak01
Jan 16 2018 18:30
you will not need to check session for each page
Ronique Ricketts
@RoniqueRicketts
Jan 16 2018 18:30
@JLuboff so i'd have to use both middlewares hand in hand?
Matej Bošnjak
@mbosnjak01
Jan 16 2018 18:31
at least I never saw anywhere session check for each page once you log in
:)
Jason Luboff
@JLuboff
Jan 16 2018 18:33

@RoniqueRicketts Not exactly. One you just stick in your route as middleware (checking if the user is logged in, if not they can't navigate to the page for example). The other (the session) you would check inside the the route so that you'd be sending the username. For example,

app.route('/addpoll')
  .get(isLogged, (req, res) => {
    var user, avatar;
    if(req.user !== undefined){
    user = req.user._json.name;
    avatar = req.user._json.avatar_url;};
    res.render('addpoll.hbs', {user, avatar});
})

isLogged is my middleware to check if the user is logged in. Then in my if statement below I'm checking the session for the user information

Ronique Ricketts
@RoniqueRicketts
Jan 16 2018 18:36
@mbosnjak01 thanks @JLuboff
CamperBot
@camperbot
Jan 16 2018 18:36
:cookie: 218 | @mbosnjak01 |http://www.freecodecamp.org/mbosnjak01
:star2: 2299 | @jluboff |http://www.freecodecamp.org/jluboff
roniquericketts sends brownie points to @mbosnjak01 and @jluboff :sparkles: :thumbsup: :sparkles:
Ronique Ricketts
@RoniqueRicketts
Jan 16 2018 19:10
@JLuboff what/who handles session btw?
Jason Luboff
@JLuboff
Jan 16 2018 19:13
@RoniqueRicketts What do you mean? In the context of how do you interact with it? If so, you use the npm package express-session. If you mean how to manipulate sessions, you would still use express-session and then you can add, remove, modify items within the session
Ronique Ricketts
@RoniqueRicketts
Jan 16 2018 19:14
@JLuboff ok so I believe for authentication and sessions I'll use passport for authentication and express-session for all sessions. I thought when a user logs in I would have to manually create some file for session etc. Please forgive my ignorance. :D
Jason Luboff
@JLuboff
Jan 16 2018 19:31
@RoniqueRicketts No worries. PAssport handles that for you (writing to the session). IF you weren't using Passport then you would need to handle the session info
Blauelf
@Blauelf
Jan 16 2018 21:13
@Masd925 Misquote. Wrapper, not wrap. Oh, wait, I actually said "wraps". Yeah, but it's a verb. Values inside, not beans. And Promise outside, not tortilla.
Francois Beyers
@Blusoup
Jan 16 2018 21:57
Has anyone got good training material on Regular Expressions?
Diego Mayer
@Chrono79
Jan 16 2018 22:03
@Blusoup Try doing hackerrank challengeshttps://www.hackerrank.com/domains/regex/re-introduction
Francois Beyers
@Blusoup
Jan 16 2018 22:05
Thanks @Chrono79
CamperBot
@camperbot
Jan 16 2018 22:05
blusoup sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4604 | @chrono79 |http://www.freecodecamp.org/chrono79
Andrea Beducci
@microcluster
Jan 16 2018 22:12
hi, can someone explain me this please?
var arr = [
  [1,2], [3,4], [5,6]
];
for (var i=0; i < arr.length; i++) {
  for (var j=0; j < arr[i].length; j++) {
    console.log(arr[i][j]);
  }
}
i'm on "nesting for loops" lesson
Kaz Baig
@kbaig
Jan 16 2018 22:13
@microcluster go through each item in arr, and go through item within that item
so i will be 0, j will be 0, then 1, then i will be 1, j 0, then 1
hope I'm explaining that right
Therefore, you will initially log arr[0][0], which is [1, 2][0], which is 1
Andrea Beducci
@microcluster
Jan 16 2018 22:16
@kbaig inside a function is same things?
Kaz Baig
@kbaig
Jan 16 2018 22:17
Not sure if I understand your question
Jason Luboff
@JLuboff
Jan 16 2018 22:18
There's technically no function above
@kbaig You know SQL right?
Andrea Beducci
@microcluster
Jan 16 2018 22:21
the exercise is this
Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr
Kaz Baig
@kbaig
Jan 16 2018 22:23
@JLuboff ye
Jason Luboff
@JLuboff
Jan 16 2018 22:23
@microcluster Oh, you didn't copy the complete code (the function wrapper). But what @kbaig said still applies
@kbaig Have you taken any of the Microsoft SQL server certification exams?
Andrea Beducci
@microcluster
Jan 16 2018 22:24
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line

  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
i don't want solutions only to understand
Kaz Baig
@kbaig
Jan 16 2018 22:24
@JLuboff nah I just took a data mining course for business students
@microcluster you want to go through each subarray and multiply the elements by your product variable. Looks like you've already figured out how to get access to each item in subarrays
Jason Luboff
@JLuboff
Jan 16 2018 22:26
@kbaig Ah, gotcha. My new focus is going to be earning MCSA SQL 2016 but not a ton of study material out there...that and apparently the test is quite intimidating lol
Kaz Baig
@kbaig
Jan 16 2018 22:28
Yikes good luck dude
One day I'll figure out what kind of certs PMs usually have
And try to go for those
But you need $$$
Jason Luboff
@JLuboff
Jan 16 2018 22:30
PM = Project Manager...?
Kaz Baig
@kbaig
Jan 16 2018 22:30
Yep
Jason Luboff
@JLuboff
Jan 16 2018 22:30
Gotcha
Kaz Baig
@kbaig
Jan 16 2018 22:30
Or I could get lucky and get picked up as a VC associate but I think finding gold at the end of a rainbow is more likely
Jason Luboff
@JLuboff
Jan 16 2018 22:31
My works paying for everything (study material, exams, etc). MCSA consists of two tests. I'm giving myself until the end of the year to pass both. May or may not be realistic lol
Kaz Baig
@kbaig
Jan 16 2018 22:31
We get half off one course per semester if we get a B- or above - I suppose that's not bad
Jason Luboff
@JLuboff
Jan 16 2018 22:32
Saving money is saving money
Kaz Baig
@kbaig
Jan 16 2018 22:33
Ideally I should be leveraging that twice a year, so let's see what I can come up with
Thought about doing a 2 week mini tech MBA at my old university but I figured I'm too young to (probably) be in a classroom of executives
Jason Luboff
@JLuboff
Jan 16 2018 22:34
Maybe I'm misunderstanding.. but get your MBA (masters degree?) in 2 weeks?
Kaz Baig
@kbaig
Jan 16 2018 22:35
No it's a mini MBA, so really a certification/training
It's in the same vein as executive training courses
Jason Luboff
@JLuboff
Jan 16 2018 22:35
Ah, gotcha
I'm altering a database right now...trying to normalize it
Its a small database (tracks our companies vehicles) but the original DBA/Programmer didn't normalize it for some reason
Dan Lafferty
@DanLaff
Jan 16 2018 22:49
@microcluster It's a nested for loop. The first for loop iterates through the sub arrays: [1,2], [3,4], and [5,6,7]. The second for loop iterates through each of the sub arrays. The final result is 1, 2, 3, 4, 5, 6. Check out the *= assignment operator for that next step in multiplying all those numbers by the product variable
Kaz Baig
@kbaig
Jan 16 2018 22:49
Ugh do you use the formalized degree of normalization approach or is that too extra for you @JLuboff
My least favorite (and maybe most useful) part of that class
Jason Luboff
@JLuboff
Jan 16 2018 22:51
@kbaig I still don't fully understand all the different forms of normalization lol. I think I'm just trying to get it to 3nf.
Andrea Beducci
@microcluster
Jan 16 2018 22:57
@DanLaff i solved it . i omitted the console.log *=etc.
Brian Dudey
@briandudey
Jan 16 2018 23:56
This "should" be so easy but it's not passing the test, I must be missing something, which is probably so obvious. Any insight would be appreciated:
var myStr = "I am a \"double quoted\" string inside \"double quotes\".";
needs to return: I am a "double quoted" string inside "double quotes".
Henry
@GitHub-Henry
Jan 16 2018 23:59
@briandudey this may help