These are chat archives for FreeCodeCamp/HelpJavaScript

10th
Dec 2018
Pagnito
@Pagnito
Dec 10 2018 00:46
hmmmmmmmmmmmmmm
auth works on heroku, but not with firebase
works perfect with firebase serve, but not deployed
Pagnito
@Pagnito
Dec 10 2018 00:59
sigh...none of my god damn logs are showing up in the firebase logs
Donnie
@Donnie-D
Dec 10 2018 03:05
Silly little thing if anyone could answer please. In the following little case I would prefer the code to 'return' the result for the amount of times the loop runs instead of using console.log. But 'return' seems to overwrite the previous return. Can I retain all the results from return on console?
https://repl.it/repls/MaroonHorizontalSets
Alwin George
@siliconchild
Dec 10 2018 03:12
@Donnie-D use this code

  for (var i=0; i<=10; i++){
    function times(a){
      return a*i;
  }
  console.log(times(2));
}
when times(2) is called initially the output returned is 0 and when the loop runs again it changes to 2 , then 4 and so forth.
in your case you got the final return value, which is 20
since you want to display the returned value from function each time wrap the function call in console.log() like i did
Donnie
@Donnie-D
Dec 10 2018 03:18
silly me. :thumbsup: Alwin
Alwin George
@siliconchild
Dec 10 2018 03:19
Also write the code like this

for (var i=0; i<=10; i++){
  console.log(times(2));
}

function times(a){
      return a*i;
}
take the function declaration out of the loop
Donnie
@Donnie-D
Dec 10 2018 03:20
looks good this way :accept:
Alwin George
@siliconchild
Dec 10 2018 03:22
otherwise you are redeclaring the function 10 times
Donnie
@Donnie-D
Dec 10 2018 03:23
thats nice. this way we are only calling it 10 times as it should be :thumbsup:
Alwin George
@siliconchild
Dec 10 2018 03:27
I suppose you just started learning about loops and functions, if that is the case. I would strongly recommend the free course 'Practical javascript' from watchandcode.com
it's unlike all other tutorials
the structure in which he introduces concepts is amazing
Donnie
@Donnie-D
Dec 10 2018 03:28
:thumbsup: shall look into it mate. thanks for the reference :smiley:
Alwin George
@siliconchild
Dec 10 2018 03:29
glad to help :)
Pagnito
@Pagnito
Dec 10 2018 03:47
i got margin top problems with firefox
this is what i got with chrome and all other browsers ive checked so far, opera, brave, bing
and even safari
Screen Shot 2018-12-09 at 10.47.28 PM.png
this is what i get in firefox
Screen Shot 2018-12-09 at 10.47.36 PM.png
asjdbaskjdfb asfhjvasjhfasvflka
Alwin George
@siliconchild
Dec 10 2018 03:49
@Pagnito are you using flecbox for layout
Pagnito
@Pagnito
Dec 10 2018 03:49
yea
Alwin George
@siliconchild
Dec 10 2018 03:50
in firefox flexbok has bugs when setting margin in relative units i believe. I used to run across this bug
I dont remember exactly
are you using margin in rem/em ?
Pagnito
@Pagnito
Dec 10 2018 03:51
px
Alwin George
@siliconchild
Dec 10 2018 03:51
oh, now i remeber margins set ans % values seem to cause this for me in firefox
px should be fine
Pagnito
@Pagnito
Dec 10 2018 03:51
well its not lol
Alwin George
@siliconchild
Dec 10 2018 03:52
I don't know then sorry
do you have the code on codepen
?
Pagnito
@Pagnito
Dec 10 2018 03:52
altho u did help my friend
if i set position static
the margins behave same way in both browsers
i really didnt want to change that layout and now i dont have to
Alwin George
@siliconchild
Dec 10 2018 03:56
glad you found a fix. yeah flexbox implementation vary a lot across browsers, mostly safari. safari used to me give a lot of issues
Pagnito
@Pagnito
Dec 10 2018 05:48
Anyone know how to optimize svg animations?
Any browser thats not using chromium as im guessin...seems to struggle with animations.
zdman135
@zdman135
Dec 10 2018 06:07

trying to figure out why my 2nd jquery event click is not working. I can’t seem to run:
$('.class').on("click", function () { });
$('.class').on("click", function () { });

and the 2nd click event is never triggered.
Here is the codepen: https://codepen.io/zdman135/details/madzpe

the only way I seem to get it to trigger is if I put the 2nd one inside the first one, which I would rather not do, if I can help it. cause that can get messy. Like this:
$('.class').on("click", function () { $('.class').on("click", function () { }); });
zdman135
@zdman135
Dec 10 2018 06:25
Nvm, I solved my issue. here’s the answer in case others wanted to know:
https://stackoverflow.com/questions/11154458/the-second-click-function-is-not-working
Precious adeyinka
@precious-adeyinka
Dec 10 2018 10:28
Hello guys, good morning from here.
Zaza
@ForkInSpace
Dec 10 2018 12:15
Morning @precious-adeyinka
Spyrantis Theodoros
@thodorisanta
Dec 10 2018 15:45
Are the last 2 lines doing the same thing?
var objectName = {
  a: 2,
  m: function() {
    return this.a + 1;
  }
};


var p = Object.create(objectName );  // IS THIS THE SAME
var p = new objectName (); // AS THIS?
Precious adeyinka
@precious-adeyinka
Dec 10 2018 15:54
@ForkInSpace wadup bro, good morning!
@thodorisanta Yeah they are?
Aditya
@ezioda004
Dec 10 2018 15:56
@thodorisanta The 2nd line should throw an error, new is only used with a constructor function or class.
Jason Luboff
@JLuboff
Dec 10 2018 16:13
Morning
Aditya
@ezioda004
Dec 10 2018 16:14
:wave:
Jason Luboff
@JLuboff
Dec 10 2018 16:15
Whats up
Aditya
@ezioda004
Dec 10 2018 16:20
Chillin like a villain
What about you?
Christopher McCormack
@cmccormack
Dec 10 2018 16:20
morning
Jason Luboff
@JLuboff
Dec 10 2018 16:21
Just got to work...starting the day
Christopher McCormack
@cmccormack
Dec 10 2018 16:22
same
Jason Luboff
@JLuboff
Dec 10 2018 16:23
How was the weekend
Aditya
@ezioda004
Dec 10 2018 16:25
It was a weekend? Crap
Jason Luboff
@JLuboff
Dec 10 2018 16:25
Lol
Christopher McCormack
@cmccormack
Dec 10 2018 16:27
@ezioda004 accidentally work all weekend? :)
@JLuboff mine was good, spent most of it with the wife. Looked at a few new houses just in case we do move back to Phoenix
Jason Luboff
@JLuboff
Dec 10 2018 16:29
So...a third house?
Christopher McCormack
@cmccormack
Dec 10 2018 16:29
yeah lol
Aditya
@ezioda004
Dec 10 2018 16:29
@cmccormack Nah didnt realize, no work til next week!
Christopher McCormack
@cmccormack
Dec 10 2018 16:29
but would probably sell at least one of them
@ezioda004 personal work is still work right?
Jason Luboff
@JLuboff
Dec 10 2018 16:29
Jeez...wish I could afford one house here lol.. one day though
Aditya
@ezioda004
Dec 10 2018 16:30
If you mean sleeping and killing time, a lot of personal work was done
Christopher McCormack
@cmccormack
Dec 10 2018 16:30
excellent haha
Tom
@moT01
Dec 10 2018 16:30
:house:
Christopher McCormack
@cmccormack
Dec 10 2018 16:30
@moT01 heya
Tom
@moT01
Dec 10 2018 16:31
hello
whats everyone up to this morning
Christopher McCormack
@cmccormack
Dec 10 2018 16:33
@moT01 some more api scripting for work. you?
Tom
@moT01
Dec 10 2018 16:34
not much, doing one of these files on the guides
Jason Luboff
@JLuboff
Dec 10 2018 16:34
Continue working on this SSRS report...React project...have some surface pros and regular desktops to get ready for deployment.. too much :)
Tom
@moT01
Dec 10 2018 16:35
trying to do one per day, it's going much faster with them being organized by file changed
Christopher McCormack
@cmccormack
Dec 10 2018 16:37
@moT01 the PRs? Which are you doing?
Tom
@moT01
Dec 10 2018 16:37
no shortage of work then @JLuboff
Christopher McCormack
@cmccormack
Dec 10 2018 16:37
@JLuboff sounds like fun :)
Jason Luboff
@JLuboff
Dec 10 2018 16:37
Definitely no shortage
Tom
@moT01
Dec 10 2018 16:38
im doing the 10 simple linux commands file right now
Christopher McCormack
@cmccormack
Dec 10 2018 16:38
@moT01 I hate that one, such low effort PRs and much more work for the reviewer
Tom
@moT01
Dec 10 2018 16:38
which should be renamed, since there's way more than 10 on it now
Christopher McCormack
@cmccormack
Dec 10 2018 16:38
right :)
it should be deleted
so much redundancy
or maybe a brief summary of all commands in one file, linking to a guide
Tom
@moT01
Dec 10 2018 16:39
hmm, maybe it should just be deleted - I think there's another file on linux commands as well
Christopher McCormack
@cmccormack
Dec 10 2018 16:39
there's even a whole dir full of bash-[command] files that don't make any sense, they aren't specific to bash...
Precious adeyinka
@precious-adeyinka
Dec 10 2018 16:40
@ezioda004 True, but i think he meants literally, not in this context right @ @thodorisanta ?
Tom
@moT01
Dec 10 2018 16:41
yea, it's messy
Aditya
@ezioda004
Dec 10 2018 16:41
@precious-adeyinka Umm, I see object literal with new keyword, not sure what other context this could be taken as.
Precious adeyinka
@precious-adeyinka
Dec 10 2018 16:42
@ezioda004 lolllll
Tom
@moT01
Dec 10 2018 16:42
I feel like it would be faster to just close all the pr's on the file and rewrite it myself
Christopher McCormack
@cmccormack
Dec 10 2018 16:43
@moT01 :thumbsup: it would certainly look better, I've had the same thought many times
Precious adeyinka
@precious-adeyinka
Dec 10 2018 16:44
@ezioda004 I see it more like a question combination just like i first make a statement and then later compares it to probably something else , but it looks like am talking in relation to what I already said, but I could be wrong its fine, I thought he meant generally, cause they both create and instance of an object, but in this snippet above, the second line would definitely cause an error. Agreed :+1::
Jason Luboff
@JLuboff
Dec 10 2018 17:52
Damn PM2.. forgot I had to reload to get it to reread the ecosystem file even if you restart the service
Spyrantis Theodoros
@thodorisanta
Dec 10 2018 17:58
@precious-adeyinka @ezioda004 so i have to change the constructor name to objectName first and then it will work? thats what you're saying? But in general those two do the same thing right? Cause my experience so far tells me that whenever there are more than 1 way to do something there is also a "catch" somewhere xD
Christopher McCormack
@cmccormack
Dec 10 2018 17:59
@JLuboff whomp whomp
Jason Luboff
@JLuboff
Dec 10 2018 17:59
@cmccormack It provided a few moments of frustration lol
I have three modes... dev, staging, and production.. so I set ENV_NODE and my own MODE variable. It wasn't reading the MODE variable
Aditya
@ezioda004
Dec 10 2018 18:06
@thodorisanta There is no constructor function there. But yes both (Object.create and constructor func) would create a prototype link.
Back in the day hacks like this were used:
Dog.prototype = (function(){
  function tmp(){};
  tmp.prototype = Animal.prototype;
  return new tmp();
}())
Brad
@bradtaniguchi
Dec 10 2018 19:31
ba bam
Jason Luboff
@JLuboff
Dec 10 2018 19:32
Bam Bam?
Brad
@bradtaniguchi
Dec 10 2018 19:33
idk I was bored, and drank to much coffeee
Jason Luboff
@JLuboff
Dec 10 2018 19:45
Lol fair enough
Alright...got my SSRS report working with parameters
Brad
@bradtaniguchi
Dec 10 2018 19:55
Nice, even tho idk what that is hehe
Jason Luboff
@JLuboff
Dec 10 2018 19:59
SQL Server Reporting Services... so basically a front end for SQL for reports
Brad
@bradtaniguchi
Dec 10 2018 19:59
So it automatically does the front-end for ya right?
Pagnito
@Pagnito
Dec 10 2018 20:03
Screen Shot 2018-12-10 at 3.03.00 PM.png
i got this, but for some reason one of my fonts isnt loading on some refreshes, then sometimes it loads, and then it wont etc
hmm
i had cache disabled i think it somehow messed wit it
even tho offline still worked, those fonts werent coming thru half the time
Jason Luboff
@JLuboff
Dec 10 2018 20:07
@bradtaniguchi No...not really.. lol You still have to format it and group and add filters and parameters and..etc. It just gives you the tools for the front end (think WinForm for VB/C#)
Brad
@bradtaniguchi
Dec 10 2018 20:10
Ah I see
Jason Luboff
@JLuboff
Dec 10 2018 20:13
Ya..it setup in a way that you don't have to be an expert to get a report built
Precious adeyinka
@precious-adeyinka
Dec 10 2018 20:48
@thodorisanta Yeah sure there is a catch, But they basically do same thing which is to instantiate an instance of the constructor object yeah... So but the idea is basically the same but there are differences, maybe go read more about the differences umm I recommend this book: "Essential Javascript" I promise you will love it...
@thodorisanta if you have other questions I could help with please don't hesitate to contact me.
Spyrantis Theodoros
@thodorisanta
Dec 10 2018 21:03
@precious-adeyinka thanks! you're too generous!
Jason Luboff
@JLuboff
Dec 10 2018 22:10
:fire:
Brad
@bradtaniguchi
Dec 10 2018 23:20
Stupid prettier not formatting html correctly :(
Jason Luboff
@JLuboff
Dec 10 2018 23:22
I find prettier can be great...or complete fuck things up. It does not like hbs for example
Brad
@bradtaniguchi
Dec 10 2018 23:24
Yea idk what happened, it was fine. But like the last few weeks it formats html all funky.
Jason Luboff
@JLuboff
Dec 10 2018 23:26
Works fine with React :shrug:
Brad
@bradtaniguchi
Dec 10 2018 23:27
I was reading an issue for it... its related to prettier assuming all html is react html XD
Jason Luboff
@JLuboff
Dec 10 2018 23:27
:joy:
Christopher McCormack
@cmccormack
Dec 10 2018 23:34
is prettier even made for regular html?
Jason Luboff
@JLuboff
Dec 10 2018 23:35
Are you even made for regular html?
Christopher McCormack
@cmccormack
Dec 10 2018 23:35
@JLuboff No :crying_cat_face:
Jason Luboff
@JLuboff
Dec 10 2018 23:35
heh
Christopher McCormack
@cmccormack
Dec 10 2018 23:36

How can I improve this?

console.logobj = ((...args) => 
    args.forEach(arg => console.log(util.inspect(arg, false, null))))

What do you guys think of this?

it's to log a full object to the console (e.g. using Node)
Jason Luboff
@JLuboff
Dec 10 2018 23:37
Hmmm.. what would you guys say is the best option to have for having an user verify something (in this case, verify they are done entering in steps for a job) from a UX perspective? Thinking modal...but.. I also have modals in the next section so not sure if I want that many
Christopher McCormack
@cmccormack
Dec 10 2018 23:38
you mean a way for you to determine they are done with a section?
Can you use the fantastic American Express https://github.com/americanexpress/react-albus library?
Jason Luboff
@JLuboff
Dec 10 2018 23:39
Ya.. the requestor(s) don't think these guys are bright enough to understand when they click a button that says "Complete Job Steps" that they know what it means.. so they want the user to verify that Yes..they have completed entering the job steps. And then in the next section...also have a back button to the job steps.. :anguished:
Also.. I have nothing to change in your code above
Christopher McCormack
@cmccormack
Dec 10 2018 23:43
@JLuboff I realized that having a log each iteration would not add a space between arguments like console.log so now trying
console.logobj = ((...args) =>
    console.log(args.map(arg => util.inspect(arg, false, null)).join(' ')))
@JLuboff what about collapsing each section when not being worked and showing some status if it's completed or not, or not started if you aren't to that step yet?
Jason Luboff
@JLuboff
Dec 10 2018 23:45
Hmmm...
I could always use tabs... only active once they are completed...
Then there would be no need for back button or for the step confirmation
Or even a breadcrumb
@cmccormack Thanks for spurring some ideas
Christopher McCormack
@cmccormack
Dec 10 2018 23:50
np
Jason Luboff
@JLuboff
Dec 10 2018 23:52
Man...all my React files have a mix of ' and "...I hate it lol