These are chat archives for FreeCodeCamp/HelpJavaScript

30th
Nov 2018
Brad
@bradtaniguchi
Nov 30 2018 00:32
Yo I think this mistake drove me insane...
// most files
import { ObjectID } from 'mongodb';

// one KEY file
import { ObjectID } from 'bson';
Jason Luboff
@JLuboff
Nov 30 2018 00:36
Whats the issue here
Except that you're using the same variable name
Brad
@bradtaniguchi
Nov 30 2018 00:42
This:
import { mongoDbObjectIdThingy } = 'some-file';

import { theKeyObjectIdThingy } = 'some-other-file';

mongoDbObjectIdThingy instanceof theKeyObjectIdThingy // false
and this is fine
import { ObjectID} from 'mongodb';
//theKeyObjectIdThingy = '12345' as an example 
const objectId = new ObjectID(theKeyObjectIdThingy);
// objectId = '12233451' the id changes..... why IDK.
Jason Luboff
@JLuboff
Nov 30 2018 00:44
mongo, am I rite?
Brad
@bradtaniguchi
Nov 30 2018 00:44
Mainly the two ObjectIds between the two packages aren't the same thing, but don't throw any errors anywhere when used with each other. My linter also didn't catch any of this
Jason Luboff
@JLuboff
Nov 30 2018 00:44
Just rename one?
Or is that not the problem
Brad
@bradtaniguchi
Nov 30 2018 00:45
The usage of these two variables are actually between two projects, 1 has a re-usable utility using the bson one, and the other is the actual project that uses the utility.
The actual project had logic that checked to see if the passed variable is an ObjectId (the mongo one) if it isn't I try to make one from the variable. (usually its a string). For some damn reason if I pass the bson variable to the mongoDb ObjectId it creates a totally unrelated ID
And finally when I pass the unrelatedID I guess mongo doesn't even make the property in the DB probably because its not a valid mongodb Id or something?
Jason Luboff
@JLuboff
Nov 30 2018 00:49
Its supposed to update/read from mongo or insert? If insert..I guess that means you're making your own ID's instead of letting mongo handle it?
Brad
@bradtaniguchi
Nov 30 2018 00:51
Yea for this situation I have to manually make them all before insert
Jason Luboff
@JLuboff
Nov 30 2018 00:51
Ah.
I always let mongo make them for me..I don't think theres any strict guidelines to it though just has to be an ObjectID('myString')
Brad
@bradtaniguchi
Nov 30 2018 00:55
Were doing a "migration" so we have to change all the referenceIds for all the items, the actual migration logic is what is being re-used. But yea between the two they were using the wrong ObjectIds between each other resulting in this mess
Jason Luboff
@JLuboff
Nov 30 2018 00:59
Sounds like a ton of fun! So much fun that I'm going home
Brad
@bradtaniguchi
Nov 30 2018 01:02
@JLuboff Have fun at home :D
ZeHung
@RexHung0302
Nov 30 2018 09:21
Why can't I Run this?
var myStr = "I am a \"double quoted\" string inside \"double quotes\".";
The question is use " or ' by \
myStr = I am a "double quoted" string inside "double quotes"
Jefferson
@jeffersonnnn
Nov 30 2018 11:28
@AdelMahjoub i have to say a big thank you for yesterday. may whatever diety you work with bless you for meeee.
chenqian
@M-cq
Nov 30 2018 15:59
what a front end developer exactly do ,
what a front end developer exactly do ,
"years ago one must master a every language can be called full stack developer ,but now just javacript" is that true?
Jason Luboff
@JLuboff
Nov 30 2018 16:07
Due to the existence of NodeJS...to an extent, yes you can know JS and be a full stack developer.
chenqian
@M-cq
Nov 30 2018 16:13
hey see you again @JLuboff
Jason Luboff
@JLuboff
Nov 30 2018 16:14
Hi
chenqian
@M-cq
Nov 30 2018 16:15
now i am learning to be a front end developer at a trainning school
now i am learning to be a front end developer at a trainning school
Christopher McCormack
@cmccormack
Nov 30 2018 16:15
I'm reading this as a song
how will they rhyme school...
Jason Luboff
@JLuboff
Nov 30 2018 16:16
:smile:
chenqian
@M-cq
Nov 30 2018 16:17
they let us make static page for nine days
they let us make static page for nine days
Jefferson
@jeffersonnnn
Nov 30 2018 16:17
:smile:
Gosh this chat room is amazing
chenqian
@M-cq
Nov 30 2018 16:17
haha
Jason Luboff
@JLuboff
Nov 30 2018 16:19
Whats everyone working on today?
chenqian
@M-cq
Nov 30 2018 16:19
the trainning school treat students as machines
Jefferson
@jeffersonnnn
Nov 30 2018 16:22
@JLuboff well, im working on stuck on a Node/Express API with a JS structure for persisting data (someone said the fs module suits what i'm looking for, but i don't know)
Jason Luboff
@JLuboff
Nov 30 2018 16:22
@M-cq Like machines? That...doesn't sound very nice :(
Jose Pagan
@josepagan
Nov 30 2018 16:22
Ihave been away from coding for a month And I have lost touch with JS. Do you know any place to have quick recaps and refresh?
Jefferson
@jeffersonnnn
Nov 30 2018 16:23
@JLuboff i'd ask what you are working on, but i know i'll be mind blown already.
Jose Pagan
@josepagan
Nov 30 2018 16:23
I am now re-reading my own code and I find it hard to understand
Christopher McCormack
@cmccormack
Nov 30 2018 16:23
@jeffersonnnn fs is to work with the filesystem
Jason Luboff
@JLuboff
Nov 30 2018 16:23
@jeffersonnnn Persisting data without a database?
Christopher McCormack
@cmccormack
Nov 30 2018 16:23
maybe writing data to a file on the server is your persistent data?
Jason Luboff
@JLuboff
Nov 30 2018 16:23
And I'm just working on my React app for work. Nothing too mind blowing haha
@josepagan You should start commenting code so that it is easier to read in the future. As far as refreshers..I would just start coding again and look up things as needed
Jose Pagan
@josepagan
Nov 30 2018 16:25
thanks I find a bit stressing, you are right. I made a game and I was so into it I ignore all comenting and linting
Christopher McCormack
@cmccormack
Nov 30 2018 16:25
@josepagan yeah never hurts to go over the curriculum again just to surface your latent JS memories
Jose Pagan
@josepagan
Nov 30 2018 16:25
now it huts lol,
Jefferson
@jeffersonnnn
Nov 30 2018 16:25
exactly that sigh. it is for a bootcamp-esque program. for pointers, i am using this article (https://www.codementor.io/olawalealadeusi896/building-simple-api-with-es6-krn8xx3k6#comments-krn8xx3k6) @cmccormack @JLuboff
Jose Pagan
@josepagan
Nov 30 2018 16:25
They say that when you abandon something and you come back you actually learn better
Jefferson
@jeffersonnnn
Nov 30 2018 16:25
@JLuboff have you give the new Hooks a spin in production yet?
*React Hoks
Jason Luboff
@JLuboff
Nov 30 2018 16:25
@jeffersonnnn I'm still very much a noob when it comes to React
Jefferson
@jeffersonnnn
Nov 30 2018 16:25
Ughhh *Hooks
Jason Luboff
@JLuboff
Nov 30 2018 16:26
I think @cmccormack has played with them though
Christopher McCormack
@cmccormack
Nov 30 2018 16:26
I've played with them they are great!
it's like going back to regular JS again
Jason Luboff
@JLuboff
Nov 30 2018 16:26
@jeffersonnnn Also...if you're trying to persist data without a database, I could see where fs would come in hand in that you would be writing data to a file
Jose Pagan
@josepagan
Nov 30 2018 16:26
Im looking forward react and node to make fully featured stuff, I have been learning JS for a while
Christopher McCormack
@cmccormack
Nov 30 2018 16:26
you can have nice little stateful functions that you can reuse for state and side effects, etc..
Jefferson
@jeffersonnnn
Nov 30 2018 16:27
@cmccormack wow! now that sounds exciting. It and the Context API are what i should go back to.
Christopher McCormack
@cmccormack
Nov 30 2018 16:27
@jeffersonnnn Yeah context API also has hooks which makes it even nicer!
Jose Pagan
@josepagan
Nov 30 2018 16:27
I miss the casual chat where you could just talk about off topic things related to us. I dont know why they removed it
Christopher McCormack
@cmccormack
Nov 30 2018 16:28
@josepagan because that type of chat devolves pretty quickly
Jefferson
@jeffersonnnn
Nov 30 2018 16:28
@JLuboff can i pass on an article? i am trying to follow it, but to be honest, this is my first time writing node, and i'm using it (said article) to learn how to do the persisting.
Christopher McCormack
@cmccormack
Nov 30 2018 16:28
and we want to keep the fcc channels focused
chenqian
@M-cq
Nov 30 2018 16:28
the school teach students the same way ,the same thing ,
Jefferson
@jeffersonnnn
Nov 30 2018 16:28
@josepagan hey hey, we can be pretty casual here too :smile_cat:
Jason Luboff
@JLuboff
Nov 30 2018 16:29
@jeffersonnnn I could take a quick look
chenqian
@M-cq
Nov 30 2018 16:30
there is a super market of programming in china ,if some of you can speak chinese ,that is a good chance
there is a super market of programming in china ,if some of you can speak chinese ,that is a good chance
Jefferson
@jeffersonnnn
Nov 30 2018 16:31
i think these chat rooms are a beautiful mix of code, casual talk, and more serious stuff. ah, we have celebrated new jobs here, shared bad news from npm (LOL), played games and all
Jason Luboff
@JLuboff
Nov 30 2018 16:32
@jeffersonnnn Well... just learned from that article that express reintroduced the ability to populate req.body without needing something like body-parser lol
Jose Pagan
@josepagan
Nov 30 2018 16:33
god why is that I always forget how to use git? I need a cheat poster to put on front of me!
Jefferson
@jeffersonnnn
Nov 30 2018 16:33
@JLuboff yeah. i noticed that i didn't have to import body parser
Jason Luboff
@JLuboff
Nov 30 2018 16:34
@jeffersonnnn Ah... so he hasn't yet written the portion on persisting the data. But I imagine it will involve writing that to a file unless its only persistent in the current session in which case it would be persisted in an object I'd assume
Jefferson
@jeffersonnnn
Nov 30 2018 16:35
me thinks the author didn't quite deal with that portion well.
Jason Luboff
@JLuboff
Nov 30 2018 16:35
Ya it looks that way
Christopher McCormack
@cmccormack
Nov 30 2018 16:36
@josepagan @gbsimon87 shared this the other day - https://files.gitter.im/FreeCodeCamp/HelpJavaScript/dfmL/git-cheatsheet-EN-white.pdf
Jose Pagan
@josepagan
Nov 30 2018 16:36
Thanks!!!
Jason Luboff
@JLuboff
Nov 30 2018 16:36
@cmccormack I was trying to copy my local copy but wasn't working lol
Christopher McCormack
@cmccormack
Nov 30 2018 16:37
@JLuboff I had to find his link in the archives and copy it :)
Jefferson
@jeffersonnnn
Nov 30 2018 16:37

@JLuboff but i see what he is doing. All the information is stored in the object.

this is a snippet from his code

import uuid from 'uuid';

class Reflection {
  /**
   * class constructor
   * @param {object} data
   */
  constructor() {
    this.reflections = [];
  }
  /**
   * 
   * @returns {object} reflection object
   */
  create(data) {
    const newReflection = {
      id: uuid.v4(),
      success: data.success || '',
      lowPoint: data.lowPoint || '',
      takeAway: data.takeAway || '',
      createdDate: moment.now(),
      modifiedDate: moment.now()
    };
    this.reflections.push(newReflection);
    return newReflection
  }
  /**
Jason Luboff
@JLuboff
Nov 30 2018 16:38
@cmccormack That sounds like a lot of effort
@jeffersonnnn Ah..so just persistent for the session it would seem
Christopher McCormack
@cmccormack
Nov 30 2018 16:39
@JLuboff you would think but I got lucky haha
Jefferson
@jeffersonnnn
Nov 30 2018 16:39
@JLuboff indeed sigh. Well, i'll figure it out.
Jason Luboff
@JLuboff
Nov 30 2018 16:41
I would just go to using a database if you need to keep the data
Jefferson
@jeffersonnnn
Nov 30 2018 16:41
@JLuboff I envy you right now; React was my first love.
Jason Luboff
@JLuboff
Nov 30 2018 16:42
I prefer my backend stuff still hehe
Jason Luboff
@JLuboff
Nov 30 2018 16:48
React still gets me with properly manipulating state..but.. I'm starting to get the hang of things
Aditya
@ezioda004
Nov 30 2018 16:50
React is the best!
Jason Luboff
@JLuboff
Nov 30 2018 16:50
I mean...its okay... :P
Christopher McCormack
@cmccormack
Nov 30 2018 16:50
@JLuboff I think that's what most people struggle with the most. Once you get it, though, you really get it!
it's not better than Marko!
Jason Luboff
@JLuboff
Nov 30 2018 16:51
You and your Marko
Christopher McCormack
@cmccormack
Nov 30 2018 16:51
haha
Aditya
@ezioda004
Nov 30 2018 16:51
I think ebay is paying @cmccormack
Christopher McCormack
@cmccormack
Nov 30 2018 16:51
I wouldn't mind a sticker at least
Jason Luboff
@JLuboff
Nov 30 2018 16:52
Paying him to not even use it hah
"Just push others to use it!"
Adel
@AdelMahjoub
Nov 30 2018 16:56
@jeffersonnnn yw
Christopher McCormack
@cmccormack
Nov 30 2018 16:57
Can I put Marko proselytizer on my CV?
Jason Luboff
@JLuboff
Nov 30 2018 16:57
Stop making up words @cmccormack
Christopher McCormack
@cmccormack
Nov 30 2018 16:58
haha you don't like that word do you
Jason Luboff
@JLuboff
Nov 30 2018 16:58
I don't even know what it means
I can assume
But I would hate to make an ass out of you and me
Adel
@AdelMahjoub
Nov 30 2018 16:58
@cmccormack I used marko last year, was almost a mix of handlebars / react
Christopher McCormack
@cmccormack
Nov 30 2018 16:59
@AdelMahjoub yeah seems like that
Jefferson
@jeffersonnnn
Nov 30 2018 16:59
@JLuboff well, Backend definitely has its meritss. But React and the whole of Front End just speaks to my Liberal Arts soul haha
Jason Luboff
@JLuboff
Nov 30 2018 16:59
Fair enough lol
Adel
@AdelMahjoub
Nov 30 2018 17:00
in term of front end lib, Vue is a perfict fit for a lot of work, react is going nuts for me
Jefferson
@jeffersonnnn
Nov 30 2018 17:00
@cmccormack stop mentioning Marko so much, you had me skimming through the docs and thinking up a project that i may use it for in the future haha :smiley:
Christopher McCormack
@cmccormack
Nov 30 2018 17:00
@jeffersonnnn why not try it out?
haha
Jefferson
@jeffersonnnn
Nov 30 2018 17:00
@AdelMahjoub Oh my God, I have to say thank you again. Did you see my mail?
Christopher McCormack
@cmccormack
Nov 30 2018 17:00
who knows maybe it will catch on and you'll be one of the few that can claim they have experience in it.
Adel
@AdelMahjoub
Nov 30 2018 17:00
@jeffersonnnn yes, no problem man
now you'll hear, 'Nintendo is using Vue' hahaha
Jefferson
@jeffersonnnn
Nov 30 2018 17:01
@cmccormack that is actually true haha.
Adel
@AdelMahjoub
Nov 30 2018 17:02
yeah, but I don't work for nintendo neither for paypal or coca cola hahaha
so I still use yui hahahaha
Jefferson
@jeffersonnnn
Nov 30 2018 17:02
@cmccormack they should hire you as their developer advocate - at least for online chat rooms
Christopher McCormack
@cmccormack
Nov 30 2018 17:02
yui?
haha they might be me dozens of dollars a year to do that!
Adel
@AdelMahjoub
Nov 30 2018 17:03
@cmccormack yui
it is an attempt to joke
Christopher McCormack
@cmccormack
Nov 30 2018 17:04
lol
man is Yahoo still around?

@JLuboff

verb: convert or attempt to convert (someone) from one religion, belief, or opinion to another.

Jason Luboff
@JLuboff
Nov 30 2018 17:06
Oh shit is that the same damn word you used before to try and get me to use React?
Christopher McCormack
@cmccormack
Nov 30 2018 17:06
hahaha
Adel
@AdelMahjoub
Nov 30 2018 17:06
is Yahoo still around, it seems that any question had its topic at quora
I guess it is still here as dailymotion is
Christopher McCormack
@cmccormack
Nov 30 2018 17:08
My main use of yahoo is to force captive portal in my phone browser when trying to connect to public wifi, that's about it :D
Adel
@AdelMahjoub
Nov 30 2018 17:08
that's why theye are still around
Christopher McCormack
@cmccormack
Nov 30 2018 17:09
look at me, propping up TWO things that noone knows about anymore
Adel
@AdelMahjoub
Nov 30 2018 17:10
that still exists here
Last year I posted for a task on upwork, to build one of those portals :laughing:
Christopher McCormack
@cmccormack
Nov 30 2018 17:11
A captive portal?? why didn't you build it?
Adel
@AdelMahjoub
Nov 30 2018 17:13
the client picked someone else
Christopher McCormack
@cmccormack
Nov 30 2018 17:13
oh I thought you meant you were requesting someone to build it for you
Adel
@AdelMahjoub
Nov 30 2018 17:15
they are still around for sometime, I know that all hospitals here still using them
Jason Luboff
@JLuboff
Nov 30 2018 17:16
So many console.log for debugggggiiinnnngggg
Christopher McCormack
@cmccormack
Nov 30 2018 17:16
@JLuboff VS Code has a debugger
just sayin
Jason Luboff
@JLuboff
Nov 30 2018 17:16
Whatev's homie
Christopher McCormack
@cmccormack
Nov 30 2018 17:17
Don't make me bust out that P word again haha
Jason Luboff
@JLuboff
Nov 30 2018 17:17
I'm not afraid! OH... and it was when you were trying to push VS Code on me that you used that word, not React. I remember!
Christopher McCormack
@cmccormack
Nov 30 2018 17:18
it was probably both
let's see... what can I start pushing for now...
you use ZSH yet?
Jason Luboff
@JLuboff
Nov 30 2018 17:20
NO
Christopher McCormack
@cmccormack
Nov 30 2018 17:22
I'm going to add a few more items to that today actually, found some more useful commands/tools
Jason Luboff
@JLuboff
Nov 30 2018 17:24
You can't make me click that!
Christopher McCormack
@cmccormack
Nov 30 2018 17:24
hmm maybe if I post it enough times you'll accidentally click on it
Jefferson
@jeffersonnnn
Nov 30 2018 17:29
that strategy might work...hmm
please help. how can i orchestrate image uploads ?
i see the multer library, but i don't see how i can insert it here
 create(data) {
     const newRedflag = {
         id: uuid.v4(),
         createdOn: moment.now(),
         createdBy: data.user || '',
         type: data.type || '',
         status: data.type || '',
         image: 
     }
 }
Adel
@AdelMahjoub
Nov 30 2018 17:31
@jeffersonnnn don't head jump first, try multer and check how it works
@jeffersonnnn then you'll have a pitcure on how to model your data
Jefferson
@jeffersonnnn
Nov 30 2018 17:33
@AdelMahjoub okay thennn.
Adel
@AdelMahjoub
Nov 30 2018 17:33
@jeffersonnnn it is only a request body that you will parse and save into a file
@jeffersonnnn you can even try it without multer
Jason Luboff
@JLuboff
Nov 30 2018 17:40
@jeffersonnnn I use multer specifically for my file uploads. I’m going into a meeting but if you have any further questions I’ll see if I can help after
I will say that you most likely want to save the image somewhere on the file system than use a symbolic link in your database. You can upload the image as well using blob I believe but no experience with that
Adel
@AdelMahjoub
Nov 30 2018 17:48
@jeffersonnnn I sometime 'overdo things', last year to confirm to myself that I understand how those file uploads works, I built this image hosting page, it is a good excercice as you'll be challenged to find a structure to properly crud users images, and figure out an appropriate model
and to push things even farther image tools, I wanted to then combine the two services, but lacked motivation for it
Jefferson
@jeffersonnnn
Nov 30 2018 18:05
@JLuboff thanks mn, i'll make sure to drop the questions as they assail meee.
@AdelMahjoub you are awesome, you this man haha.
@AdelMahjoub you fully understand the scale of my project, is multer an overdo in this case. For reference, this are the specifications i'm working with
“​ Images” ​:​ [ Image, Image]​,
"​ Videos” ​:​ [Image, Image]​
Christopher McCormack
@cmccormack
Nov 30 2018 18:09
@jeffersonnnn try not to paste walls of text like that - use a code editor site if it's that long
Adel
@AdelMahjoub
Nov 30 2018 18:10
@jeffersonnnn if you need to upload files using express, then multer is most likely the module you'll need
Jefferson
@jeffersonnnn
Nov 30 2018 18:11
@cmccormack i know this sigh.\
Christopher McCormack
@cmccormack
Nov 30 2018 18:13
No worries @jeffersonnnn
Adel
@AdelMahjoub
Nov 30 2018 18:14
@jeffersonnnn for drag and drop file uploads check dropzone
Jefferson
@jeffersonnnn
Nov 30 2018 18:19

@cmccormack took your advice and jacked open another tab in good ole Sublime Text. @AdelMahjoub so this is the API specification i am trying to work around with

 {
          const newRedflag = {
         id: uuid.v4(),
         createdOn: moment.now(),
         createdBy: data.user || '',
         type: data.type || '',
         status: data.type || '',
         image:
         video:
         comment: data.details || '' 
 }

for the image and video portions, i am stuck with what to use.

Christopher McCormack
@cmccormack
Nov 30 2018 18:21
gotta work on that tabbing
Adel
@AdelMahjoub
Nov 30 2018 18:22
@jeffersonnnn try file uploads in a separate project, all you need is a form and a request handler, read the docs and see how it works, giving you a solution is not a good thing
@jeffersonnnn being stuck is the best thing that could happen when you are learning :laughing:
@jeffersonnnn that mean that all what you'll try and find out will be stuck in your head likely forever
Jefferson
@jeffersonnnn
Nov 30 2018 18:23
@cmccormack think of it as Luke SkyWalker rebelling against the Empire that is AirBnb-ESLint :smile:
@AdelMahjoub wow you wound me :smile:
but i think i see what you mean
Adel
@AdelMahjoub
Nov 30 2018 18:24
@jeffersonnnn that's supposed to help :laughing: maybe I've not expressed it correctly
Christopher McCormack
@cmccormack
Nov 30 2018 18:25
@jeffersonnnn I would agree with @AdelMahjoub , build an example uploader in another project and get it working first
Jefferson
@jeffersonnnn
Nov 30 2018 18:32
I'm browsing through the docs right this minute.
Christopher McCormack
@cmccormack
Nov 30 2018 18:43
depositphotos_166542760-stock-video-portrait-of-man-programmer-hacker.jpg
Adel
@AdelMahjoub
Nov 30 2018 18:50
is that you without the sun glasses?
Christopher McCormack
@cmccormack
Nov 30 2018 18:54
nah that guy probably has hair
Adel
@AdelMahjoub
Nov 30 2018 19:04
it hair on both sides that count, not on top :laughing:
and the beard
Christopher McCormack
@cmccormack
Nov 30 2018 19:05
that was my wedding day, and probably the cleanest beard trim I ever received
guy was a pro
Jason Luboff
@JLuboff
Nov 30 2018 19:09
My beard still comes in thin... my mustache is even worse haha.
Christopher McCormack
@cmccormack
Nov 30 2018 19:11
The trick is...
have genes
Jason Luboff
@JLuboff
Nov 30 2018 19:11
I'm wearing jeans..no difference
Christopher McCormack
@cmccormack
Nov 30 2018 19:11
fair enough lol
Jason Luboff
@JLuboff
Nov 30 2018 19:12
I normally just keep like a 2-3 day stubble or whatever the length that my electric shaver does. Looks alright. But as of right now..haven't shaved since I think the first week of November, so its kind of grown in
Just found some code that does nothing. COOL!
Christopher McCormack
@cmccormack
Nov 30 2018 19:16
There was a study recently that shows women mostly prefer men to have a few days growth but not quite a beard
but that could be just a few percentage points different
@JLuboff probably doesn't do Nothing
probably wastes cycles :)
Jason Luboff
@JLuboff
Nov 30 2018 19:17
I guess I should say that the if condition would never evaluate to true thus it does nothing
I believe its just old code that isn't used anymore
I think its from before I switched to using a modal for the user to select controls related to a hazard
Christopher McCormack
@cmccormack
Nov 30 2018 19:24
hmm shouldn't your linter tell you if you aren't using a function/variable?
Jason Luboff
@JLuboff
Nov 30 2018 19:24
Yes but that isn't the case for this
The linter doesn't detect an if statement that will never execute
Christopher McCormack
@cmccormack
Nov 30 2018 19:24
oh that makes sense
Jason Luboff
@JLuboff
Nov 30 2018 19:25
Si si
Now to refactor and get rid of my nested if/else as to not give @bradtaniguchi an aneurysm
Christopher McCormack
@cmccormack
Nov 30 2018 19:27
this is in React?
Brad
@bradtaniguchi
Nov 30 2018 19:28
@JLuboff Yes, I will find you, and I will force you to refactor!
Jason Luboff
@JLuboff
Nov 30 2018 20:33
@cmccormack In one of my functions (or method i guess)
@bradtaniguchi :joy:
Pagnito
@Pagnito
Nov 30 2018 22:14
ughhhhhh. i wish navigator.onLine was reliable, would make things to simple for me right now T.T
Brad
@bradtaniguchi
Nov 30 2018 23:16
yes, I finally got around to doing an array => map reduce oneliner!
Jason Luboff
@JLuboff
Nov 30 2018 23:44
@bradtaniguchi Stop bragging about it and show us then
Brad
@bradtaniguchi
Nov 30 2018 23:46
const objs = [
  {
    _id: 'obj1',
    name: 'obj one'
  },
  {
    _id: 'obj2',
    name: 'obj two'
  },
  {
    _id: 'obj3',
    name: 'obj three'
  }
];

const map2 = objs.reduce((map, obj) => (map[obj._id] = obj) && map, {});

console.log(map2);

/*
output:"
{ obj1: { _id: 'obj1', name: 'obj one' },
  obj2: { _id: 'obj2', name: 'obj two' },
  obj3: { _id: 'obj3', name: 'obj three' } }

*/
Using an actual Map object is easier tho, probably better to go that route when ya can
Jason Luboff
@JLuboff
Nov 30 2018 23:48
Hmmm.. I'm going to have to study this for a minute or 5 to understand it
Brad
@bradtaniguchi
Nov 30 2018 23:51
The key was those inner parentheses, hehe
Brad
@bradtaniguchi
Nov 30 2018 23:57
without those the thing gets funky and creates an infinite loop of references haha