These are chat archives for FreeCodeCamp/HelpJavaScript

2nd
Jan 2019
Jason Luboff
@JLuboff
Jan 02 00:46
It is common in SQL based servers to have Pascal case for column/table names
Idowu Wasiu
@Hoxtygen
Jan 02 00:50
@JLuboff do you ever sleep?
@JLuboff Or is it that the times zones mightily differs?
Jason Luboff
@JLuboff
Jan 02 01:02
I do sleep. It’s only 5 PM here though
Idowu Wasiu
@Hoxtygen
Jan 02 01:03
@JLuboff sorry, apologies to you.. I always know I'm an idiot........ It's 2:03AM wednesday morning here
Jason Luboff
@JLuboff
Jan 02 01:06
I guess I should ask if you ever sleep 😄
Idowu Wasiu
@Hoxtygen
Jan 02 01:08
@JLuboff yes and no. If I have a problem I can't seem to solve on my own I sacrifice my sleep to learn from you guys here since my day time is pretty filled up
Jason Luboff
@JLuboff
Jan 02 02:18
Fair enough but sleep is important to solving problems 😉
Pagnito
@Pagnito
Jan 02 07:27
hey how do i remove a tooltip that shows up over a cookie, i set it to HttpOnly and i thought that would make it completly unreadable by client
is that done with the secure true
Diego Mayer
@Chrono79
Jan 02 13:13
Happy new year :fireworks:
Jose Pagan
@josepagan
Jan 02 14:24
when I dont sleep well I think my own code is made by a genius :P
Tiago Correia
@tiagocorreiaalmeida
Jan 02 14:25
what's keeping you away of being one? @josepagan :D
Jose Pagan
@josepagan
Jan 02 14:27
@tiagocorreiaalmeida this year i have decided to be a genius. It is my new years resolution, apart from no bread and no fap
XD
Tiago Correia
@tiagocorreiaalmeida
Jan 02 14:29
what has the bread done to you?
BP
@bgq007
Jan 02 14:30
Anyone know of any good videos to explain Node.js? So we can do stuff on our on systems? Typically, when it comes to JS, I just use http://repl.it … I actually really like it, but they even have Node.js as a “language” and I just avoid it for regualr JS.
Idowu Wasiu
@Hoxtygen
Jan 02 14:31
@bgq007 there are tons of them, i'd recommend one of academind, brad traversy or net ninja on youtube
BP
@bgq007
Jan 02 14:39
@Hoxtygen … Thanks. I am familiar with Brad and TNN. I will check them out.
Jason Luboff
@JLuboff
Jan 02 16:16
Morning :wave:
Chris
@crokita
Jan 02 16:17
Heyy
Jason Luboff
@JLuboff
Jan 02 16:17
Happy new year
Chris
@crokita
Jan 02 16:17
Same to you!
Blauelf
@Blauelf
Jan 02 16:17
Happy new year, too.
Jason Luboff
@JLuboff
Jan 02 16:19
:fireworks:
Blauelf
@Blauelf
Jan 02 16:26
At least for followers of the Gregorian calendar. People following the Julian calendar or Chinese or whatever might have other dates.
Jason Luboff
@JLuboff
Jan 02 16:28
Or the jewish calendar :P
Blauelf
@Blauelf
Jan 02 16:29
Must be interesting for the people using a moon calendar. Either insert leap months every now and then (I think the Jewish do it that way?), or rotate the calendar over the years like the Muslims do.
With many Christian holidays being aligned to the moon phases, we also have some traces of moon in ours.
Jason Luboff
@JLuboff
Jan 02 16:34
Ya jewish calendar has leap month
Blauelf
@Blauelf
Jan 02 16:35
Also, since the moon loses energy, it slows down and drifts away from the earth, so moon years will become longer XD
Or was it the other way around? I think it gains energy from the earth, which slows down, allowing the moon to go higher in orbit, with a longer period. Yeah, that would actually make sense.
Christopher McCormack
@cmccormack
Jan 02 16:37
:wave:
Jason Luboff
@JLuboff
Jan 02 16:37
Morning
@Blauelf Sounds like stuff way above my pay grade :P
Blauelf
@Blauelf
Jan 02 16:38
Evening. Pretty dark. But I don't hear the nightingale yet. Might be too cold now, a few weeks ago it always started singing around 5pm.
Jason Luboff
@JLuboff
Jan 02 16:40
@cmccormack Have a good new year?
Christopher McCormack
@cmccormack
Jan 02 16:40
yeah, didn't do much but it was enjoyable enough. you?
Blauelf
@Blauelf
Jan 02 16:40
@JLuboff Most of the energy goes into friction, not into the moon. So it won't fly away too soon.
Recently read the theory that mercury might be a former moon of venus. Interesting stuff :)
Jason Luboff
@JLuboff
Jan 02 16:41
@cmccormack Passed out by 11 :shrug: but had a few friends over yesterday for a little BBQ. Was fun
@Blauelf Would be an interesting sight....seeing the moon fly away haha
Blauelf
@Blauelf
Jan 02 16:44
With days becoming longer, I guess if something is still alive on earth, it will have had time to adapt. It won't be a sudden event for sure.
Christopher McCormack
@cmccormack
Jan 02 16:46
@JLuboff we ended up just cooking tacos and watching cooking competitions until midnight then going to sleep, was not the grandiose party by any means lol
Jason Luboff
@JLuboff
Jan 02 16:47
lol
Blauelf
@Blauelf
Jan 02 16:48
I've seen some documentary where they imagined what life on other, very different planets might look like, including ice planets with liquid water under a few kilometers of ice, and a tide-locked planet (which to their surprise could hold an atmosphere). Much was... artistic interpretation, but on the basis of real simulations.
Jason Luboff
@JLuboff
Jan 02 16:49
@cmccormack Started going through the Info Sec stuff on FCC
Christopher McCormack
@cmccormack
Jan 02 16:49
oh fun
I think some of the examples may be broken
Jason Luboff
@JLuboff
Jan 02 16:50
@Blauelf I remember there was I think a show that Dr. Stephen Hawking narrated or something that was kind of the same thing as what you're describing. Was interesting
@cmccormack Ya... there are. I had installed bcrypt and required it..but it wouldn't pass the test
Christopher McCormack
@cmccormack
Jan 02 16:51
I mean the example not the challenge itself - did you clone the github/glitch boilerplate?
Jason Luboff
@JLuboff
Jan 02 16:53
Oh.. But ya, just using the glitch boilerplate
Christopher McCormack
@cmccormack
Jan 02 16:56
are you stuck or did you figure it out?
Jason Luboff
@JLuboff
Jan 02 16:57
I just moved on. I didn't really care if it didn't recognize that I installed and required bcrypt :shrug:
Dolan
@dguh
Jan 02 17:00

Can someone help me take the following array of arrays
var arr = [["QUARTER",25],["QUARTER",25],["QUARTER",25],["PENNY",1]];

and reduce it down to this array of arrays?
//end result: [["QUARTER",75],["PENNY",1]]

Jason Luboff
@JLuboff
Jan 02 17:06
You could probably just use two loops. Loop over the initial array, and have a secondary empty array that you loop through (second loop). Inside the second loop check to see if you have a matching key (i.e quarter, penny, etc) and if you do, add the value to it otherwise push the value to the secondary array
Dolan
@dguh
Jan 02 17:17
@JLuboff Thanks for the advice. I think I understand what you're saying, but my code is producing an empty array... Would you mind taking a look at it and letting me know where I am going wrong?
Jason Luboff
@JLuboff
Jan 02 17:17
Post it up here, myself and any others will do our best to help
Dolan
@dguh
Jan 02 17:17

var arr = [["QUARTER",25],["QUARTER",25],["QUARTER",25],["PENNY",1]];

var newArr = [];

for (var i = 0; i<arr.length;i++){
for (var j = 0; j<newArr.length; j++){
if (newArr[j][0] == arr[i][0]){
newArr[j][1] = newArr[j][1] + arr[i][1]

} else { 
  newArr.push(arr[i])}

}
}

console.log(newArr);

Jason Luboff
@JLuboff
Jan 02 17:20
Its becuase the second loop never runs. (or that is, j will always be less than newArr.length on initial iteration)
Probably best to add the first element of arr to newArr before the loop
And then skip that element in the first loop (so i = 1)
Eh.. still some issues there actually lol
Dolan
@dguh
Jan 02 17:27
Yeah, I see that.
The above link is very similar to the problem I am trying to solve, but I am not quite sure how to implement it in my case...
Nate Mallison
@NJM8
Jan 02 17:41
Anyone on familiar with html Drag and Drop functionality?
I've made a Kanban board with enough columns that you have to scroll off screen, dragging a a card to the edge of the container in FF and Chrome will automatically scroll the container but Safari does not.
Jason Luboff
@JLuboff
Jan 02 17:45
@dguh
const arr = [["QUARTER",25],["QUARTER",25],["QUARTER",25],["PENNY",1]];

const obj = {};

for (let i = 0; i < arr.length; i++){
    if(obj.hasOwnProperty(arr[i][0])){
  obj[arr[i][0]] = obj[arr[i][0]] + arr[i][1]
  } else {
  obj[arr[i][0]] = arr[i][1];
  }
}

const result = Object.keys(obj).map(e => [e, obj[e]])

console.log(result)
console.log(obj);
Dolan
@dguh
Jan 02 17:48
Thanks! Reading through now.
Blauelf
@Blauelf
Jan 02 17:48
I think the inventory update lesson describes this pretty well. But where is it? The search function leads me to a 404 :(
Jason Luboff
@JLuboff
Jan 02 17:49
Dunno why I didn't think to use an object before lol
@Blauelf Cash register?
Blauelf
@Blauelf
Jan 02 17:50
That's likely this challenge, but this "you have name and amount, and you have another name and amount you have to add on top" appeared in "inventory update".
Jason Luboff
@JLuboff
Jan 02 17:51
Ya...kind of silly that Inventory update comes up in the search but results in 404
Blauelf
@Blauelf
Jan 02 17:53
Since the redesign, I haven't been able to search properly, and I no longer find anything (but forum posts) using Google. Even the search mask itself is bugged (inline search results appear left of the window, where I can only see the line endings)
Slightly unhappy user here :/
Jason Luboff
@JLuboff
Jan 02 17:55
Ya...I think they focused a little too much on quantity over quality for the last update. Still good stuf, don't get me wrong but issues like that are still around even after its been out for this long
I think the new content and structure was a good idea, just the new platform feels broken in so many ways. Test cases passing only on certain browsers (or after reloading the page), search not working properly, ... Feels not right. I understand far too little of these libraries/frameworks to see/fix the core problems, though.
Blauelf
@Blauelf
Jan 02 18:12
Also fun: If stripe (payment provider?) script does not load, even more parts of the page are broken.
Dolan
@dguh
Jan 02 18:30
@JLuboff Just past all of the tests for the Cash Register challenge. Thank you for your help.
passed*
Jason Luboff
@JLuboff
Jan 02 18:30
No problem and good job :thumbsup:
Diego Mayer
@Chrono79
Jan 02 20:46
Not a js question, but I can't find a proper channel, does anybody know why there are spaces between these rows? https://ecommerce.temaiken.org.ar/temaikendelverano/
Tiago Correia
@tiagocorreiaalmeida
Jan 02 20:46
does anyone has an idea what's the work behind tagging users in comments and stuff like that? trying to implement something similiar but can't come up with ideas, if anyone has experience over it
@Chrono79 what rows?confusing to look at it and understand exactaly what you mean :D
Diego Mayer
@Chrono79
Jan 02 20:48
I don't know it it'll help you @tiagocorreiaalmeida but you can see the source code (php) of this phpbb extension: https://www.phpbb.com/customise/db/extension/simple_mentions/
There are 5 images in a table
you can see some white lines between them, even if cellpading is set to 0 and border-collapse to collapse
Tiago Correia
@tiagocorreiaalmeida
Jan 02 20:49
you want to remove the lines then?
or the white space?
Diego Mayer
@Chrono79
Jan 02 20:49
yes
the whitespace
so the images are next to each other
Tiago Correia
@tiagocorreiaalmeida
Jan 02 20:56
found it
took a while
:D
add display:block to the images
Diego Mayer
@Chrono79
Jan 02 20:58
I'd never though about that, any logic reason so I'll remember next time? Thanks btw :+1:
Tiago Correia
@tiagocorreiaalmeida
Jan 02 20:59
I think its because the image is inside an inline element? the tag <a>
but I only discovered it by testing everything that came to mind xd
Diego Mayer
@Chrono79
Jan 02 20:59
lol, so I'd eventually reach that conclusion?
Well, I'll remember it anyway
thx again
Tiago Correia
@tiagocorreiaalmeida
Jan 02 21:01
tbh aswell I had to search around for the main reason and seems that's probably it still
"You're seeing the space for descenders (the bits that hang off the bottom of 'y' and 'p') because img is an inline element by default."
even explained it wrong, imgs are inline elements itself the reason wasn't even the a tag, because you didnt evne touch it after all
Jason Luboff
@JLuboff
Jan 02 21:22
@Chrono79 @tiagocorreiaalmeida :wave: Happy new years
Kelechi Chinaka
@ke1echi
Jan 02 21:24
Happy New Year to everyone
Tiago Correia
@tiagocorreiaalmeida
Jan 02 21:24
happy new year :D
Diego Mayer
@Chrono79
Jan 02 21:24
:wave: the same for all
Jason Luboff
@JLuboff
Jan 02 21:24
@ke1echi Same to you :fireworks:
Kelechi Chinaka
@ke1echi
Jan 02 21:25
@JLuboff I just made the ui for my random quote machine
where do i get a qoute api and how do i use it @JLuboff
not used an api before now
Jason Luboff
@JLuboff
Jan 02 21:25
@Chrono79 I have a question which you maybe able to answer... it involves user sessions.. particularly user sessions that are aware of one another..
@ke1echi I made an API which serves random Simpsons quotes https://thesimpsonsquoteapi.glitch.me/
Kelechi Chinaka
@ke1echi
Jan 02 21:28
how do i get started with the api @JLuboff not used an api before now
Jason Luboff
@JLuboff
Jan 02 21:28
Easiest solution is to use jQuery's $.ajax method
enestatli
@enestatli
Jan 02 21:31
happy new year to everyone
Markus Kiili
@Masd925
Jan 02 21:32
Happy new Year()
Jason Luboff
@JLuboff
Jan 02 21:35
@Masd925 Looks like we got a funny guy here
Kelechi Chinaka
@ke1echi
Jan 02 21:38
there alot of stuff @JLuboff i will see a vid on using ajax
tundeiness
@tundeiness
Jan 02 22:00
I need help on a particular concept I have. I have 2 react component and I want it in such a way that if I click a button on either one of the components, one component is hidden while the clicked component is still available. i'd like to know the best approach to this concept? Looking forward to your responses.
Jason Luboff
@JLuboff
Jan 02 22:04
@tundeiness use two booleans that reside in your state and switch from true to false or visa-versa
{this.state.showBtnOne && <Button...
{this.state.showBtnTwo && <Button...
tundeiness
@tundeiness
Jan 02 22:08
@JLuboff okay. I have really tried some but it's not working too well. But I will try again.
Jason Luboff
@JLuboff
Jan 02 22:09
@tundeiness You would need to modify the state with your onClick method for either button
You can always put what you have into codepen/codesandbox and we can take a look
tundeiness
@tundeiness
Jan 02 22:10
@JLuboff sure I will post the link once I am done
Pagnito
@Pagnito
Jan 02 22:14
is there a way in sql to update a record and get the new record in the callback or promise?
i want to send back the updated user info, i thought it would be the .then(function(updatedData){}) but its not
Jason Luboff
@JLuboff
Jan 02 22:15
@Pagnito Just have a SELECT query which pulls the data
after the update
Pagnito
@Pagnito
Jan 02 22:15
@JLuboff k thnx
Jason Luboff
@JLuboff
Jan 02 22:15
Or you can use inserted.columnname but not positive if thats a MS SQL server only syntax
Pagnito
@Pagnito
Jan 02 22:16
ill just use select for now
Jason Luboff
@JLuboff
Jan 02 22:19

Here's an example..but again not sure if its MS SQL only or not

UPDATE TOP (10) HumanResources.Employee  
SET VacationHours = VacationHours * 1.25,  
    ModifiedDate = GETDATE()   
OUTPUT inserted.BusinessEntityID,  
       deleted.VacationHours,  
       inserted.VacationHours,  
       inserted.ModifiedDate

So inserted would be the new data, deleted. would be the old data

tundeiness
@tundeiness
Jan 02 22:25
@JLuboff so far this is what I have come up with. It's broken actually. need help https://codepen.io/highness/pen/ebNYVX?editors=0010
Jason Luboff
@JLuboff
Jan 02 22:27
Where are the buttons?
tundeiness
@tundeiness
Jan 02 22:33
@JLuboff the red dots on the upper right of the editor and previewer
Jason Luboff
@JLuboff
Jan 02 22:39
Doesn't appear that your toggleDot function ever runs
Ok figured out the issue
You're using this.props.toggleDot in your Editor component.. but you're naming it onClick when you render that component from Apps

Additionally

  toggleDot(){
    this.setState({
      showUp: !showUp
    })
  }

toggleDot doesn't know what showUp is. You need !this.state.showUp

Markus Kiili
@Masd925
Jan 02 22:55
@JLuboff Maybe half a year without doing any JS. Nice change to code something again.
Jason Luboff
@JLuboff
Jan 02 22:57
I'd probably forget half the things I know if I went that long lol
tundeiness
@tundeiness
Jan 02 23:02
@JLuboff okay
@JLuboff I will remove onClick from Apps then
Jason Luboff
@JLuboff
Jan 02 23:04
you can change it to toggleDot = {this.toggleDot}
tundeiness
@tundeiness
Jan 02 23:05
@JLuboff okay
Jason Luboff
@JLuboff
Jan 02 23:06

In Apps

<Editor input={this.state.input} handleChange ={this.handleChange} toggleDot={this.toggleDot} />

And then just leave your Editor component alone

tundeiness
@tundeiness
Jan 02 23:07
@JLuboff okay
@JLuboff without any statement at all?
Jason Luboff
@JLuboff
Jan 02 23:10

What do you mean?

@JLuboff without any statement at all?

tundeiness
@tundeiness
Jan 02 23:26
@JLuboff I meant does that mean that whatever I have previously in my Editor component etc should be removed? eg the onClick?
Jason Luboff
@JLuboff
Jan 02 23:27

In Apps

<Editor input={this.state.input} handleChange ={this.handleChange} toggleDot={this.toggleDot} />

And then just leave your Editor component alone

Pagnito
@Pagnito
Jan 02 23:34
hey how do i get a length of rows ina table, anyone know ?
sql, preferbly knex
tundeiness
@tundeiness
Jan 02 23:37
@JLuboff kindly help take a look at the codepen please. Thank you.
Jason Luboff
@JLuboff
Jan 02 23:38
SELECT COUNT(*) FROM tblName
@Pagnito
Pagnito
@Pagnito
Jan 02 23:38
thnx
Jason Luboff
@JLuboff
Jan 02 23:39
@tundeiness Why did you remove the onclick from Editor?
tundeiness
@tundeiness
Jan 02 23:43
@JLuboff yes.. from the Editor component
Jason Luboff
@JLuboff
Jan 02 23:43
But why did you remove it? I said just modify Apps component and leave Editor alone
tundeiness
@tundeiness
Jan 02 23:45
@JLuboff okay...I have made the change again
Jason Luboff
@JLuboff
Jan 02 23:46
Ok, so the toggle is working
tundeiness
@tundeiness
Jan 02 23:48
@JLuboff no change at my end yet....
Jason Luboff
@JLuboff
Jan 02 23:51

You haven't used that boolean anywhere yet. You would need something like

<span className={this.props.showUp ? "dotGreen" : "dotRed"} onClick={this.props.toggleDot}></span>

(And have the respective classes in your CSS)

And pass showUp to your Editor component. What I like to do is pass the entire state object to the child. You still have to specify your methods.

<Editor 
handleChange ={this.handleChange}
toggleDot = {this.toggleDot} 
{...this.state}/>

So there the entire state object is being passed to Editor so input and showUp are now in your props

Kelechi Chinaka
@ke1echi
Jan 02 23:53
have any particular vidoe you would like me to see about ajax @JLuboff