These are chat archives for FreeCodeCamp/HelpJavaScript

18th
Jan 2019
Chinmay Joshi
@dienigma
Jan 18 01:14 UTC
Hey Guys
Stuck here.
Use destructuring assignment to swap the values of a and b so that a receives the value stored in b, and b receives the value stored in a.
My Answer -
` let a = 8, b = 6; (() => { "use strict"; // change code below this line const [b,a] = [a,b]; // change code above this line })(); console.log(a); // should be 6 console.log(b); // should be 8
let a = 8, b = 6;
(() => {
  "use strict";
  // change code below this line
  const [b,a] = [a,b];  
  // change code above this line
})();
console.log(a); // should be 6
console.log(b); // should be 8
So yeah it aint working.
It should work according to this.
Christopher McCormack
@cmccormack
Jan 18 01:26 UTC
@dienigma you probably don't want to redeclare a and b, try removing const
Chinmay Joshi
@dienigma
Jan 18 01:26 UTC
Okay.
..
That worked
Christopher McCormack
@cmccormack
Jan 18 01:26 UTC
:thumbsup:
you already declared it at the top, and because you used let you can change the values. Without a return or even calling your function (it's an IIFE) you would need the swapped values stored outside the function
Chinmay Joshi
@dienigma
Jan 18 01:27 UTC
ah okay.
Any good resources for understanding let var and const differences?
@cmccormack ah, Understood.
Christopher McCormack
@cmccormack
Jan 18 01:29 UTC
@dienigma could try https://wesbos.com/let-vs-const/ but there are tons of short articles about it on Medium and other sites, I would recommend just doing a google search and reading through a few
Chinmay Joshi
@dienigma
Jan 18 01:30 UTC
@cmccormack Okay.
Thanks.
Christopher McCormack
@cmccormack
Jan 18 01:32 UTC
np
Karma Drukpa
@coderkarma
Jan 18 02:24 UTC
:wave:
Hey guys i need help on this.
let images = document.querySelectorAll('img');
let resetButton = document.querySelector('button');

resetButton.addEventListener('click', (e) => {
    let newImage = []
    return newImage.push(images)

    }
);


for (let i = 0; i < images.length; i++) {
    let image = images[i];
    image.addEventListener('click', (e) => {
        image.remove()
    })
}
ignore resutButton. That's where i need help
when user clicks the reset button it should restore all the images back to html .
abraham anak agung
@padunk
Jan 18 02:33 UTC
@coderkarma i never use remove() before, why don't hide it? you can use add() to add images back, but i think you need to create those elements before adding it
Karma Drukpa
@coderkarma
Jan 18 02:37 UTC
@padunk you think i should create element ? let me try.
abraham anak agung
@padunk
Jan 18 02:37 UTC
@coderkarma i think so, cause remove() will remove your element from the DOM tree.
Karma Drukpa
@coderkarma
Jan 18 02:39 UTC
yes, i think i should just hide the image when user clicks .
abraham anak agung
@padunk
Jan 18 02:41 UTC
yup, easier if you want to show them back again.
Karma Drukpa
@coderkarma
Jan 18 02:42 UTC
e.style.display = 'none'
e.style.display = images;
abraham anak agung
@padunk
Jan 18 02:44 UTC
@coderkarma JS have hide() and show() too.
but you can use CSS to show and hide also.
Karma Drukpa
@coderkarma
Jan 18 02:47 UTC
let images = document.getElementsByTagName('img');
let resetButton = document.querySelector('button');

resetButton.addEventListener('click', (e) => {
        images.style.visiblity = 'visible';
    }
);


for (let i = 0; i < images.length; i++) {
    let image = images[i];
    image.addEventListener('click', (e) => {
        image.style.visibility = "hidden";
    })
}
images are not showing back
abraham anak agung
@padunk
Jan 18 02:48 UTC
visibility you have a typo in resetButton.
be aware there is a different between visibility and display: none
Karma Drukpa
@coderkarma
Jan 18 02:51 UTC
okay
@padunk wait show and hide are jquery stuff.
I am just using vanilla js
Pagnito
@Pagnito
Jan 18 02:54 UTC
hey whats the maximum amount of traffic can i have on a laptop if i use it as server to host a website
abraham anak agung
@padunk
Jan 18 02:58 UTC
@coderkarma ah yes, sorry. it is jQuery.
i always mixed those up :smile:
Riadh
@KWFE
Jan 18 03:45 UTC
hi who still up
Spyrantis Theodoros
@thodorisanta
Jan 18 10:03 UTC
Quick question. What value will the input will get in here and why?
script>
function makeConverterFunction(multiplier, term) {
    return function(input) {           // <<<<<---- INPUT
        var convertedValue = input * multiplier;
        convertedValue = convertedValue.toFixed(2);
        return convertedValue + " " + term;
    };
}

var kilometersToMiles = makeConverterFunction(0.6214, "miles");
console.log("10 km is " + kilometersToMiles(10));
var milesToKilometers = makeConverterFunction(1.62, "km");
console.log("10 miles is " + milesToKilometers(10));
abraham anak agung
@padunk
Jan 18 10:07 UTC
@thodorisanta you give value of 10 to input like makeConverterFunction(0.6214, "miles")(//input values)
revised it, i didn't see it in your console.log
Spyrantis Theodoros
@thodorisanta
Jan 18 10:12 UTC
@padunk yeah but somehow the function remembers the first parameters i send to it. Thats what got me confused
abraham anak agung
@padunk
Jan 18 10:14 UTC
@thodorisanta that's one of JS feature closure
Spyrantis Theodoros
@thodorisanta
Jan 18 10:14 UTC
@padunk I'll check it out. thanks!
sounds cool xD
abraham anak agung
@padunk
Jan 18 10:15 UTC
@thodorisanta ok. my hands is busy right now, cant explain it much to you. just google closure javascript
Blauelf
@Blauelf
Jan 18 10:17 UTC
@Pagnito Totally depends on device, connection, type of application. Also depends on how you define "traffic", as megabits per second might mean anything, from pushing out large static content from cache (with enough RAM and connection speed you're probably fine) to doing heavy computation or database requests for a small response (might be limited by any factor depending on application). So while a raspberry pi might work for some applications, you might want at least a shared host with a 100Mbit/s connection for others. Also depends on how much response time you want to accept. Laptop is probably not great if you want high reliability, some raspi or rented standard server is easier to replace on hardware failure. If it's just for your own purpose (e.g. a private file server serving from USB hard disks), and you are ok with having a less reliable solution...
Keshav Malani
@credizian
Jan 18 13:00 UTC
Does anyone have working code to detect browser type? (Chrome, firefox, etc.) I've searched online but keep finding ones that are not working on latest version of Chrome and/or Firefox
Kaz Baig
@kbaig
Jan 18 14:08 UTC
:wave: morning
@credizian You should read the browser detection docs if you haven't already
Tiago Correia
@tiagocorreiaalmeida
Jan 18 14:56 UTC
Hey, anyone that uses digital ocean around?
Nate Mallison
@NJM8
Jan 18 15:19 UTC
@alpox Do you have a two finger swipe horizontal that will change your workspaces? I'm trying to figure out where that gesture comes from as it drives me nuts, super sensitive an triggers when I'm scrolling normally.
The system76 devs think it comes from gnome
enestatli
@enestatli
Jan 18 15:57 UTC

hello quick question, how can I put - into the blank of each elements of the lst array

lst = ["3 series", "4 series"]

output should be lst = ["3-series", "4-series"]
Aditya
@ezioda004
Jan 18 15:58 UTC
@enestatli
lst.map(str => str.split(" ").join("-"))
enestatli
@enestatli
Jan 18 16:00 UTC
thank you! @ezioda004
Blauelf
@Blauelf
Jan 18 16:00 UTC
I thought of str.replace(/ /g, "-") (replace requires regex if you want it to replace all occurrences)
enestatli
@enestatli
Jan 18 16:03 UTC
@Blauelf I am gonna try, thank you!
Jason Luboff
@JLuboff
Jan 18 16:03 UTC
Morning :wave:
Blauelf
@Blauelf
Jan 18 16:04 UTC
Afternoon :P
Jason Luboff
@JLuboff
Jan 18 16:04 UTC
That too!
@tiagocorreiaalmeida Pretty sure @cmccormack uses digital ocean...but..I also realize you may not be around and he may not be either lol
Blauelf
@Blauelf
Jan 18 16:05 UTC
I recently had a chat with some CS50x online community manager who is in New Zealand. That's about as far as it can get :D
Jason Luboff
@JLuboff
Jan 18 16:06 UTC
New Zealand eh?
Christopher McCormack
@cmccormack
Jan 18 16:07 UTC
:wave: morning
Markus Kiili
@Masd925
Jan 18 16:08 UTC
Evening.
Jason Luboff
@JLuboff
Jan 18 16:10 UTC
Yo
How is everyone?\
Christopher McCormack
@cmccormack
Jan 18 16:16 UTC
meh. Was up until 02:00 this morning trying to get a partner moved to my new ivpn environment
you?
enestatli
@enestatli
Jan 18 16:17 UTC
I just feel so depressed recently, I think I should have a break
Jason Luboff
@JLuboff
Jan 18 16:17 UTC
@cmccormack Up until 2? Jeez...was it scheduled?
Christopher McCormack
@cmccormack
Jan 18 16:18 UTC
@JLuboff yeah. our maintenance window is 20:00-03:00. Part of the job to have to occasionally be up all night for something, unfortunately
@enestatli depressed about what?
Jason Luboff
@JLuboff
Jan 18 16:19 UTC
Ah.. so atleast it wasn't an unexpected thing
enestatli
@enestatli
Jan 18 16:19 UTC
@cmccormack learning programming things :(
Christopher McCormack
@cmccormack
Jan 18 16:19 UTC
@enestatli what's the issue?
enestatli
@enestatli
Jan 18 16:22 UTC
I got stuck a lot, I shouldn't have learn R or any data analysis thing
Jason Luboff
@JLuboff
Jan 18 16:23 UTC
Thats the learning process....getting stuck a lot
You don't think we get stuck at all?
Riadh
@KWFE
Jan 18 16:23 UTC
hi, how are you today?
enestatli
@enestatli
Jan 18 16:25 UTC
@JLuboff I think you 'barely' get stuck :)
Christopher McCormack
@cmccormack
Jan 18 16:25 UTC
That's actually what experience gives you, a shorter path out of getting stuck
enestatli
@enestatli
Jan 18 16:32 UTC
@cmccormack you are right, like 2 months ago I had no clue what the heck nested loops but now I could play like toys
but there are so many things!
Christopher McCormack
@cmccormack
Jan 18 16:34 UTC
@enestatli yeah once you get past the thrill of figuring out the initial stuff it can be a dark slog through some of the more nuanced stuff, that's for sure. But you're building a foundation, the stronger it is the easier everything else will be
Jason Luboff
@JLuboff
Jan 18 16:36 UTC

@enestatli I'm going to quote myself from yesterday

I used to be like you. I thought programming wasn't for me. I couldn't properly conceptualize algorithms or code flow. So, I didn't touch it for years. Then.. i found FCC. And started working on it.. probably a couple hours a day. Now, I'm Systems Developer for my company in charge of building new applications and administrating the database. I've worked my ass off to get where I am currently, but even so, I still know very little. I still have to ask questions frequently. BUT I made it. And you can too. Its just a matter of sticking to it, being consistent and not putting yourself down.

I started FCC in May 2016. I started studying SQL 2017. I put my first real app into production in August 2018. It took me time. But now I'm working actively on multiple apps. And I have my Microsoft certification for SQL server.
The SQL stuff doesn't matter as much here but you can get the point here
Kelechi Chinaka
@ke1echi
Jan 18 16:40 UTC
nice :thumbsup: @JLuboff
Jason Luboff
@JLuboff
Jan 18 16:44 UTC
:smile:
Christopher McCormack
@cmccormack
Jan 18 16:51 UTC
@JLuboff climbed that mountain and now has a great view of the land below
that's really him I swear!
image.png
alpox
@alpox
Jan 18 16:52 UTC
@NJM8 i believe too that it comes from gnome. I dont have it but I use a special setup - Arch with i3wm and some KDE applications
Jason Luboff
@JLuboff
Jan 18 16:53 UTC
@cmccormack I make a good green screen model!
Christopher McCormack
@cmccormack
Jan 18 16:56 UTC
stop slouching your shoulders! but otherwise yeah man maybe switch careers
is green screen model a career?
Jason Luboff
@JLuboff
Jan 18 16:56 UTC
I guess I'll find out!
enestatli
@enestatli
Jan 18 17:17 UTC
@cmccormack @JLuboff thanks a lot both of you. You always giving promising advice/speech to new learners :)
@JLuboff I will do the same thing next week, just gonna finis FCC challenges for this time
Jason Luboff
@JLuboff
Jan 18 17:19 UTC
I'm only continuing what others have done for me :)
Christopher McCormack
@cmccormack
Jan 18 17:20 UTC
@JLuboff you can do it!
Next goal - Sr. developer at Netflix
those guys make like 300 grand
Jason Luboff
@JLuboff
Jan 18 17:21 UTC
That'd be dope. But.... I'm not that good...yet!
Christopher McCormack
@cmccormack
Jan 18 17:21 UTC
Use my patented 50% rule - if you can meet or exceed 50% of the requirements on a job posting, go for it!
enestatli
@enestatli
Jan 18 17:21 UTC
@JLuboff @cmccormack have you ever worked remotely?
Jason Luboff
@JLuboff
Jan 18 17:22 UTC
@cmccormack Not a bad rule heh
@enestatli I have not
Christopher McCormack
@cmccormack
Jan 18 17:22 UTC
@enestatli I mostly work remotely
Jason Luboff
@JLuboff
Jan 18 17:22 UTC
I did just finish my e2e tests for my project though, so thats cool!
enestatli
@enestatli
Jan 18 17:22 UTC
@cmccormack what are the pros and cons you think?
Christopher McCormack
@cmccormack
Jan 18 17:23 UTC
@JLuboff it's actually been shown men already do this for the most part, but women have a hard time doing it as they feel they need to be more qualified even if it doesn't provide any benefits vs their male counterparts
Jason Luboff
@JLuboff
Jan 18 17:23 UTC
If I could work remote I would. Would probably move too.
Christopher McCormack
@cmccormack
Jan 18 17:23 UTC
@enestatli I'd say the pros would be having my workspace at my house where I control what I get to do throughout the day. Nobody will judge me if I decide to play my switch during a meeting or whatever :)
cons are social - you really benefit from actually being around your colleagues and leaders more than you know. That definitely has diminishing returns, though. Being around them a few days a week is probably better than 5 days a week, for example. There's a LOT of wasted time when people gather in person
another con that can also be a pro depending on how you look at it - you can make your hours. You don't have to worry about a commute, so you can work earlier and work longer if you want
@JLuboff trying to get the wife to get a remote job so we can both move somewhere with a vastly lower cost of living
Jason Luboff
@JLuboff
Jan 18 17:27 UTC
I think we'd move to Hawaii...at least for a few years. I'd have to probably wake up early...but I would not care one bit lol
Christopher McCormack
@cmccormack
Jan 18 17:27 UTC
I work at home and still get up at 05:30 every other day to hit the gym and stuff, it's not bad at all
enestatli
@enestatli
Jan 18 17:27 UTC
@cmccormack well it seems, remote work look promising for myself :D
get up at 5:30?
Christopher McCormack
@cmccormack
Jan 18 17:28 UTC
you don't have to squeeze all that prep and commute time in
enestatli
@enestatli
Jan 18 17:28 UTC
damn...
Jason Luboff
@JLuboff
Jan 18 17:28 UTC
I go to the gym during lunch
Christopher McCormack
@cmccormack
Jan 18 17:28 UTC
@enestatli it can be, also depends on how well you work alone and how driven you are. I've been doing my job for a long time now and it wasn't always remote, so I was able to adapt fairly quickly as my work didn't change just my environment
@JLuboff I used to but then kept getting meetings during lunch :/
enestatli
@enestatli
Jan 18 17:29 UTC
I go to the gym during lunch :D
Jason Luboff
@JLuboff
Jan 18 17:29 UTC
I'm hourly so I have to take a lunch
Christopher McCormack
@cmccormack
Jan 18 17:30 UTC
I'm salary so my lunch is grab what you can before someone else pings you lol
Jason Luboff
@JLuboff
Jan 18 17:31 UTC
You gotta tell them your lunch is sacred!
Christopher McCormack
@cmccormack
Jan 18 17:31 UTC
we all know, nobody cares
too many different timezones
In the office I can just walk out for lunch, but at home everyone expects me to be around, so that's another con I guess
Jason Luboff
@JLuboff
Jan 18 17:33 UTC
Thats why you just don't answer your phone
enestatli
@enestatli
Jan 18 17:33 UTC
but you can bring your laptop to lunch?
Christopher McCormack
@cmccormack
Jan 18 17:34 UTC
@JLuboff phone? nobody uses the phone lol
Jason Luboff
@JLuboff
Jan 18 17:34 UTC
Ok..thats why you just don't look at your email
Christopher McCormack
@cmccormack
Jan 18 17:34 UTC
Slack/Skype normally
oh yeah and email
Jason Luboff
@JLuboff
Jan 18 17:34 UTC
Ok...thats why you just don't look at Slack.Skype
Christopher McCormack
@cmccormack
Jan 18 17:34 UTC
but email I don't respond to quickly
if only it were that easy most times
enestatli
@enestatli
Jan 18 17:35 UTC
how long have you been in 'work' field?
Jason Luboff
@JLuboff
Jan 18 17:38 UTC
I've been in IT for 8.5 years... programming/db...well you saw my earlier post
Christopher McCormack
@cmccormack
Jan 18 17:38 UTC
like work work?
any work?
damn, like 22 years if you include teenager jobs
enestatli
@enestatli
Jan 18 17:39 UTC
yes any work
damn 22 years :D
Jason Luboff
@JLuboff
Jan 18 17:40 UTC
Ya... working in general... 13 years... if you count working with my grandpa.. 17 years
enestatli
@enestatli
Jan 18 17:40 UTC
what kind of work with your grandpa?
boutique?
Jason Luboff
@JLuboff
Jan 18 17:40 UTC
Used to sell self-defense items (stun guns/pepper spray) and binoculars/scopes at gun shows
enestatli
@enestatli
Jan 18 17:41 UTC
Wow, thats really cool
was it boring?
Jason Luboff
@JLuboff
Jan 18 17:42 UTC
Sometimes when it was slow. I would just read during that time. It would only be 2-3 weekends a month
Christopher McCormack
@cmccormack
Jan 18 17:46 UTC
I used to install tile with my uncle, in Phoenix... That was some backbreaking work, probably why I got into IT instead lol
Jason Luboff
@JLuboff
Jan 18 17:49 UTC
I use to work at Macys. That was...easy work but lame lol
Christopher McCormack
@cmccormack
Jan 18 17:50 UTC
were you one of those people that spritzed people walking by?
Jason Luboff
@JLuboff
Jan 18 17:51 UTC
Lol no
I worked in the Home department
I was a master at folding towels
Christopher McCormack
@cmccormack
Jan 18 17:52 UTC
lol
Jason Luboff
@JLuboff
Jan 18 17:54 UTC
That was like 75% of what I did. It was busy work that kept me entertained lol
Christopher McCormack
@cmccormack
Jan 18 17:55 UTC
man that's why we need something like google glass but good, you could have been learning too while you folded towels!
Jason Luboff
@JLuboff
Jan 18 18:01 UTC
That would have been cool
enestatli
@enestatli
Jan 18 18:06 UTC
I was a master at folding towels
:D
Christopher McCormack
@cmccormack
Jan 18 18:15 UTC
@JLuboff could make any towel fold just by looking at it. He had the static electricity power of a thousand dryer sheets!
Jason Luboff
@JLuboff
Jan 18 18:15 UTC
Man, you don't even know!
Christopher McCormack
@cmccormack
Jan 18 18:15 UTC
Is there a "right" way? The wife and I tend to disagree
Jason Luboff
@JLuboff
Jan 18 18:16 UTC
There...yes. At home? Nah.. just whatever works for you. Problem with towels at home is they usually get warped so harder to get a clean fold
Christopher McCormack
@cmccormack
Jan 18 18:20 UTC
I'll just throw them out each time I use one and have Amazon ship me new ones daily
Jason Luboff
@JLuboff
Jan 18 18:20 UTC
Works for me!
enestatli
@enestatli
Jan 18 18:21 UTC
@JLuboff could make any towel fold just by looking at it. He had the static electricity power of a thousand dryer sheets!
lol you remind me of when I was a little boy some people bending spoons just by looking :D
Jason Luboff
@JLuboff
Jan 18 18:21 UTC
Also...remember to never use laundry softner on towels!
Christopher McCormack
@cmccormack
Jan 18 18:22 UTC
that much I DO know
and I tell people pretty often, because I'm kind of an a-hole
Jason Luboff
@JLuboff
Jan 18 18:22 UTC
Lol do you really?
Christopher McCormack
@cmccormack
Jan 18 18:22 UTC
yeah man
who wants barely functioning towels?
Jason Luboff
@JLuboff
Jan 18 18:23 UTC
lol
I sure dont
Or destroying your expensive towels
Christopher McCormack
@cmccormack
Jan 18 18:23 UTC
Hotels sure know what they're doing, those towels could soak up a pond
Jason Luboff
@JLuboff
Jan 18 18:24 UTC
:joy:
Nate Mallison
@NJM8
Jan 18 18:24 UTC
My gym towel I've had since I was 12. It doesn't soak up a thing haha
$2500 laptop? check. $12 towel? No thanks too much. Lol
What is everyone working on today.
Jason Luboff
@JLuboff
Jan 18 18:25 UTC
Finishing up my e2e tests... then...perhaps get back to my React app..
enestatli
@enestatli
Jan 18 18:26 UTC
can I see your React app?
Nate Mallison
@NJM8
Jan 18 18:27 UTC
I'm going to need some motivation to do all my testing. We pushed to deliver first beta and then testing came up and I was like hmmmm. Nope haha
Jason Luboff
@JLuboff
Jan 18 18:27 UTC
Its for work..so can't, sorry. But @cmccormack has much nicer React apps then wht I'm building lol
Nate Mallison
@NJM8
Jan 18 18:27 UTC
Going back and setting up all the unit and the building e2e testing is going to suck
What are you using for a test runner?
enestatli
@enestatli
Jan 18 18:27 UTC
@cmccormack may I see?
Jason Luboff
@JLuboff
Jan 18 18:28 UTC
@NJM8 Dude... @alpox introduced me to testcafe...and.. its fucking awesome. Ya... its taken some work to get all the tests I want but it'll keep me from not noticing mistakes that end up in production
Christopher McCormack
@cmccormack
Jan 18 18:28 UTC
@NJM8 that is life in a nutshell. As I get older, though, I am trying to replace everything I keep around with better versions, and tossing everything I no longer use, KonMari style
Nate Mallison
@NJM8
Jan 18 18:28 UTC
testcafe?
Christopher McCormack
@cmccormack
Jan 18 18:28 UTC
Saves money long term
Nate Mallison
@NJM8
Jan 18 18:28 UTC
Thanks!
Christopher McCormack
@cmccormack
Jan 18 18:29 UTC
@enestatli repos my biggest to date are the Voting App and Nightlife App
Nate Mallison
@NJM8
Jan 18 18:30 UTC
@cmccormack You still go into the office sometimes or full remote?
Christopher McCormack
@cmccormack
Jan 18 18:30 UTC
@NJM8 sometimes
if I'm in town I'll go, or if we have a big onsite meeting
I'm about an hour and a half from the office
Pagnito
@Pagnito
Jan 18 19:12 UTC
just noticed vs code seems to set different tab sizes randomly for different files
anyone know why it does that? and how i can make it fixed?
Brad
@bradtaniguchi
Jan 18 19:15 UTC
@Pagnito file name?
Pagnito
@Pagnito
Jan 18 19:16 UTC
@bradtaniguchi nah, like some js files will have 5 tab spaces, other js files will have 4 or 3
or 2
Brad
@bradtaniguchi
Jan 18 19:16 UTC
wait we talking about the format inside of the file or vscode's tabs?
Pagnito
@Pagnito
Jan 18 19:17 UTC
format inside the file
Christopher McCormack
@cmccormack
Jan 18 19:22 UTC
@Pagnito ah you mean the actual number of spaces a tab takes up - bottom right in the status bar should show the spaces
and you can adjust them by clicking it
Pagnito
@Pagnito
Jan 18 19:23 UTC
yea i do, but i dont understand why the default isnt the same for every js page
Christopher McCormack
@cmccormack
Jan 18 19:23 UTC
There is a detect indentation option as well
Pagnito
@Pagnito
Jan 18 19:23 UTC
what does that do
Christopher McCormack
@cmccormack
Jan 18 19:23 UTC
probably detects indentation
:)
so if it were 5 spaces maybe sets it to 5
Editor: Tab Size
The number of spaces a tab is equal to. This setting is overridden based on the file contents when Editor: Detect Indentation is on.
Pagnito
@Pagnito
Jan 18 19:24 UTC
hmm, ima try something to see if i undestand it right
Brad
@bradtaniguchi
Jan 18 19:25 UTC
@Pagnito Sounds like someone should look into formatting all the JS files in the project the same. (if you can)
Confusing indentation is like a caveman problem, we have technology
Pagnito
@Pagnito
Jan 18 19:26 UTC
@bradtaniguchi not sure what u mean
Brad
@bradtaniguchi
Jan 18 19:27 UTC
@Pagnito If you can, auto-format the entire project so the indentation (and other things) are exactly the same accross the entire project.
Pagnito
@Pagnito
Jan 18 19:27 UTC
ah, yea i def wanna do that
Christopher McCormack
@cmccormack
Jan 18 19:27 UTC
@Pagnito if you want to do it manually by file type you can add something like this in your setting:
{
    "[sass]": {
        "editor.tabSize": 2
    },
    "[html]": {
        "editor.tabSize": 4
    },
    "[javascript]": {
        "editor.tabSize": 2
    }
}
I would probably do this to use 2 for JS and 4 for Python, for example
Pagnito
@Pagnito
Jan 18 19:28 UTC
yea sounds good to me
where in the settings do i add it
oh i found it
Pagnito
@Pagnito
Jan 18 19:34 UTC
do i put it into workspace settings?
Christopher McCormack
@cmccormack
Jan 18 19:35 UTC
only if you want it just for that workspace
I don't usually use workspace settings if that helps you
Pagnito
@Pagnito
Jan 18 19:36 UTC
ah
ok
Nate Mallison
@NJM8
Jan 18 19:38 UTC
"editor.tabSize": 2, 10% raise right there
Jason Luboff
@JLuboff
Jan 18 19:43 UTC
Phew...another bug caught by e2e before causing an issue in production
@JLuboff What kind of bug
Jason Luboff
@JLuboff
Jan 18 19:46 UTC
@NJM8 Had added a case statement to an DB insert query...but forgot to add the additional parameter that does the check to the query input and function lol
Nate Mallison
@NJM8
Jan 18 19:47 UTC
you know what really drove home that TDD is great? I messed up one of my components because I refactored it to work a certain way and had forgotten why it did XYZ, so broke the original functionality. And that made it into production as I wasn't even thinking about it.
Oops
Jason Luboff
@JLuboff
Jan 18 19:47 UTC
Ya...I'm trying to get better about that sort of thing hah
Brad
@bradtaniguchi
Jan 18 19:48 UTC
I love being able to refactor stuff and have no fear of things breaking. Helps with making code clean too :D
Jason Luboff
@JLuboff
Jan 18 19:50 UTC
My entire e2e tests take just shy of 4 minutes to complete.. runs through the guantlet twice though ( two different scenarios)
Brad
@bradtaniguchi
Jan 18 19:53 UTC
@JLuboff Doesn't sound very scalable to me..... time for unit-tests >:D
and throw in some CI sever to do the work for ya
Jason Luboff
@JLuboff
Jan 18 19:54 UTC
Whats CI?
Brad
@bradtaniguchi
Jan 18 19:54 UTC
:o
Jason Luboff
@JLuboff
Jan 18 19:54 UTC
And its performing almost every scenario I can think of that would be performed
Brad
@bradtaniguchi
Jan 18 19:54 UTC
continuous integration
Jason Luboff
@JLuboff
Jan 18 19:54 UTC
Ooooh
Brad
@bradtaniguchi
Jan 18 19:54 UTC
Yes, but it's slow
Jason Luboff
@JLuboff
Jan 18 19:55 UTC
Ya I haven't looked into that yet
Riadh
@KWFE
Jan 18 19:55 UTC
               hi                                                                                                                                                                  
Jason Luboff
@JLuboff
Jan 18 19:55 UTC
Perhaps its slow...but it's faster than me doing it myself :)
Brad
@bradtaniguchi
Jan 18 19:55 UTC
Main thing is it can run the tests for you, all the time. So you aren't sitting around waiting, and it will double check for you (heck it can even deploy to the live server if you set it up right
Very true :), Were nearing 1k unit-tests and it runs under 10 seconds (most of it is typescript compiling), actual "tests" take 2 seconds :D
Jason Luboff
@JLuboff
Jan 18 19:56 UTC
But thats not e2e automated testing, right?
Brad
@bradtaniguchi
Jan 18 19:57 UTC
We only have unit-tests currently (a crap ton) to test business logic
Jason Luboff
@JLuboff
Jan 18 19:57 UTC
I'll still have to learn how to properly perform unit tests :)
Brad
@bradtaniguchi
Jan 18 19:59 UTC
They are easy IMO, jest should have all that handled for ya haha. Main thing is what to test, and writing testable code
Jason Luboff
@JLuboff
Jan 18 20:00 UTC
Does route testing count as unit-tests?
Brad
@bradtaniguchi
Jan 18 20:03 UTC
I don't think so, Id say testing a single react-component's behavior would be a good place to have unit-tests.
Or key business logic, like validators, security checks, etc
Riadh
@KWFE
Jan 18 20:04 UTC
guys who has a french keyboard?
Jason Luboff
@JLuboff
Jan 18 20:06 UTC
@bradtaniguchi Ah..ya I'll be creating those tests for my React app (jest has a REact plugin)
Brad
@bradtaniguchi
Jan 18 20:07 UTC
You can check your server-side too, same idea applies. But yea the main concern id have is if your current code is testable. it's totally possible you will have a nightmare time testing just single parts of the app if they aren't designed well, forcing you to refactor it. But you got E2E tests to make sure you don't totally break stuff haha
Jason Luboff
@JLuboff
Jan 18 20:08 UTC
I mean..it probably isn't designed well... this is me we're talking about
Nate Mallison
@NJM8
Jan 18 20:17 UTC
Ohhh stop, I'm sure it's fine.
Jason Luboff
@JLuboff
Jan 18 20:18 UTC
It works so ya, guess its fine :)
Brad
@bradtaniguchi
Jan 18 20:18 UTC
that's what really matters in the end
Kaz Baig
@kbaig
Jan 18 20:21 UTC
@JLuboff asking for a friend - any good free tutorials to brush up on sql?
Jason Luboff
@JLuboff
Jan 18 20:22 UTC
@kbaig Mmm..there's always Microsoft VirtualAcademy
Kaz Baig
@kbaig
Jan 18 20:22 UTC
this is for an interview and the person last touched sql when they were learning it in class 2-3 years ago
@JLuboff thanks dude
Brad
@bradtaniguchi
Jan 18 20:37 UTC
hehe sounds like me :P
Jason Luboff
@JLuboff
Jan 18 20:42 UTC
What kind of job? Heavy SQL usage?
Kaz Baig
@kbaig
Jan 18 20:51 UTC
No clue. All I know is it's for instacart
I just offered to help her prep for the interview
It would almost definitely be a business side role though
enestatli
@enestatli
Jan 18 20:52 UTC
break syntax doesn't stop my for loops :(
Brad
@bradtaniguchi
Jan 18 20:55 UTC
@enestatli POST DAH CODE (depends on what type of loop)
enestatli
@enestatli
Jan 18 21:01 UTC
@bradtaniguchi its Python
even so can I post?
Lia-Sue-Kim
@Lia-Sue-Kim
Jan 18 21:01 UTC
Anybody learning math on khan academy?
enestatli
@enestatli
Jan 18 21:02 UTC
@Lia-Sue-Kim just specific topic of some integral calculations
Lia-Sue-Kim
@Lia-Sue-Kim
Jan 18 21:02 UTC
I don't know which one to choose by grade or topic?
@enestatli Why reading books about math is harder to understand than on khan academy
enestatli
@enestatli
Jan 18 21:07 UTC
@Lia-Sue-Kim reading books generally enough, but sometimes you need more examples
Riadh
@KWFE
Jan 18 21:16 UTC
// Example
var sum = 0;
function addThree() {
  sum = sum + 3;
}

// Only change code below this line                                                                                         
function AddFive() {
  sum = sum + 5 ;
}

// Only change code above this line
var returnedValue = addFive();
Brad
@bradtaniguchi
Jan 18 21:18 UTC
@enestatli I mean there is a python room for this sorta stuff
enestatli
@enestatli
Jan 18 21:19 UTC
@bradtaniguchi they barely answer :(
Brad
@bradtaniguchi
Jan 18 21:20 UTC
@enestatli I don't see your question asked there, and idk who here knows python
enestatli
@enestatli
Jan 18 21:21 UTC
okay then I will ask there :)
Brad
@bradtaniguchi
Jan 18 21:21 UTC
@KWFE I assume your having issues
Riadh
@KWFE
Jan 18 21:21 UTC
no no
i think i missed AddFive which must be addFive
@bradtaniguchi thanks
Brad
@bradtaniguchi
Jan 18 21:22 UTC
don't name functions with UpperCase names, they are almost always named camelCase
good convention to remember :)
Christopher McCormack
@cmccormack
Jan 18 21:23 UTC
@enestatli I think the reason many don't respond in the Python room is because the questions are harder than most can answer. The easy questions just aren't asked as often
Jeff
@jargonfilter
Jan 18 21:25 UTC
hey everyone. I'm kind of stuck with one of the intermediate algo exercises.
one of the things i find kind of confusing is how to iterate through an array of objects in clean way.
function whatIsInAName(collection, source) {
  // What's in a name?
  let arr = [];
  // Only change code below this line
  for (let i = 0; i < collection.length; i++) {
      for (let key in collection[i]) {
        if (collection[i][key] = Object.keys(source)) {
          arr.push(collection[i]);
          console.log("yes " + JSON.stringify(collection[i]));
        }
      }
  }
  // Only change code above this line
  return arr;
}
i've tried something with filter but didnt get far, tried something with forEach but also didnt seem to have it right. so this is where i'm at right now. problem is its obviously incorrect lol

when i log collection[i] just to see what its pushing to arr, it gives me things like:

yes {"apple":["apple","bat"],"bat":2}

Brad
@bradtaniguchi
Jan 18 21:29 UTC
@jargonfilter I forgot about this challenge, it wants you to return the objects that "match" with the second arg right?
Jeff
@jargonfilter
Jan 18 21:29 UTC
yes {"apple":["apple","bat"],"bat":2}
yes
so it should be returning things more like
Brad
@bradtaniguchi
Jan 18 21:29 UTC
Well I wouldn't worry too much about the "clean way to loop", if your current loop code isn't working
Aditya
@ezioda004
Jan 18 21:29 UTC
(collection[i][key] = Object.keys(source) you probably didnt mean to assign in an if statetment
Jeff
@jargonfilter
Jan 18 21:29 UTC
{"apple":1,"bat":2}
Brad
@bradtaniguchi
Jan 18 21:30 UTC
Also the collection[i][key] = Object.keys(source) isn't correct
or at least its not doing what you think
Jeff
@jargonfilter
Jan 18 21:30 UTC
yep.... missed that
ok, so i fixed that part. am i on the right track or am i totally off base?
Brad
@bradtaniguchi
Jan 18 21:32 UTC
Your idea is correct, but the execution isn't working. What did you change the line I pointed out too? (there's multiple bugs in this line)
Jeff
@jargonfilter
Jan 18 21:32 UTC
hmm
function whatIsInAName(collection, source) {
  // What's in a name?
  let arr = [];
  // Only change code below this line
  for (let i = 0; i < collection.length; i++) {
      for (let key in collection[i]) {
        if (collection[i][key] == Object.keys(source)) {
          arr.push(collection[i]);
          console.log("yes " + JSON.stringify(collection[i]));
        }
      }
  }
  // Only change code above this line
  return arr;
}
well i tried triple equals as well but i switched it to double just to see if anything changed heh
Brad
@bradtaniguchi
Jan 18 21:33 UTC
@jargonfilter In JS use === instead of just ==, basically == isn't as strict and creates more bugs. But even then this approach wont' work here
Jeff
@jargonfilter
Jan 18 21:33 UTC
ok
so where am i going wrong?
Brad
@bradtaniguchi
Jan 18 21:34 UTC
Because your essentially doing this:
if ('bat' === ['bat', 'apple'])
Jeff
@jargonfilter
Jan 18 21:34 UTC
hmmmm
ok so i guess i need to just grab the first key in source first, then grab the 2nd key if there is a second key
i guess i could accomplish this with another for loop.... seems really unruly
Brad
@bradtaniguchi
Jan 18 21:35 UTC
I would double check the requirements first, to make sure we understand the actual problem, before jumping into the code :D
My current understanding is
we want to return any item that has all the keys in the "source"
Jeff
@jargonfilter
Jan 18 21:36 UTC
well, the keys and the values right?
Brad
@bradtaniguchi
Jan 18 21:36 UTC
Yes yes
So your right in you need another "loop", to check all the values with the current element
Jeff
@jargonfilter
Jan 18 21:38 UTC
hmm
Jeff
@jargonfilter
Jan 18 21:40 UTC
so, for each key in collection, for each key in source, if the keys and values match, return collection[i]
Brad
@bradtaniguchi
Jan 18 21:41 UTC
whoa, I thought we were only thinking about comparing the elements at this point haha
Jeff
@jargonfilter
Jan 18 21:43 UTC
ok, so i should just check the keys, and then if those match, then check the values?
Brad
@bradtaniguchi
Jan 18 21:43 UTC
@jargonfilter You technically can check both at the same time right? like: el[key] === otherEl[key] as long as both el, and otherEl exists (they always due, FCC isn't passing undefined in the array or anything nasty) this would work :D
Jeff
@jargonfilter
Jan 18 21:45 UTC
oh so checking just the key also checks the value at the same time. i thought maybe it would check just the key name
Brad
@bradtaniguchi
Jan 18 21:46 UTC
not sure what you mean, I pointed out you can check the elements value at the given key, and the sources value at the given key. If they both match you "keep" that element to return. I checked the testcases, the values do matter so even if both element and the source have the same keys, they also need the same values for each key
Jeff
@jargonfilter
Jan 18 21:47 UTC
ok
i guess that makes sense for checking the key value pair
Brad
@bradtaniguchi
Jan 18 21:55 UTC
@jargonfilter I got my solution (a nice readable version, and a cutdown "less-optimal" fancy solution) if you want it for what I think is the "clean" way todo this. Obviously finish the challenge first tho hehe
Jeff
@jargonfilter
Jan 18 21:56 UTC
trying to finish it on my own first, but thank you!
i'll ask to see your solution if i can figure this out lol
Brad
@bradtaniguchi
Jan 18 21:58 UTC
@jargonfilter No worries haha, I wont spoil anything :P
Christopher McCormack
@cmccormack
Jan 18 22:12 UTC
I'm off for the evening take care people
Brad
@bradtaniguchi
Jan 18 22:13 UTC
@cmccormack C ya, have a good weekend
Jason Luboff
@JLuboff
Jan 18 22:13 UTC
@cmccormack Adios
@bradtaniguchi I'm trying to think...can that challenge be done with a single looping mechanism?
Brad
@bradtaniguchi
Jan 18 22:14 UTC
@JLuboff Depends what we count as a single looping mechanism
Jason Luboff
@JLuboff
Jan 18 22:14 UTC
map/filter/reduce/for loop
Brad
@bradtaniguchi
Jan 18 22:15 UTC
Yes, idk about the "checks" for each value+key pair tho
Jason Luboff
@JLuboff
Jan 18 22:16 UTC
Your answer makes it sound like no that you would need atleast two looping mechanisms
Brad
@bradtaniguchi
Jan 18 22:17 UTC
There might be some fancy way to do the value+key pair that doesn't use a loop (or at least id doesn't seem like it does haha
Jason Luboff
@JLuboff
Jan 18 22:17 UTC
Got it
Brad
@bradtaniguchi
Jan 18 22:21 UTC
Has anyone ever tired one of those challenges where you write JS code and can't do the following:
  1. Can't use if statements
  2. Can't use const/var/let
  3. 1 line solutions only
    It's driving me insane XD
Jason Luboff
@JLuboff
Jan 18 22:22 UTC
I think I've done some via codewars
Brad
@bradtaniguchi
Jan 18 22:38 UTC
I gotta try to solve more code this way. Feels like I'm trying todo clojure again :P
Jason Luboff
@JLuboff
Jan 18 22:40 UTC
Just made a change that should break part of e2e...lets see!
It did!
Brad
@bradtaniguchi
Jan 18 22:49 UTC
sanity check, of the sanity checks :P
Jason Luboff
@JLuboff
Jan 18 22:50 UTC
and after updating the test...it still fails! :joy:
Ah forgot to change something
I should probably turn the email feature off during Dev..