These are chat archives for FreeCodeCamp/HelpJavaScript

24th
Jan 2018
aRtoo
@artoodeeto
Jan 24 2018 02:24
anyone online??
Isaiah Trembley
@IsaiahCT
Jan 24 2018 02:24
yeah
aRtoo
@artoodeeto
Jan 24 2018 02:24
need help on my simon game.
Isaiah Trembley
@IsaiahCT
Jan 24 2018 02:24
EEEEEEEEEh
I am not the person to ask
hold on
aRtoo
@artoodeeto
Jan 24 2018 02:24
i cant get the logic right on turns heres my pen:https://codepen.io/artoo/pen/opQZWy
@IsaiahCT no bro its fine
Isaiah Trembley
@IsaiahCT
Jan 24 2018 02:25
I must say I like it
iWearDiapers
@iWearDiapers
Jan 24 2018 02:28
i just did Simon recently @artoodeeto
taking a look at your pen...
Isaiah Trembley
@IsaiahCT
Jan 24 2018 02:28
I didn't either hahaha
aRtoo
@artoodeeto
Jan 24 2018 02:28
@iWearDiapers hey bro can i PM you?
iWearDiapers
@iWearDiapers
Jan 24 2018 02:28
sure @artoodeeto
Traek Wells
@TraekWells
Jan 24 2018 11:41
can anyone help me with this? All I want to do is make the big number increment or decrement by one when you click on the plus or minus sign: https://codepen.io/traekwells/pen/rpNyzN
can’t seem to figure out this seemly ‘easy’ thing to do
Aditya
@ezioda004
Jan 24 2018 11:48
@TraekWells Just add document.querySelector(".current-count").textContent = currentCountNumber; in the addOne() function
Likewise add that line in minuseOne() too
Traek Wells
@TraekWells
Jan 24 2018 11:52

@ezioda004 that worked. thanks man. In regards to the updated code

const minus = document.querySelector('.minus');
const add = document.querySelector('.add');
const currentCount = document.querySelector('.current-count');
let currentCountNumber = parseInt(currentCount.textContent);

minus.addEventListener('click', minusOne);
add.addEventListener('click', addOne);

function minusOne() {
  document.querySelector('.current-count').textContent = currentCountNumber;
  currentCountNumber -= 1;
}

function addOne() {
  document.querySelector('.current-count').textContent = currentCountNumber;
  currentCountNumber += 1;
}

do I even need let currentCountNumber = parseInt(currentCount.textContent); ?

CamperBot
@camperbot
Jan 24 2018 11:52
traekwells sends brownie points to @ezioda004 :sparkles: :thumbsup: :sparkles:
:cookie: 413 | @ezioda004 |http://www.freecodecamp.org/ezioda004
Traek Wells
@TraekWells
Jan 24 2018 11:54
@ezioda004 sorry, I meant do I need const currentCount = document.querySelector('.current-count’); ?
Aditya
@ezioda004
Jan 24 2018 11:56
@TraekWells I guess you can use currentCount.textContent = currentCountNumber; instead of the above code or if you require that selector in other parts of your code, but the snippet you have, its not really required.
Traek Wells
@TraekWells
Jan 24 2018 11:59
@ezioda004 right on. Thanks again.
CamperBot
@camperbot
Jan 24 2018 11:59
traekwells sends brownie points to @ezioda004 :sparkles: :thumbsup: :sparkles:
api offline
sabahatullah
@sabahatullah
Jan 24 2018 13:32
Hello, is that a good way to select grand parent (not immediate parent)
document.querySelector(".pdp-carousel .play-icon").parentElement.parentElement
using parentElement.parentElement twice
Stephen James
@sjames1958gm
Jan 24 2018 13:34
@sabahatullah Seems fine to me.
sabahatullah
@sabahatullah
Jan 24 2018 13:38
@sjames1958gm thanks mate. secondly how can I avoid getting null error if element is not defined on the page
CamperBot
@camperbot
Jan 24 2018 13:38
sabahatullah sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8890 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
sabahatullah
@sabahatullah
Jan 24 2018 13:39
image.png
Stephen James
@sjames1958gm
Jan 24 2018 13:43
@sabahatullah well then you have to test first (maybe make a function)
function grandParent(selector) {
   let gran;
   let e = document.querySelector(selector);
   if (e) {
      gran = e.parentElement.parentElement;
   }
   return gran;
}
Marianissimus
@Marianissimus
Jan 24 2018 14:33
hi all. how can you find all objects made with a certain constructor?
Stephen James
@sjames1958gm
Jan 24 2018 14:41
@Marianissimus Unless that constructor keeps track of the objects itself, I am not sure that is possible.
Marianissimus
@Marianissimus
Jan 24 2018 14:44
So in order to push these objects in an array, you need to do so from the very beginning?
Blauelf
@Blauelf
Jan 24 2018 14:48
If you change the constructor to save a reference to each object it creates, you might want to use weak references (for example a WeakSet). Or not, if you need to control the destruction of the object (JavaScript doesn't have a destructor). Weak references do not prevent garbage collection.
Stephen James
@sjames1958gm
Jan 24 2018 14:49
@Blauelf :+1:
Blauelf
@Blauelf
Jan 24 2018 14:53
Oh, sh**. WeakSets cannot be iterated. Then that one might not work the way I thought. So forget it :(
I knew there was something I forgot. I might have used WeakMap (makes sense if you store stuff associated to an object, that you may forget when you no longer have that object), but not WeakSet.

PonyFoo has some example on how one could use HashSet:

const foos = new WeakSet()
class Foo {
  constructor() {
    foos.add(this)
  }
  method () {
    if (!foos.has(this)) {
      throw new TypeError('Foo.prototype.method called on incompatible object!')
    }
  }
}

So not your usecase :-/

Blauelf
@Blauelf
Jan 24 2018 15:02
Wow. There seem to be many people out there that search for weak references, but as JavaScript objects won't be notified of garbage collection, it seems impossible to create one. Thought my Java knowledge (hey, I was there when they dumped it into Java 1.2! Also appreciated Swing added in same release) would carry over a bit.
Blauelf
@Blauelf
Jan 24 2018 15:25
This is JavaScript channel, so that's less relevant. (It's JavaScript, neither JScript nor LiveScript, in the old meaning of LiveScript, and certainly not Java)
Jason Luboff
@JLuboff
Jan 24 2018 16:06
@Blauelf talking to yourself again? :P
Blauelf
@Blauelf
Jan 24 2018 16:07
Nobody wants to talk with me, so what else should I do? ^_^
Jason Luboff
@JLuboff
Jan 24 2018 16:08
:D
Damn it. Still can't claim my garlicoin!
Blauelf
@Blauelf
Jan 24 2018 16:11
I just wanted to leave my thoughts on why my former remark was nonsense in the JavaScript context. I might have erred, but I hope I also have learnt.
Jason Luboff
@JLuboff
Jan 24 2018 16:12
I had never heard of a WeakSet so I learned something new
Blauelf
@Blauelf
Jan 24 2018 16:17
Its uses are limited. I have played around with WeakMap, though.
Jason Luboff
@JLuboff
Jan 24 2018 16:18
Never knew of that either :D
Kelechi Chinaka
@ke1echi
Jan 24 2018 16:20
what are they used for? @Blauelf
@kelechy I think it's mostly security stuff. You can access the value only if you have the key, and if you lose the key, it's gone.
Blauelf
@Blauelf
Jan 24 2018 16:28
@kelechy It was one of the more obscure features introduced in ES6. I also still haven't used proxies, and done little with generators.
May Kittens Devour Your Soul
@diomed
Jan 24 2018 17:34
hello fellow kids
has any of you ever worked with firebase?
& do you know if it's possible to upload json file to it, so it could populate it, then just continue to add things normally
Jason Luboff
@JLuboff
Jan 24 2018 17:37
A simple google search yielded: https://firebase.google.com/docs/database/rest/save-data which talks about uploading different data types including JSON
May Kittens Devour Your Soul
@diomed
Jan 24 2018 17:39
@JLuboff thanks
CamperBot
@camperbot
Jan 24 2018 17:39
diomed sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2306 | @jluboff |http://www.freecodecamp.org/jluboff
Danish Gujjar
@Dani-0-7
Jan 24 2018 17:47
whats wrong?
image.png
oops curly brace
Joshua Arnett
@josha5
Jan 24 2018 17:50
Could anyone help me out with a bubbling event issue I'm having
Kaz Baig
@kbaig
Jan 24 2018 18:00
@Dani-0-7 you have an extra } where you see the exclamation
Christopher McCormack
@cmccormack
Jan 24 2018 18:09
@josha5 what's the question?
Kaz Baig
@kbaig
Jan 24 2018 18:10
@cmccormack he already got help in the Help room
Jason Luboff
@JLuboff
Jan 24 2018 18:10
:wave:
Christopher McCormack
@cmccormack
Jan 24 2018 18:10
cool
@JLuboff @kbaig and hi :wave:
Jason Luboff
@JLuboff
Jan 24 2018 18:11
Whats up?
Christopher McCormack
@cmccormack
Jan 24 2018 18:11
working and stuff
Kaz Baig
@kbaig
Jan 24 2018 18:11
:wave:
Jason Luboff
@JLuboff
Jan 24 2018 18:11
Word.
Apparently a new project has been approved for me to build at work. Will be the first production Node project I'll create..
Kaz Baig
@kbaig
Jan 24 2018 18:12
Noice
Jason Luboff
@JLuboff
Jan 24 2018 18:13
Ya... going to be kind of annoying project lol but should test me a bit
Christopher McCormack
@cmccormack
Jan 24 2018 18:13
@JLuboff sounds like fun man
Jason Luboff
@JLuboff
Jan 24 2018 18:15
Essentially its a "Suggestion" page.. sort of.. an employee puts in a suggestion for how to improve something (workflow, product, whatever) then after they fill out the form, it should email their supervisor, than that supervisor looks it over and either approves or denies..if denies, it stops there otherwise it then goes to a group of 5? or something to then look over, etc. So I need emails to be sent out to alert and use a database (SQL) to store everything etc
Christopher McCormack
@cmccormack
Jan 24 2018 18:17
so you need some way for the supervisor to connect to your webapp and authenticate as a supervisor of that employee to then reject/deny?
Does that mean you need to use your org chart as well?
Jason Luboff
@JLuboff
Jan 24 2018 18:18
@cmccormack Ya... not sure how I'm going to handle it yet. Perhaps use an auth token that they get in the email.. hmm
Christopher McCormack
@cmccormack
Jan 24 2018 18:19
yeah something like that
Pieter Stokkink
@forkerino
Jan 24 2018 18:21
Yo
Jason Luboff
@JLuboff
Jan 24 2018 18:27
@forkerino Yo
@cmccormack And in regards to the org chart, I think I'm just going to create a table in my database that holds all the viable options (shouldn't be terribly long..). Right now I have an IT Request form that individuals can fill out but htey have to manually enter the supervisors email and on more than one occasion they fuck that up. Luckily that gets emailed to the IT group regardless so we can catch that when it happens
Christopher McCormack
@cmccormack
Jan 24 2018 18:32
@forkerino heya!
Pieter Stokkink
@forkerino
Jan 24 2018 18:42
@cmccormack How's life?
Christopher McCormack
@cmccormack
Jan 24 2018 18:43
Good man, got married recently and now settling back into work after a long holiday :)
yourself?
Pieter Stokkink
@forkerino
Jan 24 2018 18:43
Congrats!
Christopher McCormack
@cmccormack
Jan 24 2018 18:43
@forkerino thanks!
CamperBot
@camperbot
Jan 24 2018 18:43
cmccormack sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2973 | @forkerino |http://www.freecodecamp.org/forkerino
Pieter Stokkink
@forkerino
Jan 24 2018 18:44
I'm having some relationship troubles myself. Not the best time of my life.
Christopher McCormack
@cmccormack
Jan 24 2018 18:45
sorry to hear that man
Hope it improves
Pieter Stokkink
@forkerino
Jan 24 2018 18:48
Yeah, me too.
Christopher McCormack
@cmccormack
Jan 24 2018 18:53
@forkerino how's the job going? enjoying it still?
Pieter Stokkink
@forkerino
Jan 24 2018 18:53
@cmccormack yeah, the job is great, and I'm getting a lot of support from them in this situation too, which is touching.
Christopher McCormack
@cmccormack
Jan 24 2018 18:54
@forkerino Sounds like a great team, glad to hear it!
Jason Luboff
@JLuboff
Jan 24 2018 19:29
@forkerino Relationship troubles suck..
Johnny
@JohnnyBizzel
Jan 24 2018 23:03
@forkerino Just been reading your forum post. It's long so I am not finished reading it yet! :+1: Very good though. https://forum.freecodecamp.org/t/some-questions-answered-about-learning-to-code-and-finding-a-job/139873
Jason Luboff
@JLuboff
Jan 24 2018 23:03
@JohnnyBizzel Johnny!
Johnny
@JohnnyBizzel
Jan 24 2018 23:03
@JLuboff what's up?
Jason Luboff
@JLuboff
Jan 24 2018 23:04
Not a whole lot. How're you? Haven't seen you around
Johnny
@JohnnyBizzel
Jan 24 2018 23:04
@JLuboff I dip in and out but the forum is where I go more nowadays.
Jason Luboff
@JLuboff
Jan 24 2018 23:04
I don't like the forum :(
Johnny
@JohnnyBizzel
Jan 24 2018 23:05
@JLuboff I have been learning VueJs and Python recently but also have tried to do the D3 challenge "heat map"
@JLuboff why don't you like the forum?
Jason Luboff
@JLuboff
Jan 24 2018 23:06
I've been learning C#, been rebuilding an inhouse app from VB to C# (and adding some much needed improvements).
I like the chat environment. Can talk much easier IMO
Johnny
@JohnnyBizzel
Jan 24 2018 23:06
@JLuboff Ah yes. I need to learn MVC (again)!
@JLuboff Seems to be less busy (the chat). Plus you get some random non FCC questions.
@JLuboff If Stephen James is about I usually leave (he's the daddy!)
Jason Luboff
@JLuboff
Jan 24 2018 23:09
The chat is definitely less busy then the old days.. but.. if they'd just reinstate the built in chat it'd be florishing again
Johnny
@JohnnyBizzel
Jan 24 2018 23:09
@JLuboff The built in chat, you mean the help next to the challenges?
@JLuboff By the way, did you use a VB C# converter :P
@JLuboff I used them all the time lol!
Jason Luboff
@JLuboff
Jan 24 2018 23:10
...maybe? Its been so long since I've used it that way I forget but I think so. I use the gitter app instead of the browser version
Johnny
@JohnnyBizzel
Jan 24 2018 23:11
I have gitter, discord and slack on my phone. It beeps all day!
Jason Luboff
@JLuboff
Jan 24 2018 23:11
@JohnnyBizzel Nope, built the C# app from scratch (well, looked over the VB code and changed as needed). There was a lot to change, such as protecting the SQL queries from SQL Injection
Johnny
@JohnnyBizzel
Jan 24 2018 23:11
Nice one
Jason Luboff
@JLuboff
Jan 24 2018 23:12
I believe you sent me a BV to C# converter before actually
Johnny
@JohnnyBizzel
Jan 24 2018 23:12
Jason Luboff
@JLuboff
Jan 24 2018 23:14
You showed me that app in fact as well!
Johnny
@JohnnyBizzel
Jan 24 2018 23:14
I converted that to C#
Ha ha. I am getting predictable!
Jason Luboff
@JLuboff
Jan 24 2018 23:16
:D
I'm not crazy about using Windows Forms.. but seems easier than switching to WPF
Johnny
@JohnnyBizzel
Jan 24 2018 23:17
Yes, I wrote it ages ago.
I should probably do it in JS now
Jason Luboff
@JLuboff
Jan 24 2018 23:18
There ya go
A new challenge :D
Johnny
@JohnnyBizzel
Jan 24 2018 23:19
I had another idea. Based on an old Google app.
Google used to do a custom desktop where you could add apps.
Jason Luboff
@JLuboff
Jan 24 2018 23:20
hmmm I don't recall it
Johnny
@JohnnyBizzel
Jan 24 2018 23:20
One was "Time since" which was quite practical.
So you say for example "got hair cut" and it logged the date.
Then it would count the days since you did that task in future.
So you can quickly see how long ago since you did certain things.
Jason Luboff
@JLuboff
Jan 24 2018 23:22
Oh thats pretty nice
Johnny
@JohnnyBizzel
Jan 24 2018 23:22
Could be done with local storage.