These are chat archives for FreeCodeCamp/HelpJavaScript

7th
Aug 2018
ArchivalBoat50
@ArchivalBoat50
Aug 07 2018 06:34
Hey guys does anyone see why the log is saying that arr.indexOf() is not a function?
var bookList = ["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "PhilosophiƦ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"];

function add(arr, bookName) {

  return arr.push(bookName);


}


function remove(arr, bookName) {
  if (arr.indexOf(bookName) >= 0) {

    return arr.splice(arr.indexOf(bookName), 1, bookName);

  }
}

var newBookList = add(bookList, 'A Brief History of Time');
var newerBookList = remove(bookList, 'On The Electrodynamics of Moving Bodies');
var newestBookList = remove(add(bookList, 'A Brief History of Time'), 'On The Electrodynamics of Moving Bodies');

console.log(bookList);
Blauelf
@Blauelf
Aug 07 2018 06:43
@ArchivalBoat50 push returns the new array length, not the array. splice returns an array of removed elements.
ArchivalBoat50
@ArchivalBoat50
Aug 07 2018 07:39
@Blauelf Thanks
ATom M
@ATom-M
Aug 07 2018 12:22
Anyone need a hand?
Mark
@vinarius
Aug 07 2018 12:52
Morning all
Garrus Napp
@GarrusNapp
Aug 07 2018 12:53
morning
Jen
@jenniredfield
Aug 07 2018 13:50
@Blauelf how come you are always here? I remember logging in last year in this chat room and you were already here
Kelechi Chinaka
@ke1echi
Aug 07 2018 14:08
that's because everyday is a learning-day @jenniredfield
Diego Mayer
@Chrono79
Aug 07 2018 14:33
@jenniredfield he's an IA ;)
A pretty advanced one
Jason Luboff
@JLuboff
Aug 07 2018 15:11
They say @Blauelf never eats or sleeps.
Christopher McCormack
@cmccormack
Aug 07 2018 15:14
@JLuboff :wave:
Jason Luboff
@JLuboff
Aug 07 2018 15:16
@cmccormack Yoo
Christopher McCormack
@cmccormack
Aug 07 2018 15:17
what's up man?
Jason Luboff
@JLuboff
Aug 07 2018 15:18
Just got into work.. checking on the databases.. see that a request has been put in on my app, so its working, pretty happy about that
Christopher McCormack
@cmccormack
Aug 07 2018 15:19
nice!
just sit back and drink Mai Tais now right?
Jason Luboff
@JLuboff
Aug 07 2018 15:19
If only ;)
Whats up with you?
Christopher McCormack
@cmccormack
Aug 07 2018 15:20
Trying to figure out why traffic isn't properly traversing this port channel from a Nexus VPC to a vSwitch LAG
Jason Luboff
@JLuboff
Aug 07 2018 15:20
Ya ya for sure man
(Thats beyond my networking knowledge haha)
Christopher McCormack
@cmccormack
Aug 07 2018 15:21
probably mine too, vswitch is strange and not my area of expertise
but the server guys keep saying everything is fine
same ol' argument
Jason Luboff
@JLuboff
Aug 07 2018 15:23
haha sounds like my coworkers. We installed VOIP phones several months back and we have issues where they drop and my manager was convinced it had to do with QOS on the switches and my network guy was saying No, and they were talking smack behind each others back lol
Christopher McCormack
@cmccormack
Aug 07 2018 15:25
could be qos :) shouldn't run voice without qos really
it's very sensitive
Jason Luboff
@JLuboff
Aug 07 2018 15:26
Oh I get that, but apparently the Cisco switches have some sort of QoS that doesn't need to be configured? I don't recall what he said about it
Christopher McCormack
@cmccormack
Aug 07 2018 15:29
I believe they have a trust dcscp marking command that may be default
and the phones probably mark
Jason Luboff
@JLuboff
Aug 07 2018 15:30
Ya...that sounds like it
Christopher McCormack
@cmccormack
Aug 07 2018 16:01
I had to deconstruct how this all works from another project
Jason Luboff
@JLuboff
Aug 07 2018 16:03
The switch stuff?
Christopher McCormack
@cmccormack
Aug 07 2018 16:05
Oops that was meant for another channel my apologies :)
Prakash Kumar
@ThePrakashKumar
Aug 07 2018 16:06
I got stuck in ES6 class any tutorial will be highly appreciated.
Christopher McCormack
@cmccormack
Aug 07 2018 16:06
@ThePrakashKumar what did you get stuck with?
It's good to have something specific to refer to
Prakash Kumar
@ThePrakashKumar
Aug 07 2018 16:08
@cmccormack I am having problem like what is constructor function, what is the use new and I need more explanation of class index.
Tried some YT videos but didn't go well.
Jefferson
@jeffersonnnn
Aug 07 2018 16:42

Hey guys, i have a question please. So i am going through an answer in Stack Overflow (i need to find the duplicates in an array) and i saw this

function hasDuplicates(array) {
    var valuesSoFar = Object.create(null);
    for (var i = 0; i < array.length; ++i) {
        var value = array[i];
        if (value in valuesSoFar) {
            return true;
        }
        valuesSoFar[value] = true;
    }
    return false;
}

Everything makes sense but var valuesSoFar = Object.create(null); , does anyones know what that is meant to do? Apparently, it is a hash table

Brad
@bradtaniguchi
Aug 07 2018 16:43
@jeffersonnnn Object.create(null) is one of those tricks out there
Jason Luboff
@JLuboff
Aug 07 2018 16:44
So...it's really exciting that people are using my app...
Brad
@bradtaniguchi
Aug 07 2018 16:44
Id consider just doing var valuesSoFar = {} to be good enough for most cases. I wouldn't resort to "trick-js" techniques unless they are warranted, and in this case I don't really see any benefit. Unless its clear of its behavior to you, and your team, its a "trick" so I wouldn't do it haha
unless value in valuesSoFarreturns false for a basic object... hmm not sure there tho :P
Jefferson
@jeffersonnnn
Aug 07 2018 16:51
@bradtaniguchi so there is something of an equivalence between var valuesSoFar = {} and var valuesSoFar = Object.create(null);
Aditya
@ezioda004
Aug 07 2018 16:52
@jeffersonnnn Object.create(null) creates a new object with its prototype set to null, so this object doesnt inherit any prototype methods from Object.
Brad
@bradtaniguchi
Aug 07 2018 16:52
^
Blauelf
@Blauelf
Aug 07 2018 16:54
@jenniredfield I am procrastinating all the time, that is what I am here for. And for the good feeling whenever I am of help.
Jefferson
@jeffersonnnn
Aug 07 2018 16:54
@bradtaniguchi now i get it. Sigh. And i spent a solid 10 minutes hitting my head over this thing. Haha. Trick.js seems the be the word for it :D. Nice one and thanks!
@JLuboff i really have no idea what your app is about, but i'm here shouting Hurrah from this end of the Interwebs. Congratulations on your app being used by real life people, man \0/, now all the edge cases you never thought off are about to be revealed :D
Blauelf
@Blauelf
Aug 07 2018 16:58
@jeffersonnnn Consider something like hasDuplicates(["hasOwnProperty"]), a regular object with a non-null prototype would "inherit" a property of that name.
Christopher McCormack
@cmccormack
Aug 07 2018 16:59
@JLuboff which app?
Jason Luboff
@JLuboff
Aug 07 2018 17:00
@jeffersonnnn Thanks man! It's an app for creating Management of Change Requests (so essentially when a facility needs to change something that is not like in kind or needs special approvals, etc). So its essentially a bunch of forms with a lot of emailing but also centralizes everything within a database
@cmccormack My work app! 3 new requests today and they're being actively worked on!
Blauelf
@Blauelf
Aug 07 2018 17:02
@jeffersonnnn With ES6, Set and Map might replace Object.create(null) in many cases
Jefferson
@jeffersonnnn
Aug 07 2018 17:03
@JLuboff amazing. i like the fact that is a business/corporate - oriented app. It is going to definitely be put through its paces. Database parts are things i need to work on personally, so i admire the verve !
@Blauelf Set definitely tries to answer my question straight out of the box seeing as it doesn't accept duplicated entries. I was on the look out for something that can be backwards compatible if i need it to be
Jason Luboff
@JLuboff
Aug 07 2018 17:05
@jeffersonnnn That it will. I've become fairly comfortable with databases. I'd say I'm proficient at Mongo especially after taking the M101JS course through Mongo University and decently proficient at T-SQL (Microsoft SQL), and actually am taking a certification test on that tomorrow. Database's are actually kind of fun. Trying to figure out queries to get just the data you need/want
Jefferson
@jeffersonnnn
Aug 07 2018 17:09
@JLuboff pysched for you. Mongo sigh. Okay, first off, how did you start with it? Any tutorial (Udemy et al) you can point us all to? Soon as i can get something steady with React and Redux, i'm going backend ASAP. I have so many ideas, but this inhuman need for a steady paying job is terrible
Christopher McCormack
@cmccormack
Aug 07 2018 17:10
@JLuboff awesome man! Any feedback?
Jason Luboff
@JLuboff
Aug 07 2018 17:13
@jeffersonnnn I understand the need for a job, I study at work so I'm lucky in that regard. But for mongo, I have taken a uDemy course that was more of a node/express that touched on Mongo and then just doing the FCC challenges. But the big help was the M101JS course from Mongo University. ITs free, but you have to wait until its available (every 8 weeks I think)
@cmccormack None so far, but I'm watching all the emails and what not
Brad
@bradtaniguchi
Aug 07 2018 17:23
relational database design is a big deal too, can't forget that
Jason Luboff
@JLuboff
Aug 07 2018 17:23
Yes... I've redesigned my database probably 100 times since I started this project
Brad
@bradtaniguchi
Aug 07 2018 17:24
Yea... that doesn't sound good haha
Jason Luboff
@JLuboff
Aug 07 2018 17:24
Well I built the database as I built the app so thats how that happened
Brad
@bradtaniguchi
Aug 07 2018 17:25
Yea, especially if requirements change. But id argue changing the database later is prolly the hardest thing to change, when compared to say some front-end design choices or something else
but I digress, I'm the guy in the corner throwing criticism without actually doing anything haha im sorry
Jason Luboff
@JLuboff
Aug 07 2018 17:26
True. I had to quickly change the design on Friday prior to having it go to production becuase of a requirement change
I didn't think you were throwing any criticism, you were just stating truths lol
Brad
@bradtaniguchi
Aug 07 2018 17:27
Definantly an advantage for noSql DB's if the requirements change you can say no probs :sunglasses:
Jason Luboff
@JLuboff
Aug 07 2018 17:28
True
Jason Luboff
@JLuboff
Aug 07 2018 18:09
And the changes start rolling in
Christopher McCormack
@cmccormack
Aug 07 2018 20:01
:roller_coaster: @JLuboff
Jason Luboff
@JLuboff
Aug 07 2018 20:24
@cmccormack I had to roll over that to see what it was lol. Already got the fixes in before going to lunch
Christopher McCormack
@cmccormack
Aug 07 2018 20:39
so efficient
Jason Luboff
@JLuboff
Aug 07 2018 20:41
It was easy things haha. Filter out an email, require a field (it had been, but found handlebars wasn't processing it for some reason), and disable submit button until refresh (apparently they have a hard time not pressing it twice.. :anguished: )
Brad
@bradtaniguchi
Aug 07 2018 20:43
hitting enter won't submit the form again.... right?
Jason Luboff
@JLuboff
Aug 07 2018 20:44
Hitting enter doesn't submit, have to click it
Brad
@bradtaniguchi
Aug 07 2018 20:45
gotta ask :P
Jason Luboff
@JLuboff
Aug 07 2018 20:45
Ya, there's too many buttons on the page for enter to be submit lol
Brad
@bradtaniguchi
Aug 07 2018 20:46
haha
Jason Luboff
@JLuboff
Aug 07 2018 20:47
But when you submit, I do have a notification pop up to show success/failure....and technically you can still submit until all approves are done..but..meh. They just have to refresh the page to be able to redo it lol
Brad
@bradtaniguchi
Aug 07 2018 20:48
no cancel?
Jason Luboff
@JLuboff
Aug 07 2018 20:48
No cancel for..?
Brad
@bradtaniguchi
Aug 07 2018 20:59
what do you mean refresh to redo? haha
Jason Luboff
@JLuboff
Aug 07 2018 20:59
So there's three fields Date, Approve, Comment They can change these as many times as they like until all approvers (6 currently) have approved.