These are chat archives for FreeCodeCamp/HelpJavaScript

22nd
Jun 2018
Brad
@bradtaniguchi
Jun 22 2018 00:00
Id say once you solve the problem, try to optimize your code for performance and readability. Just do parts at a time, and run thru the tests after each part. If your tests suddenly fail, then back up and try again
You CAN just forget it and move on, and tell yourself "ill come back and clean this up later" but lets be serious you wont haha.
Same idea applies in the real world :D
koder3
@koder3
Jun 22 2018 00:01
Ahaahah to be exact I was planning to comeback after I get more experienced with algorithms over on leetcode
btw if youve used leetcode is the cash register challenge on freecodecamp comparable to the leetcode hard challenges in terms of difficulty?
Brad
@bradtaniguchi
Jun 22 2018 00:02
Ive never used leetcode so I can't say for sure. The cash register challenge in FCC isn't that easy IMO, I actually never got around to finishing it haha
koder3
@koder3
Jun 22 2018 00:03
Hmm its what made me quit fcc for a while to focus on school xD
but it seems easier now
Brad
@bradtaniguchi
Jun 22 2018 00:04
Yea its always good to come back after a while, for a refresher, or with more knowledge :)
koder3
@koder3
Jun 22 2018 00:04
Yeah thanks anyway
ttyl
Brad
@bradtaniguchi
Jun 22 2018 00:05
np :D
Teac
@chtic123
Jun 22 2018 03:26
Caesars Cipher
Long Nguyen
@longnt80_gitlab
Jun 22 2018 07:15
class A {
  set x(x){
    this._x = x;
  }

  set y(y){
      this._y = y;
  }
}

class B extends A{
  get x(){
    return this._x;
  }

  get y(){
      return this._y;
  }
}

let b = new B();
b.x = 100;
console.log(b.x); //undefined
why does this happen?
Johnny
@JohnnyBizzel
Jun 22 2018 09:20
@longnt80_gitlab TypeError: Cannot set property x of #<B> which has only a getter .
Put the setters in class B and it will work.
Blauelf
@Blauelf
Jun 22 2018 09:52
Interesting, but makes sense. JavaScript delegation works on properties, so the one with getter only will shadow the one with setter only.
Simon Cordova
@gbsimon87
Jun 22 2018 10:20
@bradtaniguchi very true, I've now been back in the community for a few days after a couple of months hiatus and it feels great
Need some serious review in certain areas though
PS morning guys
Ozarion
@Ozarion
Jun 22 2018 11:03
let ohRegex = /Oh{3,6}/;
Why is it matching "Ohhhhhhh no"?
Blauelf
@Blauelf
Jun 22 2018 11:17
Why not? There's certainly a "Ohhhhhh" in there. The regular expression as you wrote it might match any substring, not just whole words.
Ozarion
@Ozarion
Jun 22 2018 11:18
Oh. What Am I missing here.?
Lazy quantifier?
Blauelf
@Blauelf
Jun 22 2018 11:19
Do you want to surround the word with \b? Totally depends on what you really want to match.
Ozarion
@Ozarion
Jun 22 2018 11:19
I want to match "Ohhh" through "Ohhhhhh" only.
Blauelf
@Blauelf
Jun 22 2018 11:19
Lazy or greedy defines what exactly is matched, not whether there is a match.
So like /^Oh{3,6}$/ or more like /\bOh{3,6}\b/?
BTW, how did your account get fixed?
Ozarion
@Ozarion
Jun 22 2018 11:21
It didn't. I made another one. XD
Ogundele Olumide
@Lumexralph
Jun 22 2018 11:23
@Blauelf Hallo.... I have been gone like forever
Blauelf
@Blauelf
Jun 22 2018 11:23
Haven't seen @camperbot for a while. Maybe he's on vacation.
Ozarion
@Ozarion
Jun 22 2018 11:23
Thanks @Blauelf /\bOh{3,6}\b/ worked.
Blauelf
@Blauelf
Jun 22 2018 11:24
@Ozarion \b matches a null-space between a word character and a non-word character (word characters are alphanumeric plus underscore). Also matches string ends IIRC.
Ozarion
@Ozarion
Jun 22 2018 11:26
@Blauelf I see. Thanks!
NikolaNbgd
@NikolaNbgd
Jun 22 2018 13:07
Hello folks! Does anyone know how to disable forward button through js? Thanks in advance
mpmaan
@mpmaan
Jun 22 2018 13:09
maybe setting disable attribute will do the job
NikolaNbgd
@NikolaNbgd
Jun 22 2018 13:13
attribute on what?
mpmaan
@mpmaan
Jun 22 2018 13:14
attribute of the forward button
in jquery it will be something like $('button').attribute('disabled');
i don't know correct syntax
NikolaNbgd
@NikolaNbgd
Jun 22 2018 13:15
I think you don't understand me :)
mpmaan
@mpmaan
Jun 22 2018 13:16
then please explain what you want
NikolaNbgd
@NikolaNbgd
Jun 22 2018 13:16
How can I set attribute disabled on forward button in browser?
I am talking of back and forward button which every browser have, top left
mpmaan
@mpmaan
Jun 22 2018 13:18
yeah but i don't know how to achieve that functionality
NikolaNbgd
@NikolaNbgd
Jun 22 2018 13:19
I don't blame you, same here :/
mpmaan
@mpmaan
Jun 22 2018 13:20
won't that cause trouble for users?
like if i visited your website then some other website and came back to your website then i can't use my forward button
NikolaNbgd
@NikolaNbgd
Jun 22 2018 13:24
The problem is next, I have one page for user validation with id and pass (this is for now hardcoded, so pass and id are static I give my user pass and id), now, when user submit form he goes to another page and that is cool
but
when user click back button in the browser he is backed to the validation page and when clicks forward button from that page he goes to another page without validation
that is the problem
and that's why I want to disable forward button
mpmaan
@mpmaan
Jun 22 2018 13:27
suppose you got everything you are asking for but the user(mischievious one) may note down the url of the next page and then he can still go to that forbidden page
are you using some authentication?
NikolaNbgd
@NikolaNbgd
Jun 22 2018 13:29
yes, that is true
no
this is all hardcoded for now
that is how client wants
mpmaan
@mpmaan
Jun 22 2018 13:30
lol ..what?..so you might be comparing the user_id and password from some data..where is that data stored?
history.replaceState() operates exactly like history.pushState() except that replaceState() modifies the current history entry instead of creating a new one. Note that this doesn't prevent the creation of a new entry in the global browser history.
from MDN
if user is able to login successfuly then he will be redirected to your forbidden page
you then get the browser history and then update the entry for the forbidden page in browser history to the home page of website
in that way if user clicks forward button he will visit the homepage
this might work
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:09
Guys please help me at this
mpmaan
@mpmaan
Jun 22 2018 14:12
if(i % j === 0){
    break;
}
it should be this
and you only push the number to array when the loop has finished
also use j <= Math.sqrt(i)
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:14
I did like you said but it still doesn't work
mpmaan
@mpmaan
Jun 22 2018 14:15
because i typed it wrong
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:15
And I know that I only push the number to array when the loop has finished but how?
mpmaan
@mpmaan
Jun 22 2018 14:15
though the loop condition needs to be updated like i said
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:16
Yeah I did that before you respond.
mpmaan
@mpmaan
Jun 22 2018 14:17
you can check after loop ends if(j > Math.sqrt(i) then arr.push(i)
it means that the loop executed as many times it could or break was never executed
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:18
I'm confused, I don't have a condition like that.
mpmaan
@mpmaan
Jun 22 2018 14:18
i mean you need to add that condition after your second loop ends
And I know that I only push the number to array when the loop has finished but how?
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:19
It still doesn't work sadly
Maybe the problem is the logic I used?
mpmaan
@mpmaan
Jun 22 2018 14:20
give updated complete code here and also look into the last comment on forum
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:20
Oh, are you the same person?
mpmaan
@mpmaan
Jun 22 2018 14:21
no that's someone else but that person gave good info regarding reduce()
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:21
Yeah.
It still doesn't solve the problem although ):
mpmaan
@mpmaan
Jun 22 2018 14:22
give me your new code here ..that's the only way i can help you
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:22
OKAY
mpmaan
@mpmaan
Jun 22 2018 14:22
i'm not good at teaching
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:22
I meant Okay
Sorry for the big capitals

function sumPrimes(num) {
var arr = [];
for (var i = 2; i < num; i++) {
if(i === 2 || i === 3) {
arr.push(i);
}
for (var j = 2; j <= Math.sqrt(i);j++) {
if (i % j === 0) {
break;
}
}
if (j > Math.sqrt(i)) {
arr.push(i);
}
}
console.log(arr);
return arr.reduce((before,after) => before + after,0);
}

sumPrimes(10);

Blauelf
@Blauelf
Jun 22 2018 14:25
For i of 2 or 3, both pushes will trigger.
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:26
Isn't that the point?
I mean, it pushes both 2 and 3
Blauelf
@Blauelf
Jun 22 2018 14:27

It pushes both twice. Also,

Sum all the prime numbers up to and including the provided number.

OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:27
including the provided number?
You mean num or i?
Blauelf
@Blauelf
Jun 22 2018 14:28
So i <= num
mpmaan
@mpmaan
Jun 22 2018 14:28

function sumPrimes(num) {
  var arr = [];
  for (var i = 2; i <= num; i++) { //upto and including num
    if (i === 2 || i === 3) {
      arr.push(i);
      continue; // no need to check anything else
    }
    for (var j = 2; j <= Math.sqrt(i); j++) {
      if (i % j === 0) {
        break;
      }
    }
    if (j > Math.sqrt(i)) {
      arr.push(i);
    }
  }
  console.log(arr);
  return arr.reduce((before, after) => before + after, 0);
}

sumPrimes(10);
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:29
Oh wow it fixed it
mpmaan
@mpmaan
Jun 22 2018 14:29
do you now understand what @Blauelf was telling
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:29
I understand most of it
except i <= num
why I should do that?
I don't understand
Blauelf
@Blauelf
Jun 22 2018 14:30
Sum all the prime numbers up to and including the provided number.
mpmaan
@mpmaan
Jun 22 2018 14:30
because if num = 13
then we have to count upto and including 13
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:30
Oh yeah because 13 itself is a prime number
Oh so I limited myself to 10(since 10 is not prime then <= will not affect it but another number like 13 will get affected)
Thank you a lot for help, you both
It helped more than that "your array returns 9" guy.
mpmaan
@mpmaan
Jun 22 2018 14:31
haha ..also get ready for upcoming challenges
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:31
Are they hard?
mpmaan
@mpmaan
Jun 22 2018 14:32
i'll say more challenging than what you have done until now
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:33
Well, for now, I solved most of my past challenges without an issue but omg if this test wasn't already hard for me.
Blauelf
@Blauelf
Jun 22 2018 14:33
I guess everybody has their own definition of "hard". And they might not overlap at all. But challenges tend to become more complex.
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:33
I spent 4 hours searching for a good algorithm for prime numbers
So I guess that the coming challenges will be nothing but more challenging than what I have already done.
mpmaan
@mpmaan
Jun 22 2018 14:34
i guess you don't have any programming background
like c/c++ or anything like that
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:35
Well, I programmed in Java, Python, Csharp.
But only the basics and I was like 13-12
mpmaan
@mpmaan
Jun 22 2018 14:35
that makes sense
But only the basics and I was like 13-12
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:35
Anyway, am I that bad to the point where I look like that have no programming background? ):
mpmaan
@mpmaan
Jun 22 2018 14:36
nope
i thought like someone who knows programming will most likely have implemented a program for prime number earlier before diving into web dev
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:38
Yeah, well, I didn't do that because the resources I read are pretty awful and I didn't know exactly what I am doing. Anyway, I only program for fun.
I don't really seriously look for a job or to work by programming. Fun is all what I need.
Anyway, just 2 questions, Is React hard? And can I skip it in Libaries/frameworks section?
Blauelf
@Blauelf
Jun 22 2018 14:40
Getting into the "thinking like a programmer" can probably help in ways other than coding jobs.
mpmaan
@mpmaan
Jun 22 2018 14:40
i hated programming(because i didn't know how c/c++ program can be used to build something) until i started web dev
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:41
Can thinking like a programmer help me in math problems?
That would be great if it's true.
mpmaan
@mpmaan
Jun 22 2018 14:41
@Blauelf yeah, most people will agree with that
how to approach a problem and devise a strategy without thinking about how to implement it helps
@OGTechnoBoy you can skip bootstrap, jquery, sass if you know them already but it will only take a hour to solve them (kind of like revision)
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:45
Jquery lessons in Freecodecamp honestly needs love.
And Bootstrap is painfully boring.
mpmaan
@mpmaan
Jun 22 2018 14:45
i'm currently doing react..feels easy
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:45
I didn't study Sass yet although but I plan in doing it. I hear that it introduced stuff like variables and nesting
mpmaan
@mpmaan
Jun 22 2018 14:45
sass is easy too
just know how to use variable , looping, if else , nesting
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:46
If you would choose between Jquery and React, what you will choose?
mpmaan
@mpmaan
Jun 22 2018 14:46
first i'll go with jquery
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:46
I don't know what I choose, people in internet are saying that Jquery is outdated and that React is better and modern but I don't know the difference between the two
Isn't Jquery supposed to help you with manipulating DOM? How React is going to provide you the same feature? I thought that React is suppose to "render" the view.
mpmaan
@mpmaan
Jun 22 2018 14:47
jquery is kinda outdated but jquery have been already used so much that it's everywhere
jquery vs react isn't a comparison
they are diffrent things
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:48
I know that but people in internet keep comparing between both.
mpmaan
@mpmaan
Jun 22 2018 14:49
jquery is userfriendly javascript and react help in creating (reactive) ui components
lol..i've heard of angular vs react vs vue but never heard about jquery vs react
Simon Cordova
@gbsimon87
Jun 22 2018 14:49
@OGTechnoBoy the main difference is that React deals with what is known as a 'virtual' Dom
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:50
Believe me, a lot of people compare between two.
mpmaan
@mpmaan
Jun 22 2018 14:50
i need to surf the net a bit more
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:50
@gbsimon87 Yes but is React going to give me a toolbox?
Simon Cordova
@gbsimon87
Jun 22 2018 14:50
This, in simple terms, is a copy of the current DOM, but instead of having to update the ENTIRE dom (say when you just need to change an element) React will not do that, it will simply update the part of the DOM that needs updating
@OGTechnoBoy no it will not. While jQuery you could say is all about DOM manipulation, React, Angular, and Vue are more among the likes of declaring how the DOM should look at a particular instance in time.
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:51
Isn't that like AJAX?
mpmaan
@mpmaan
Jun 22 2018 14:52
@OGTechnoBoy yeah you were right , i found this...now i know why you were confused
Simon Cordova
@gbsimon87
Jun 22 2018 14:53
@OGTechnoBoy it's 'like' AJAX in the sense that in order to update a web page you don't need to reload the page, but AJAX is a whole different topic
mpmaan
@mpmaan
Jun 22 2018 14:53
jquery is slow compared to javascript and react uses es6 kinda stuff
Simon Cordova
@gbsimon87
Jun 22 2018 14:53
You can use AJAX to fetch from and post data to a server
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:53
I heard that Jquery 3.2 uses ES6 too
Simon Cordova
@gbsimon87
Jun 22 2018 14:53
And you can use this with vanilla JS, jQuery, React, etc...
mpmaan
@mpmaan
Jun 22 2018 14:54
i started learning react today itself so don't know enough
Simon Cordova
@gbsimon87
Jun 22 2018 14:54
@OGTechnoBoy If I can recommend, before you touch up jQuery or React or anything, understand how vanilla JS works
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:55
Can you give me some point where I should stop and start using other libararies?
Simon Cordova
@gbsimon87
Jun 22 2018 14:55
What jQuery methods do is simply Javascript written in a simpler syntax, but if you don't get what is going on behind the scenes, when you encounter problems you're going to have a toughey
Take beginner JS lessons, and TAKE YOUR TIME to understand it, it doesn't come in a day.
The best advice most developers can give you is DON'T LOSE HOPE
Christopher McCormack
@cmccormack
Jun 22 2018 14:56
Seriously, don't disregard anything until you know what it's used for and when to use it
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:56
I'm studying Javascript 1 month ago and recently, I finished all my lessons from freecodecamp
I even completed all the basic algorithm challenges
Simon Cordova
@gbsimon87
Jun 22 2018 14:57
And abuse the knowledge from guys here such as @cmccormack himself who will offer great help along the journey
That's what I did, and still do :)
mpmaan
@mpmaan
Jun 22 2018 14:57
i think learning about basic js + api handling,ajax, json, dom manipulation with vanilla js is enough
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:57
Thanks for the advice.
Simon Cordova
@gbsimon87
Jun 22 2018 14:57
@mpmaan is enough is sort of a loose term. Is enough for what exactly?
mpmaan
@mpmaan
Jun 22 2018 14:58
for moving onto other libraries
haha
Christopher McCormack
@cmccormack
Jun 22 2018 14:58
The Frontend projects are designed to help you take your current Javascript knowledge and start applying it. It's here where you actually start to learn Javascript, IMO
Simon Cordova
@gbsimon87
Jun 22 2018 14:58
I second @cmccormack's comment, it's how I got started 2.5 years ago
Christopher McCormack
@cmccormack
Jun 22 2018 14:59
And if you want to get better, do one in vanilla JS, try one with jQuery, try one with React, keep building using new tools so you understand WHY you would use them
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 14:59
Yeah, there are libraries/frameworks projects.
mpmaan
@mpmaan
Jun 22 2018 15:00
but current challenge should have provided some api example to learn about ajax,json before front end library certification
i learned all that stuff what i told earlier first then for learning jquery i went through their documentation
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 15:02
It depeneds on how useful JSON is.
mpmaan
@mpmaan
Jun 22 2018 15:02
might not work for everyone
OGTechnoBoy
@OGTechnoBoy
Jun 22 2018 15:02
I know about AJAX but what about JSON?
Honestly, the only use I heard about JSON is that it helps you with noSQL databases like MongoDB
Christopher McCormack
@cmccormack
Jun 22 2018 15:02
The order is odd but the Data Visualization Cert has Async exercises
mpmaan
@mpmaan
Jun 22 2018 15:02
just take a look at w3school and you will know enough about json
Jason Luboff
@JLuboff
Jun 22 2018 15:06
Morning :wave:
Christopher McCormack
@cmccormack
Jun 22 2018 15:06
@JLuboff yo
@JLuboff I think I saw a message saying you were switching to VS code, that right?
Jason Luboff
@JLuboff
Jun 22 2018 15:06
@cmccormack Lol noppppeeee
Christopher McCormack
@cmccormack
Jun 22 2018 15:06
haha
Jason Luboff
@JLuboff
Jun 22 2018 15:06
Brad thought I was using VS code, but I was talking about VS community
Christopher McCormack
@cmccormack
Jun 22 2018 15:07
like totally different acryonym initialism right
Jason Luboff
@JLuboff
Jun 22 2018 15:07
Totally
Simon Cordova
@gbsimon87
Jun 22 2018 15:10
@JLuboff whats up whats up
I was thinking of trying out vs code, just to see what the fuzz is about really
buzz I should say
Christopher McCormack
@cmccormack
Jun 22 2018 15:12
I like fuzz better
Jason Luboff
@JLuboff
Jun 22 2018 15:12
Just got into work. Changing a SQL query right now since I wrote it with a syntax that won't work with our version :worried:
Christopher McCormack
@cmccormack
Jun 22 2018 15:12
Try it! It has a great extension system, built in git, tons of features, yet fairly light weight
Simon Cordova
@gbsimon87
Jun 22 2018 15:14
Im just versed with ST3 shortcuts now my workflow would change, but it never hurts to expand the toolset
and I certainly like the sound of built in git
Jason Luboff
@JLuboff
Jun 22 2018 15:15
Atom has built in git too...so there! I still use the CLI for git but nice to see files be marked so I know I need to make a commit
Christopher McCormack
@cmccormack
Jun 22 2018 15:16
@gbsimon87 there is an extension for sublime text shortcuts!
Simon Cordova
@gbsimon87
Jun 22 2018 15:16
What are you guys using?
Oh really, that extension would be key Ill look for it thx @cmccormack
Christopher McCormack
@cmccormack
Jun 22 2018 15:17
yup with 700K installs and 5 stars
another great thing is so many people are using it the extensions are usually pretty bug free
Jason Luboff
@JLuboff
Jun 22 2018 15:25
Do you guys ever lay awake at night thinking "How can I improve my code..." and then a lightbulb goes off and you'
re like "YES!"
Christopher McCormack
@cmccormack
Jun 22 2018 15:25
yup
I hate it
mpmaan
@mpmaan
Jun 22 2018 15:25
yeah
Christopher McCormack
@cmccormack
Jun 22 2018 15:25
I don't want to bring that to my sleep
although figuring out a solution is still pretty great :)
mpmaan
@mpmaan
Jun 22 2018 15:26
when i broke my windows i was dreaming about how to fix it while sleeping
Jason Luboff
@JLuboff
Jun 22 2018 15:27
I figured out my query last night lying awake...and then this morning realized how I can make part of my app more dynamic... sigh it's never ending
Although...final app review should be next week :+1:
Christopher McCormack
@cmccormack
Jun 22 2018 15:27
@JLuboff that's funny - it tends to be mostly DB calls I think of as well
Simon Cordova
@gbsimon87
Jun 22 2018 15:27
Lolol no joke I had a dream last night about my react state structure after you guys were helping me here
Christopher McCormack
@cmccormack
Jun 22 2018 15:28
@gbsimon87 in my last React app I put almost all my state in a Context component, made it so much easier :)
Simon Cordova
@gbsimon87
Jun 22 2018 15:28
Context api?
Isnt in beta still or am I mistaken?
Christopher McCormack
@cmccormack
Jun 22 2018 15:28
no its been out in production for a few months
they may still call it beta not sure but they're ok with people using it
Simon Cordova
@gbsimon87
Jun 22 2018 15:29
Hmmm good to know
so redux is a monster itself so i was thinking of trying mobx - currently all my info is in the top level components state
Christopher McCormack
@cmccormack
Jun 22 2018 15:29
@gbsimon87 I made a pen when first playing with context if you want to check it out https://codepen.io/cmccormack/pen/wjRGvz?editors=0010
Simon Cordova
@gbsimon87
Jun 22 2018 15:30
ill check it thx man
Christopher McCormack
@cmccormack
Jun 22 2018 15:31
yeah I never liked all the work that went into redux, but I also didn't like prop drilling, context api made it a lot easier
mpmaan
@mpmaan
Jun 22 2018 15:31
is the react browser extension any helpful?
Christopher McCormack
@cmccormack
Jun 22 2018 15:31
very
Simon Cordova
@gbsimon87
Jun 22 2018 15:31
Yes, you need it if youre working with react, basically essential really
Jason Luboff
@JLuboff
Jun 22 2018 15:32
@cmccormack Yup.. both things are basically DB stuff. Right now I have my app making this retarded DB call to get the approvers for a request... well. there's 4 individuals that are static...but potentially could change in the future.. so.. how do I make it dynamic? Simple.. make a seperate table in my DB that holds just those individuals and then call to that... then the person in charge of the requests can change those later as needed without me needing to change code :+1:
Simon Cordova
@gbsimon87
Jun 22 2018 15:32
the dom will only display your htnl tag elements but not your component, state, props etc
Christopher McCormack
@cmccormack
Jun 22 2018 15:32
it's so nice to be able to toggle props and see what it does, see your component tree, see where you may be passing something undefined
It's kind of slow though
@JLuboff are those 4 always added to a request?
Jason Luboff
@JLuboff
Jun 22 2018 15:37
@cmccormack Yes but could change in the future (there's two others added as well, but those are location dependent)
Markus Kiili
@Masd925
Jun 22 2018 15:37
Evening.
Christopher McCormack
@cmccormack
Jun 22 2018 15:37
@JLuboff interesting. The way our system works ( I think ) is that changes are on a specific object and that object is owned by a team, so all changes on an object will have a group of approvers
Jason Luboff
@JLuboff
Jun 22 2018 15:38
@Masd925 Yo
@cmccormack Ya so basically there are (as of now) 6 total approvers for a request. 4 are static in that they are on all requests, while 2 are dynamic as they are location specific
Markus Kiili
@Masd925
Jun 22 2018 15:38
@JLuboff Maybe its time for me to do some FCC projects again. It is about half a year from the previous one.
Jason Luboff
@JLuboff
Jun 22 2018 15:39
@Masd925 Do it! Especially now that there are new ones
Christopher McCormack
@cmccormack
Jun 22 2018 15:39
Yeah it's been fun filling in the missing ones. They're pretty simple but you can try out stuff you haven't used before
@JLuboff you do the survey/landing page?
Jason Luboff
@JLuboff
Jun 22 2018 15:40
I haven't done any of the projects yet, haven't really worked on the curriculm for a while now lol
Markus Kiili
@Masd925
Jun 22 2018 15:41
@JLuboff I made one on my own and just added it into my portfolio. Simple ajax graphQL app that shows nearby departing public transport vehicles.
Simon Cordova
@gbsimon87
Jun 22 2018 15:41
@Masd925 hello!
Jason Luboff
@JLuboff
Jun 22 2018 15:41
I like my error handling emails :+1: Sends me my route and error that occured
Markus Kiili
@Masd925
Jun 22 2018 15:41
@gbsimon87 Hi. How are you?
Jason Luboff
@JLuboff
Jun 22 2018 15:41
@Masd925 OH ya I remember you working on that
Simon Cordova
@gbsimon87
Jun 22 2018 15:42
@Masd925 Im good, long time, back in action these days
Howve you been?
Markus Kiili
@Masd925
Jun 22 2018 15:42
@JLuboff It has been working for quite a while. Finally had some time to fix some bugs and add some details.
@gbsimon87 Quite ok. Learning Clojure for some months. Looking for a new job because the last one wasn't for me.
Jason Luboff
@JLuboff
Jun 22 2018 15:44
@Masd925 That job didn't work out? You weren't there too long were you?
Markus Kiili
@Masd925
Jun 22 2018 15:45
@JLuboff Three weeks was enough.
Jason Luboff
@JLuboff
Jun 22 2018 15:46
Culture no good?
Markus Kiili
@Masd925
Jun 22 2018 15:47
@JLuboff It didn't suit me. Also had to work with mac that I haven't touched before.
Jason Luboff
@JLuboff
Jun 22 2018 15:48
Ah
Simon Cordova
@gbsimon87
Jun 22 2018 15:50
Fair enough.
Sorry to hear it wasnt for you, but theres always the next one :)
Jason Luboff
@JLuboff
Jun 22 2018 16:31
Ah...feels good to write a more efficient query
Christopher McCormack
@cmccormack
Jun 22 2018 16:34
@JLuboff haha nice
Jason Luboff
@JLuboff
Jun 22 2018 16:35
New Query cost: 36% compared to 64% of the other (when running in a batch together)
Christopher McCormack
@cmccormack
Jun 22 2018 16:35
you index too?
Jason Luboff
@JLuboff
Jun 22 2018 16:37
Thats just using the default created PK index. Not enough records to make a difference with a proper index I don't reckon
Simon Cordova
@gbsimon87
Jun 22 2018 16:48
Which database are you guys referring to?
Jason Luboff
@JLuboff
Jun 22 2018 16:54
@gbsimon87 Microsoft SQL
Brad
@bradtaniguchi
Jun 22 2018 17:02
ew database
Jason Luboff
@JLuboff
Jun 22 2018 17:03
Don't be a hater
Brad
@bradtaniguchi
Jun 22 2018 17:07
Hey man I love all levels of the stack, but databases are a pain in the backend :P
mpmaan
@mpmaan
Jun 22 2018 17:13
i finished react challenges ...should i move onto redux or try to build something?
Brad
@bradtaniguchi
Jun 22 2018 17:16
I say, build something. I am somewhat against "state management", but you can see the benefits if you DONT have it to start with
But then I'm not a React guy, (I use Angular) so dont take what I said as if an expert said it :D
Jason Luboff
@JLuboff
Jun 22 2018 17:24
@bradtaniguchi Databases can definitely be a pain..but..seeing as how I'm going to be/am our DBA..I kind of have to like it :joy:
Brad
@bradtaniguchi
Jun 22 2018 17:25
DBA's make all the money, cuse they got all the data XD
Jason Luboff
@JLuboff
Jun 22 2018 17:25
Yup. Once I get my MCSA I'll get a nice pay bump
Brad
@bradtaniguchi
Jun 22 2018 17:26
Databases are my ultimate fallback, the least flashy, but probably the most job secure :D
Jason Luboff
@JLuboff
Jun 22 2018 17:30
Database's are an interesting thing. While I don't love them... I also kind of like them.
Markus Kiili
@Masd925
Jun 22 2018 17:36
@JLuboff I think that they are the one true :heart: I have in IT.
6th and 5th and Boyce-Codd, who wouldn't fall in love.
Brad
@bradtaniguchi
Jun 22 2018 17:38
love of databases? Love is a strong word
Jason Luboff
@JLuboff
Jun 22 2018 17:41
@Masd925 Why don't you become a DBA/SQL programmer?
Markus Kiili
@Masd925
Jun 22 2018 17:42
@bradtaniguchi Maybe I have love towards the beauty of relational theory, but when we have to use SQL that is not relational, the feeling tends to fade.
@JLuboff Maybe the grass is just greener outside the front-end stuff I have done for work.
Jason Luboff
@JLuboff
Jun 22 2018 17:45
:smile:
Markus Kiili
@Masd925
Jun 22 2018 17:50
@JLuboff I have a problem choosing which backend language to study. I have done some java and some clojure, but also the JS backend stuff seems interesting.
Jason Luboff
@JLuboff
Jun 22 2018 17:50
I'd probably go with whatever you see the most jobs available in lol
Markus Kiili
@Masd925
Jun 22 2018 17:52
@JLuboff Yeah. Not many jobs with clojure here, so maybe I will stop with that when I manage to build something with it.
Jason Luboff
@JLuboff
Jun 22 2018 18:02
Good idea
Brad
@bradtaniguchi
Jun 22 2018 18:23
that moment someone starts asking how todo what your product is doing........
Or I should say, ask how to build something that sounds a hell of a lot like your product
Jason Luboff
@JLuboff
Jun 22 2018 18:31
You then sell them your product
Brad
@bradtaniguchi
Jun 22 2018 18:39
They are trying to build something like it haha, but its not exact, so no they aren't a threat :P
Jason Luboff
@JLuboff
Jun 22 2018 18:43
I'd still sell it to them.
Diego Mayer
@Chrono79
Jun 22 2018 18:43
Hi @all
Anyone familiar with MySQL and transactions? I need to do a couple of inserts in 2 different databases hosted in the same server and I want to make sure both went well or make a rollback and throw an error message
Jason Luboff
@JLuboff
Jun 22 2018 18:45
@Chrono79 ...I know a bit of MS SQL and transactions...
You probably want some Try/Catch blocks (assuming you can do that in MySQL)
Diego Mayer
@Chrono79
Jun 22 2018 18:46
I'm using mysqli btw (yes Markus, your beloved PHP :P)
Markus Kiili
@Masd925
Jun 22 2018 18:46
:imp:
Jason Luboff
@JLuboff
Jun 22 2018 18:59
@Chrono79 Something like this would work in MS SQL
Set XACT_Abort, Nocount on;
Begin Tran;
Begin Try
    Insert into TSQL2012.Stats.Scores(testid, studentid, score) Values ('Test ABC', 'Student Z', 23);
    Select * from TSQL2012.Stats.Scores Where studentid = 'Student Z';
    End try
Begin Catch
Print 'Failed, rollback first try: ' + ERROR_MESSAGE();
    rollback tran;
End Catch;
Begin Try 
    Insert into TSQLV4.Stats.Scores(testid, studentid, score) Values ('Test ABC', 'Student A', 23);
    Select * from TSQLV4.Stats.Scores Where studentid = 'Student Z';
    End try
    Begin catch 
    Print 'Failed, roillback second try: ' + ERROR_MESSAGE();
        Rollback tran;
    End catch;
    Select * from TSQL2012.Stats.Scores Where studentid = 'Student Z'
    Union All
    Select * from TSQLV4.Stats.Scores Where studentid = 'Student Z';
Print 'Completed both. Rollback'
Rollback tran
So I get a PK violation in the second Try block, which in turns rolls back the entire transaction thus I get nothing in my bottom select statements
Actually, it didn't roll it back properly that Or I hadn't rolled back a prior one..lol
Ok ya, that works. Must not have rolled back a prior transaction
Diego Mayer
@Chrono79
Jun 22 2018 19:03
@JLuboff I'll take a look at that, and also I'm reading hte php docs to see if I can get something clear of this
Markus Kiili
@Masd925
Jun 22 2018 19:04
@Chrono79 hte -> hate
Diego Mayer
@Chrono79
Jun 22 2018 19:04
I can always hope for all going well, but it's better to prevent a partial insertion
Jason Luboff
@JLuboff
Jun 22 2018 19:06
@Chrono79 And actually... You only need the one try block. My solution only works if the second insert fails. If the first insert fails, it'll rollback the transaction but still go to the next try block I think.
@Chrono79 Here's a proper one I believe
Set XACT_Abort, Nocount on;
Begin Tran;
Begin Try
    Insert into TSQL2012.Stats.Scores(testid, studentid, score) Values ('Test ABC', 'Student Y', 23);
    Insert into TSQLV4.Stats.Scores(testid, studentid, score) Values ('Test ABC', 'Student Y', 23);
    End try
    Begin catch 
    Print 'Failed, roillback second try: ' + ERROR_MESSAGE();
        Rollback tran;
    End catch;
Commit Tran;
If either insert fails, it'll be rolled back
Markus Kiili
@Masd925
Jun 22 2018 19:17
@JLuboff How does that differ from just having the two inserts between START TRANSACTION and COMMIT?
Jason Luboff
@JLuboff
Jun 22 2018 19:18
@Masd925 Without the try-catch, if one insert completes but the next fails, the first one will still be commited. The try-catch prevents that
Markus Kiili
@Masd925
Jun 22 2018 19:20
@JLuboff Isn't the basic idea of a SQL transaction that if any of the tasks inside fail the whole transaction fails and is rolled back?
I'm just asking. I didn't even know that there is try/catch in SQL.
Jason Luboff
@JLuboff
Jun 22 2018 19:24
Mmm...I'm going to have to double check on that. The book I'm studying teaches using try-catch with transactions so maybe thats just ingrained in me lol
Norvin Burrus
@ndburrus
Jun 22 2018 22:01
@AnabelSalomone this may be helpful :sparkles:
koder3
@koder3
Jun 22 2018 22:09
image.png
isnt the array variable global to the secondFunc function?
why do i get undefined?
Brad
@bradtaniguchi
Jun 22 2018 22:14
@koder3 I suggest indenting your code for readability.
koder3
@koder3
Jun 22 2018 22:15
yeah i usually use the auto-format
is that fine
Brad
@bradtaniguchi
Jun 22 2018 22:15
and your code is working as expected, you see no console.logs() because its after the return of the inner function.
and the outer function returns nothing, which is why you see undefined
koder3
@koder3
Jun 22 2018 22:19
Oh alright
Thanks
Brad
@bradtaniguchi
Jun 22 2018 22:26
np :D