These are chat archives for FreeCodeCamp/HelpJavaScript

12th
Jan 2018
silver537
@silver537
Jan 12 2018 00:16
@Chrono79 the word you're looking for is apparent. The apparent temp, or the 'feels Like' temp, is 70. But it's actually 65.
tony kroos
@aceymomo
Jan 12 2018 00:49
Good morning,everyone!
Brad
@bradtaniguchi
Jan 12 2018 00:57
goodmorning, but for me its the afternoon haha
Jason Luboff
@JLuboff
Jan 12 2018 00:58
Yup..afternoon here..about to leave work for the day :P
yanglanxiang11
@yanglanxiang11
Jan 12 2018 01:47
更改myStr字符串的双引号为单引号,并移除转义符号
var myStr = "\'<a href=http://www.example.com target=_blank>Link</a>\'";
Henry
@GitHub-Henry
Jan 12 2018 04:26
Ken Haduch
@khaduch
Jan 12 2018 04:56
@yanglanxiang11 - not sure what your problem is, because I cannot read the Chinese part, but it looks like you might need to put some internal quotes around your value following href= and target=?
Brian
@BrianCodes33
Jan 12 2018 06:20
Test.assertEquals(accum("ZpglnRxqenU"), "Z-Pp-Ggg-Llll-Nnnnn-Rrrrrr-Xxxxxxx-Qqqqqqqq-Eeeeeeeee-Nnnnnnnnnn-Uuuuuuuuuuu”);

function accum(s) {
  const splitStr = s.split(" ");
  let accumStr = "";
  let count = 0;
  for (var i=0; i<splitStr.length; i++) {

  }
}
having trouble here
Fabien SHAN
@X140hu4
Jan 12 2018 06:23
Your for loop is empty
bilaal-s
@bilaal-s
Jan 12 2018 10:13
Hey guys
:wave:

Could someone explain the following for me?
Access Across Domains
For security reasons, modern browsers do not allow access across domains.
This means that both the web page and the XML file it tries to load, must be located on the same server.
The examples on W3Schools all open XML files located on the W3Schools domain.
If you want to use the example above on one of your own web pages, the XML files you load must be located on your own server.

this can be found at: https://www.w3schools.com/js/js_ajax_http.asp

Fabien SHAN
@X140hu4
Jan 12 2018 11:08
It means that even if you want to eat W3Schools cookies you can't because they are in their house and you are not allowed to get them if you are not in the house
But you can download their cookies and put them in your house and eat them :)
Christopher
@bradley1492
Jan 12 2018 11:13
@sjames1958gm Thanks for description of lastIndexOf, I understand now :)
CamperBot
@camperbot
Jan 12 2018 11:13
bradley1492 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8848 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
bilaal-s
@bilaal-s
Jan 12 2018 11:28
@X140hu4 thanks lol
CamperBot
@camperbot
Jan 12 2018 11:28
bilaal-s sends brownie points to @x140hu4 :sparkles: :thumbsup: :sparkles:
:cookie: 314 | @x140hu4 |http://www.freecodecamp.org/x140hu4
Fabien SHAN
@X140hu4
Jan 12 2018 11:28
@bilaal-s Did it help?
mitchell369
@mitchell369
Jan 12 2018 11:29
Hey guys: Can anyone help me with the mutations challenge, I am more interested to see if there is a possible answer to the challenge based on the way I have tackled this challenge.

function mutation(arr) {
var newArr = arr.map(function (arr) {return arr.toLowerCase().split("");});
newArr.map (function (arr) {if (arr[1].indexOf(arr[0]) === -1 )
{newArr = false;}
else {newArr = true;}});

return newArr;
}

mutation(["hEllo", "heY"]);

Markus Kiili
@Masd925
Jan 12 2018 11:36
@mitchell369 Using map to check if second string characters are found on the first is not a good idea. With for loop you can stop early if you don't find a character.
If you wan't to use iterators, you should use every or some that stop early.
mitchell369
@mitchell369
Jan 12 2018 11:44
so, replacing map for every || some and checking the docs for those methods?
Markus Kiili
@Masd925
Jan 12 2018 11:50
@mitchell369 You can split the second string (after lowercasing both) and use every() on it, or just use for loop.
Keon Samuel
@keonsam
Jan 12 2018 12:28
how do I remove all property with an empty string in a object?
Markus Kiili
@Masd925
Jan 12 2018 12:30
@keonsam Do you mean properties with an empty string as property value?
Keon Samuel
@keonsam
Jan 12 2018 12:30
yeah
Markus Kiili
@Masd925
Jan 12 2018 12:32
@keonsam
Object.keys(obj).forEach(function(key){
  if(obj[key]==="") delete obj[key];
});
That works on objects own properties.
Keon Samuel
@keonsam
Jan 12 2018 12:33
@Masd925 thanks
CamperBot
@camperbot
Jan 12 2018 12:33
keonsam sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4652 | @masd925 |http://www.freecodecamp.org/masd925
Keon Samuel
@keonsam
Jan 12 2018 12:34
that won't edit the original object right?
just return a object.
Markus Kiili
@Masd925
Jan 12 2018 12:35
@keonsam It will edit the original.
var newObj = {};

Object.keys(obj).forEach(function(key){
  if(obj[key]!=="") newObj[key]=obj[key];
});
Would make a new object.
mitchell369
@mitchell369
Jan 12 2018 13:19
Why won't this for loop spit out values from inside an array of arrays?
for(i = 0; i < arr.length; i++) {
return Math.max(arr[i]); }
}
for reference, this is from the "return largest number from array" challenge
Marianissimus
@Marianissimus
Jan 12 2018 13:21
@mitchell369 Math.max returns largest NUMBER from array of numbers, not the values
mitchell369
@mitchell369
Jan 12 2018 13:23
so when I express an array as a variable, it ceases to be recognized as an array of numbers?
Marianissimus
@Marianissimus
Jan 12 2018 13:23
is arr[i] another array?
mitchell369
@mitchell369
Jan 12 2018 13:23
@Marianissimus arr[i] would be the sub array
or was my intent
Marianissimus
@Marianissimus
Jan 12 2018 13:24
js never knows (or cares) if your array contains numbers, strings, objects or booleans
but what do you want? to loop inside the subarray?
mitchell369
@mitchell369
Jan 12 2018 13:25
yes
preferably without using 2 for loops
Marianissimus
@Marianissimus
Jan 12 2018 13:27
ok, and to get what? largest number or something?
mitchell369
@mitchell369
Jan 12 2018 13:28
yup, the largest number in an array challenge except I would like to actually understand the solution step by step
Marianissimus
@Marianissimus
Jan 12 2018 13:28
whatever method you will use (even map, reduce or something), you will still actually loop, even if it doesnt appear so
just so you know...
mitchell369
@mitchell369
Jan 12 2018 13:32
@Marianissimus makes sense
what's the deal with using => notation in code camp text editor? Do I need to make some kind of adjustment to my browser?
Marianissimus
@Marianissimus
Jan 12 2018 13:37
@mitchell369 actually, your initial approach was pretty good
however, you need to rewrite the math.max method
mitchell369
@mitchell369
Jan 12 2018 13:39
@Marianissimus Thanks.
Actually it was a different topic. Maybe it was just the way I used it in another code exercise but does FCC text editor accept => notation?
CamperBot
@camperbot
Jan 12 2018 13:39
mitchell369 sends brownie points to @marianissimus :sparkles: :thumbsup: :sparkles:
:cookie: 453 | @marianissimus |http://www.freecodecamp.org/marianissimus
Aditya
@ezioda004
Jan 12 2018 13:40
@mitchell369 => is ES6, the editor works but it warns, you can add // jshint ignore: start on top of your code for the editor to skip warning .
mitchell369
@mitchell369
Jan 12 2018 13:50
@ezioda004 thanks man
CamperBot
@camperbot
Jan 12 2018 13:50
mitchell369 sends brownie points to @ezioda004 :sparkles: :thumbsup: :sparkles:
:cookie: 376 | @ezioda004 |http://www.freecodecamp.org/ezioda004
Stephen James
@sjames1958gm
Jan 12 2018 14:36
@bradley1492 :+1:
Diego Mayer
@Chrono79
Jan 12 2018 14:50
@silver537 thanks
CamperBot
@camperbot
Jan 12 2018 14:50
chrono79 sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 943 | @silver537 |http://www.freecodecamp.org/silver537
Ahmad Abdolsaheb
@ahmadabdolsaheb
Jan 12 2018 15:04
hey everyone, i have a tiny question. i have an image tag and the source need to point to a file one directory up inside a folder called asset. what should i inter for the source of the img tag?
there is how the structure is organized.
asset
------tuba.jpg
src
------app.js
Kaz Baig
@kbaig
Jan 12 2018 15:05
@ahmadabdolsaheb use two periods to mean 'go up one level'
"../asset/tuba.jpg"
Ahmad Abdolsaheb
@ahmadabdolsaheb
Jan 12 2018 15:06
yes, i have ../asset/tuba.jpg
not working for some reason :)
Kaz Baig
@kbaig
Jan 12 2018 15:06
must not be a file ref issue
you could try using JS to log the src to the console to make sure
Ahmad Abdolsaheb
@ahmadabdolsaheb
Jan 12 2018 15:07
let me see
Kaz Baig
@kbaig
Jan 12 2018 15:07
or just inspect source lol
idk why my mind went to JS first LOL
Ahmad Abdolsaheb
@ahmadabdolsaheb
Jan 12 2018 15:09
yeah the inspect source shows ../asset/tuba.jpg
Kaz Baig
@kbaig
Jan 12 2018 15:09
is your folder named asset or assets
Ahmad Abdolsaheb
@ahmadabdolsaheb
Jan 12 2018 15:10
asset
Kaz Baig
@kbaig
Jan 12 2018 15:15
mmmm how is your project set up
are you serving all the relevant files
Ahmad Abdolsaheb
@ahmadabdolsaheb
Jan 12 2018 15:16
its a create-react-app and its running on locally
everything works fine but the photo
Kaz Baig
@kbaig
Jan 12 2018 15:16
hmmm yeah not sure what it could be
do you have a repo i could clone
Ahmad Abdolsaheb
@ahmadabdolsaheb
Jan 12 2018 15:20
thanks for the help,
just a heads up i changed asset to assets and changed the code accordingly?
AdolphChen
@AdolphChen
Jan 12 2018 15:25
excuse i want to ask about .hasOwnProperty(propname), in this question how should i use the propname
who can tell me ,now i have no thoughts,thank you!
Kaz Baig
@kbaig
Jan 12 2018 15:26
@AdolphChen not quite sure what you mean
AdolphChen
@AdolphChen
Jan 12 2018 15:29
@kbaig that question is how to use the parameter in that function and use (.hasOwnProperty) ←this method
Kaz Baig
@kbaig
Jan 12 2018 15:31
@ahmadabdolsaheb ah i figured it out
in your code, you're referencing the image as if the html file was the js file
like your html file doesn't actually have access to your assets folder
only the public folder is being served
you need to put the image in the public folder and reference it from there
@AdolphChen what do you mean by use?
@AdolphChen this is what usage of the Object.hasOwnProperty method looks like
var me = {
  fname: 'Kaz',
  lname: 'Baig'
};

console.log(me.hasOwnProperty('fname')); // true
console.log(me.hasOwnProperty('hobbies')); // false
Ahmad Abdolsaheb
@ahmadabdolsaheb
Jan 12 2018 15:35
@kbaig i used const tuba = require('./assets/tuba.jpg'); and it worked
Kaz Baig
@kbaig
Jan 12 2018 15:35
Yeah that should do it too
Ahmad Abdolsaheb
@ahmadabdolsaheb
Jan 12 2018 15:35
@kbaig thanks a lot for looking into my code
CamperBot
@camperbot
Jan 12 2018 15:35
ahmadabdolsaheb sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 518 | @kbaig |http://www.freecodecamp.org/kbaig
Aditya
@ezioda004
Jan 12 2018 15:35
@AdolphChen Say you have
var object = { "name" : "John Doe", "age" : "20" }
Then you can do object.hasOwnProperty("name") (returns Boolean value) to check if it exists in the object
dinesh
@1532j0004kg
Jan 12 2018 16:15
good evening , guys . Can anyone give the tutorial (video or like books) for learning express and mongo completely (covering all topics - zero to hero level), because i need to do project(big).
Jason Luboff
@JLuboff
Jan 12 2018 16:19
I don't think any one tutorial would get you there. You'll need quite a few resources and practice
Kaz Baig
@kbaig
Jan 12 2018 16:20
Luckily express is not challenging, so long as you can wrap your head around the concept of middleware
dinesh
@1532j0004kg
Jan 12 2018 16:20
some good tutorials u have?
Jason Luboff
@JLuboff
Jan 12 2018 16:20
Are you looking for free tutorials or paid?
dinesh
@1532j0004kg
Jan 12 2018 16:20
free :smile:
Christopher McCormack
@cmccormack
Jan 12 2018 16:21
MDN has a surprisingly good tutorial broken into several pieces that may be useful - https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs @1532j0004kg
Jason Luboff
@JLuboff
Jan 12 2018 16:21
@cmccormack Huh... who knew.. (well, you did obiviosily)
Christopher McCormack
@cmccormack
Jan 12 2018 16:22
@JLuboff hehe yeah found it after I had already learned from other resources, read it again anyway to solidify details
dinesh
@1532j0004kg
Jan 12 2018 16:22
tq
@cmccormack
Christopher McCormack
@cmccormack
Jan 12 2018 16:22
@JLuboff sorry no invite to Maui :palm_tree: , maybe it got burnt in that fire you guys had :p
It was great, I haven't had a real vacation like that in many years, maybe never
but now my enthusiasm for work and coding has waned, I need to force myself back into it
Jason Luboff
@JLuboff
Jan 12 2018 16:25
@cmccormack Too soon. Haven't you seen what happened in Montecito (~25-30 miles north), we had rain early this week and caused massive mudslides, 100+ homes destroyed, lots more structures damaged. Last I checked it was.. 17? people dead with still another dozen missing. Its messed up. All due to the fire
Christopher McCormack
@cmccormack
Jan 12 2018 16:25
Wow I had heard something about it but didn't realize it was that bad
Jason Luboff
@JLuboff
Jan 12 2018 16:26
Freeway is still closed I believe
But, Hawaii is great. I used to go 1-2 times a year when I was a kid. Now, I've taken my wife twice, once to the Big Island (stayed in Kona) and once to Maui (stayed in Napali, just above Kananapali (spelling?))
Christopher McCormack
@cmccormack
Jan 12 2018 16:28
We stayed in Kaanapali, really great area if not a bit too pricey
Markus Kiili
@Masd925
Jan 12 2018 16:28
:eyes: Now, I've taken my wife twice
Christopher McCormack
@cmccormack
Jan 12 2018 16:28
food was soooo good!
Markus Kiili
@Masd925
Jan 12 2018 16:28
Oh, you mean to Havaiji.
Christopher McCormack
@cmccormack
Jan 12 2018 16:28
@Masd925 :grin:
Jason Luboff
@JLuboff
Jan 12 2018 16:34
@cmccormack Ya, we rented a condo in Napali, it was cheaper then say Lahaina but still close. Didn't want to stay in Kihei, and Wailei is nice but even pricier
Christopher
@bradley1492
Jan 12 2018 16:39

Hey,
I am still working on the symmetric difference challenge, and I think my problem gets down to the following.

In the following array var arr = [1,2,3,3,3,3,5];

How could I manage to kick out all the numbers that are occuring more than once? Like the posted one would result in arr = [1,2,5]

I tried with creating an object that creates counts for each key value pair, but then I don't know how to delete the key-value pairs, with an occurence count higher than one. And then I would need to convert the object back into an array somehow? This seems kind of tedious.

Is there no "easy" way to check for number occurence in arrays, and then filter out numbers that occured more than once? :) Or is filter or reduce on the arr array the answer here?

Jason Luboff
@JLuboff
Jan 12 2018 16:40
@cmccormack Only problem we found, was we liked the beaches in Wailea more so we kept driving down there which took time (damn slow ass speed limits!)
Christopher McCormack
@cmccormack
Jan 12 2018 16:40
@JLuboff Wailea is great, probably why all the rich celebrities live down there. We got married on the beach next to Tiger Woods and Owen Wilson's houses :D
(At least that's what the guy told us) :D
Jason Luboff
@JLuboff
Jan 12 2018 16:41
Haha, thats awesome
Christopher McCormack
@cmccormack
Jan 12 2018 16:41
@bradley1492 one simple way is to use the Array reduce and only add unique numbers to your accumulator
Kaz Baig
@kbaig
Jan 12 2018 16:42
@bradley1492 check out the indexOf method for arrays
Christopher McCormack
@cmccormack
Jan 12 2018 16:42
@bradley1492 you can also use the Set object https://mdn.io/Set
Kaz Baig
@kbaig
Jan 12 2018 16:42
@bradley1492 or if you're using Array.reduce, check out Array.includes
Christopher
@bradley1492
Jan 12 2018 16:43
@kbaig @cmccormack alright thanks for the answers, somehow I feel I am asking the same question in here over and over again, sorry for that, the challenge just got a bit confusing over time... :)
CamperBot
@camperbot
Jan 12 2018 16:43
bradley1492 sends brownie points to @kbaig and @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1293 | @cmccormack |http://www.freecodecamp.org/cmccormack
:cookie: 519 | @kbaig |http://www.freecodecamp.org/kbaig
Jason Luboff
@JLuboff
Jan 12 2018 16:43
@cmccormack Did you do any hiking? We started hiking into Haleakala but probably only made it a few miles in before turning back. Cool experience, but hiking through Kilauea (Big Island) was better imo
Christopher McCormack
@cmccormack
Jan 12 2018 16:44
@JLuboff only hiking we did was at the Arboretum on the road to Hana, but we did mountain bike down Haleakala
We were going to hike the seven sacred pools but ran out of time and it was really rainy
The two excursions I found that were really worth their money were the express bike trip down the mountain, and the Sea Maui sunset booze cruise. Both were a lot of fun and reasonably priced
@bradley1492 np, it will all click eventually
@bradley1492 whenever doing anything with iterables, first ask yourself if you can use Reduce/Map/Filter
Jason Luboff
@JLuboff
Jan 12 2018 16:48
@cmccormack Oh man. Road to Hana. Beautiful and torturous all at the same time. My wives sciatica was acting up. So sitting for long was hurting. Plus she got all bit up my bugs and gets gnarly hives from it. I also fucked up the rental car during it (we stopped at the ice cream shop and when I was backing out I was ramming it into a mini hill lol). So...then we got to Hana...and decided to go around the backside instead of turning back..that was quite the experience. The road is not meant for rentals :joy:
dinesh
@1532j0004kg
Jan 12 2018 16:48
can anyone tell the online webapp that communicate with ours ,
like siri
:smile:
Christopher McCormack
@cmccormack
Jan 12 2018 16:50
@JLuboff haha nope, they specifically said they would not cover any incidents if you took the back way
Jason Luboff
@JLuboff
Jan 12 2018 16:50
Oh ya, I know but fuck it right?
Christopher McCormack
@cmccormack
Jan 12 2018 16:50
@JLuboff If you do it again, I recommend getting a convertable, it was so much better when we were able to have the top down
@JLuboff ballsy :D
dinesh
@1532j0004kg
Jan 12 2018 16:50
@JLuboff do u know
Christopher
@bradley1492
Jan 12 2018 16:50
@cmccormack Okay, thats handy too thx
I really get the feeling reduce, map and filter are quite essential to really get to know
CamperBot
@camperbot
Jan 12 2018 16:50
bradley1492 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
api offline
Jason Luboff
@JLuboff
Jan 12 2018 16:52
I fucked that rental car up though. We were trying to find the black sand (It was more reddish/brown) beach in Wailea and when I found it, I turned it perhaps a bit too fast and didn't see the huge pot hole. Busted the front fender. Took it to a body shop the day before we left. They took a look and said "Our minimum charge is $50. This is going to be the most expensive screw you'll ever buy" :joy: @cmccormack
@1532j0004kg Not sure
Kaz Baig
@kbaig
Jan 12 2018 16:52
@bradley1492 I would agree with that intuition
dinesh
@1532j0004kg
Jan 12 2018 16:52
ohh ok
i need for improve my english :smile:
Christopher McCormack
@cmccormack
Jan 12 2018 16:52
@1532j0004kg Maybe https://dialogflow.com/ ? Google Assistant has an SDK as well
@JLuboff HAHA should have at least asked them to wash your car
Christopher
@bradley1492
Jan 12 2018 16:54
@kbaig yeah I guess you just have to give it time to grow, and then you'll be able to really work with those methods intuitevely
dinesh
@1532j0004kg
Jan 12 2018 16:55
@cmccormack where to speak
Kaz Baig
@kbaig
Jan 12 2018 16:55
@bradley1492 yeah def a rhythm that you fall into after working with the lang for some time
Jason Luboff
@JLuboff
Jan 12 2018 16:55
@cmccormack It ended up being two screws so, it worked out :P
Christopher McCormack
@cmccormack
Jan 12 2018 16:56
@bradley1492 what's great about Map and Filter is they return a NEW array, so you aren't modifying your existing array, which helps prevent making mistakes with existing data.
@JLuboff haha maybe you should have done more damage just to get your money's worth
Christopher
@bradley1492
Jan 12 2018 16:56
@kbaig I just don't quite know the "essence" of the functional programming paradigm. Once more, I think this comes naturally over time and projects, challenges etc..
dinesh
@1532j0004kg
Jan 12 2018 16:56
i need for lap!
Christopher McCormack
@cmccormack
Jan 12 2018 16:58
@bradley1492 When/If you jump into React it all really comes together
Jason Luboff
@JLuboff
Jan 12 2018 16:58
@cmccormack They wouldn't even bother with the deep gouges I left in the rear bumper, said the minimum wage workers wouldn't even notice...they were right. Man. Talking about this really makes me miss Hawaii.. been almost 3 years since I last went
Christopher McCormack
@cmccormack
Jan 12 2018 16:58
React made me change the way I think about coding, in a good way
Kaz Baig
@kbaig
Jan 12 2018 16:58
@bradley1492 tldr no side effects for predictability and therefore improved testing, immutability for multiple reasons, including tracking things as they change easier
Christopher McCormack
@cmccormack
Jan 12 2018 16:59
@JLuboff yeah the cars there are pretty scuffed anyhow, probably because it's harder to sell them off at auctions as well as getting new cars to the island
Christopher
@bradley1492
Jan 12 2018 17:04
@cmccormack Alright, yeah I thought just like that it would be some sort of thing you need to learn, and can value just a bit later :)
Jason Luboff
@JLuboff
Jan 12 2018 17:05
@cmccormack Ya. Well glad you had a great trip. When do you go back to work?
Christopher
@bradley1492
Jan 12 2018 17:05
@kbaig Okay sounds good, but hasn't had any value since I started FCC, but it'll all fall into place as in the previous message
Kaz Baig
@kbaig
Jan 12 2018 17:06
@bradley1492 It'll likely not become relevant during the fCC syllabus except perhaps when doing React
It's an optional paradigm in any case
Christopher
@bradley1492
Jan 12 2018 17:07
@kbaig Functional programming is optional at all stages of frontend development and backend development?
Christopher McCormack
@cmccormack
Jan 12 2018 17:07
@JLuboff back to work now, doing some research for a web app for work right now, getting back into the swing of things
Kaz Baig
@kbaig
Jan 12 2018 17:07
@bradley1492 yeah, as are the other paradigms
Within JS, it's better to think of them as styles of programming rather than full on paradigms
Christopher
@bradley1492
Jan 12 2018 17:08
@kbaig is the functional paradigm then the most reasonable in js, if able to be pulled off in a clean way? Or the most clean and modern so to speak?
Kaz Baig
@kbaig
Jan 12 2018 17:10
Different people will tell you different things
Christopher McCormack
@cmccormack
Jan 12 2018 17:10
@kbaig yay I see you finally added a profile pic :)
Christopher
@bradley1492
Jan 12 2018 17:11
@kbaig Okay then I'll find out for myself :)
Thanks for the infos
Kaz Baig
@kbaig
Jan 12 2018 17:11
But I'd say the functional folks definitely feel that they are the most modern :D
@cmccormack :D
Christopher
@bradley1492
Jan 12 2018 17:12

@kbaig yes I just came across funfunfunction functional programming videos on youtube as a help for some challenges here a while ago.

It just seemed like something that saves you work and hassle, if you take the time to learn...

Jason Luboff
@JLuboff
Jan 12 2018 17:13
@cmccormack He still shows as a blue blob to me @kbaig :P
Christopher McCormack
@cmccormack
Jan 12 2018 17:13
I just went on Github to do something and when I popped back here it was different
Kaz Baig
@kbaig
Jan 12 2018 17:13
@JLuboff dw you'll see my beautiful face soon enough ;)
Jason Luboff
@JLuboff
Jan 12 2018 17:13
Ah, ya his github has a pic
Christopher McCormack
@cmccormack
Jan 12 2018 17:15
@bradley1492 Eric Elliott has tons of functional programming articles on Medium. They're each pretty short but should provide lots of detail as a whole
Christopher
@bradley1492
Jan 12 2018 17:17
@cmccormack Many thanks this I will watch certainly, to uncover things for me a bit...
CamperBot
@camperbot
Jan 12 2018 17:17
bradley1492 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
api offline
Christopher McCormack
@cmccormack
Jan 12 2018 17:17
They'll talk about things like functors but don't let that confuse you, in the end it's a pretty simple concept
and don't watch the videos on fun fun function, I think he just makes it more confusing :)
Jason Luboff
@JLuboff
Jan 12 2018 17:18
Functions? What're those? I only know what methods are..
Christopher McCormack
@cmccormack
Jan 12 2018 17:18
@JLuboff they're as fun as their name implies!
Christopher
@bradley1492
Jan 12 2018 17:21
@cmccormack Yes funfunfunction is I guess more of a very gentle introduction to things, from top-down sort of, if that makes sense
Christopher McCormack
@cmccormack
Jan 12 2018 17:21
@bradley1492 he's fun to watch but man does it take a while to get the actual information, much faster to just read :)
Jason Luboff
@JLuboff
Jan 12 2018 17:21
@cmccormack Have you rebuilt any apps for your company that another employee had built?
Christopher McCormack
@cmccormack
Jan 12 2018 17:22
@bradley1492 well that and he actually gets some stuff mixed up in his videos, which he calls out, but it's still a problem
@JLuboff I've only built like 2 apps for my company
Jason Luboff
@JLuboff
Jan 12 2018 17:23
@cmccormack Just new ones I assume then
Christopher McCormack
@cmccormack
Jan 12 2018 17:23
@JLuboff one a geolocation tool, which is probably redundant, the other was unique in that it was for a technology only our team is working with
Christopher
@bradley1492
Jan 12 2018 17:24

@cmccormack Yes I relied a lot on youtube videos, but in the meanwhile I really feel whith reading, you can extract information a lot easier and faster.

Just sometimes stack overflow and mdn alone gets to heavy for me after a while, and then I gravitate to youtube :). But medium is a nice in-between thing...

The mixed up thing with funfunfunction I can't comment on, but I can imagine certainly.

Jason Luboff
@JLuboff
Jan 12 2018 17:25
@cmccormack Gotcha. I've rebuilt (well, still rebuilding...) our vehicle fleet management application and I have a feeling the current (mostly retired) DBA/Programmer isn't going to appreciate it much haha
Christopher McCormack
@cmccormack
Jan 12 2018 17:25
@bradley1492 I ran into a blockage when learning React - I would normally watch videos but I found videos for React, while useful in some ways, were never comprehensive enough. I moved to the Facebook documentation instead and found it much more cohesive, and since then I don't really watch videos much any more
@JLuboff that's awesome! What tech are you using to build it?
@bradley1492 and Medium is great - I like to tag articles to read later then read them while at the gym, gives me incentive to go to the gym AND to read the articles :)
Christopher
@bradley1492
Jan 12 2018 17:27
@cmccormack Goodness thats tough stuff to read medium at the gym! :) I never did that, I just sat around doing nothing, and watching people surfing on a television while at a gym hahaha
But I can certainly see the advantages here
Christopher McCormack
@cmccormack
Jan 12 2018 17:28
@bradley1492 it's not so bad, most articles are little single serving 4 minute reads that I can read between sets
Although programming articles tend to be much longer to read then stated, as you have to not only read it but process it as well
Christopher
@bradley1492
Jan 12 2018 17:29
@cmccormack I just always refused to take a phone with me, I wanted it to be sort of a phone free zone for me
Christopher McCormack
@cmccormack
Jan 12 2018 17:30
I would get so bored! haha to each his/her own :D
Christopher
@bradley1492
Jan 12 2018 17:31
@cmccormack I also see many guys doing stuff on phones in the gym, mainly I just walk around and drink water ^^. But maybe I will try once, I'll quickly know if it's for me...
Christopher McCormack
@cmccormack
Jan 12 2018 17:31
I'll leave my phone alone though if I'm mentally working through a tough problem on my web app or whatever, gym is a great place to think about that stuff
Christopher
@bradley1492
Jan 12 2018 17:32
@cmccormack yes brain is in a different state and gets power from the lifting etc...
Christopher McCormack
@cmccormack
Jan 12 2018 17:34
I've noticed recently after moving to doing fewer but more complete exercises that my brain has a hard time keeping up, definitely harder to read in that state :)
Jason Luboff
@JLuboff
Jan 12 2018 17:35
@cmccormack Converted the app from Visual Basic to C#. Using a Windows Form app and .NET. SQL for database (just using existing Database but having to modify it, add a couple tables for new features and normalization purposes along with modify some tables and data)
Christopher McCormack
@cmccormack
Jan 12 2018 17:36
@JLuboff is it a webapp?
if not you should make it one :D showcase all your latest skills
Jason Luboff
@JLuboff
Jan 12 2018 17:39
@cmccormack No, keeping it along the lines that it is. So .NET published application. Its not the prettiest but it works. I'm potentially going to be building a different (new) web based app soon though
Christopher
@bradley1492
Jan 12 2018 17:40
@cmccormack yes I can imagine I am doing some training without weights and these get pretty intense ironically...
Christopher McCormack
@cmccormack
Jan 12 2018 17:44
Well gents I gotta run, ttyl!
Jason Luboff
@JLuboff
Jan 12 2018 17:47
See ya
Christopher
@bradley1492
Jan 12 2018 17:54
bye
Kaz Baig
@kbaig
Jan 12 2018 17:59
@bradley1492 it took him forever to actually get to code during his guest series on devtips - so frustrating
Christopher
@bradley1492
Jan 12 2018 19:34
@kbaig the guy from funfunfunction? Or Eric Elliott?
Kaz Baig
@kbaig
Jan 12 2018 19:35
@bradley1492 fff
Christopher
@bradley1492
Jan 12 2018 19:44
@kbaig I just once listened to a talk by him on a podcast but I can't remember the name of it. However I thought it was interesting. I think one has to say his videos are quite polished, in comparison to other YT stuff...
Kaz Baig
@kbaig
Jan 12 2018 19:45
@bradley1492 oh I totally agree, but I do think it's true that the vids can sometimes be verbose
DevTips is the same way for that matter
Christopher
@bradley1492
Jan 12 2018 19:52
@kbaig ohhhhh DevTips I can remember, I completely forgot. I think it's more css related isn't it?
@kbaig But I'll watch funfunfunction with DevTips sometime :)
@kbaig Now I know
Kaz Baig
@kbaig
Jan 12 2018 19:53
@bradley1492 yeah def not a focus on JS at all. The goal was to promote designers using code to convey their designs to devs better
Christopher
@bradley1492
Jan 12 2018 19:56
@kbaig Oh ok, I didn't know that, I thought it's just for the purpose of showing off responsive design etc. to new people...
Kaz Baig
@kbaig
Jan 12 2018 19:56
@bradley1492 well that was the goal originally anyway. Ended up being more of a backdrop over time anyway
Christopher
@bradley1492
Jan 12 2018 19:57
@kbaig Ah I see with funfunfunction it's about react, I guess I'll watch it when the time is right :)
Christopher
@bradley1492
Jan 12 2018 20:09

@kbaig @cmccormack Hmm, now I read and watched some more about reduce and tried indexOf, but I seem to only be able to delete duplicates in an array, but not deleting all numbers, that occur more than once.

It always come to

https://jsbin.com/potolun/edit?js,console

this type of operation...
Altough this is filter and not reduce

Kaz Baig
@kbaig
Jan 12 2018 20:12
@bradley1492 a non-optimized way of doing it could be to separate the array into 2 arrays, one with uniques and the other with the rest
then call filter on the one with uniques
Christopher
@bradley1492
Jan 12 2018 20:20
@kbaig But like say here in my codepen https://codepen.io/bradley1492/pen/ppVRKp
I log out [1, 2, 3, 2, 3, 4] my actual problem is to filter out the uniques in this case 1and 4. But I guess I could use indexOf() in a for loop here couldn't I?
Did you mean the same problem with your solution here? Maybe I explained a bit clumsy
Kaz Baig
@kbaig
Jan 12 2018 20:27
@bradley1492 can you link the problem?
Christopher
@bradley1492
Jan 12 2018 20:27
Kaz Baig
@kbaig
Jan 12 2018 20:27
ya
Kaz Baig
@kbaig
Jan 12 2018 20:35
@bradley1492 my workflow was the following:
helper function:
- `filter` two arrays by calling `includes` on the other array
- combine them
------------------------

- create array from arguments
- `reduce` array, using helper function on the first 2 params of `reduce`
- `filter` out duplicates
Christopher
@bradley1492
Jan 12 2018 20:36
@kbaig thx a lot, I have to think through this for a moment
CamperBot
@camperbot
Jan 12 2018 20:36
bradley1492 sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 521 | @kbaig |http://www.freecodecamp.org/kbaig
Kaz Baig
@kbaig
Jan 12 2018 20:38
@bradley1492 no worries, lmk if you have questions
Christopher
@bradley1492
Jan 12 2018 20:45

@kbaig Hm I think I want to use filter in connection with indexOf on my [1, 2, 3, 2, 3, 4]array. I think with indexOf I should be able to filter out all the values, that occur twice, here.

In the helper function, with wich criteria are you filtering the arrays?

Kaz Baig
@kbaig
Jan 12 2018 20:47
const arr1 = arr.filter(existsInArr2);
const arr2 = arr.filter(existsinArr1);
then
const combinedArr = [...arr1, ...arr2];
and that'll get you symmetric diff between two arrays, but we want to do a function for any number of arrays
you could employ a recursive function too instead of using a helper
Christopher
@bradley1492
Jan 12 2018 20:54
@kbaig Okay, I have to admit that I have to sleep over this one more time, and think about it tomorrow again. Thanks for your help, I'll write it out :) how I am doing
CamperBot
@camperbot
Jan 12 2018 20:54
bradley1492 sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
api offline
Kaz Baig
@kbaig
Jan 12 2018 20:57
@bradley1492 youll get there bud
Christopher
@bradley1492
Jan 12 2018 20:58
@kbaig Thx :) it's one of the toughest things I did on FCC till now
CamperBot
@camperbot
Jan 12 2018 20:58
bradley1492 sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
api offline
Kaz Baig
@kbaig
Jan 12 2018 20:58
@bradley1492 well always good to challenge yourself
Pieter Stokkink
@forkerino
Jan 12 2018 20:59
Here's a challenge: make it a oneliner! :P
Christopher
@bradley1492
Jan 12 2018 21:00
@kbaig I have to admit that that is right
Jason Luboff
@JLuboff
Jan 12 2018 21:00
@forkerino Mr. OneLiner himself in the house
Pieter Stokkink
@forkerino
Jan 12 2018 21:01
(:
Jason Luboff
@JLuboff
Jan 12 2018 21:03
Whats up?
Pieter Stokkink
@forkerino
Jan 12 2018 21:05
Just slinging some code, how about you?
Jason Luboff
@JLuboff
Jan 12 2018 21:05
Lunch right now...but been studying and learning about publishing .NET apps
Pieter Stokkink
@forkerino
Jan 12 2018 21:06
Is it fun?
Jason Luboff
@JLuboff
Jan 12 2018 21:07
Eh. Studying not really, but have my test on Tuesday. Publishing .NET isn't too big a deal, it does most of the work for you
Pieter Stokkink
@forkerino
Jan 12 2018 21:12
Ok, haven't touched any .NET ever, so can't really tell what is going on there. I like the idea of 'it doing most of the work for you'
:smile:
Kaz Baig
@kbaig
Jan 12 2018 21:15
@forkerino Does this count as a one line solution lol
function sym(args) {

  return arguments.length <= 2 ? [
    ...arguments[0].filter(e1 => !arguments[1].includes(e1)),
    ...arguments[1].filter(e2 => !arguments[0].includes(e2))
  ].filter((e, i, a) => i === 0 || e !== a[i - 1]) :
  sym([
    ...arguments[0].filter(e1 => !arguments[1].includes(e1)),
    ...arguments[1].filter(e2 => !arguments[0].includes(e2))
  ], ...Array.from(arguments).slice(2))
    .filter((e, i, a) => i === 0 || e !== a[i - 1]);

}
I can make it uglier if you like
def cleaner as a non one liner here
function sym(args) {

  const diffHelper = (a1, a2) => a1.filter(e1 => !a2.includes(e1));
  const diff = (a1, a2) => [...diffHelper(a1, a2), ...diffHelper(a2, a1)];

  return Array.from(arguments).reduce((a, b) => diff(a, b)).filter((e, i, a) => i === 0 || e !== a[i - 1]);

}
Pieter Stokkink
@forkerino
Jan 12 2018 21:23
@kbaig maybe technically it is a one-liner, but there is another way... In your second solution you assume in your filter that the final array is sorted, but I'm not sure that will always be the case. I used [...new Set(arr)] in my one-liner.
Jason Luboff
@JLuboff
Jan 12 2018 21:24
@forkerino Well, .NET is just a framework. So I can program in C# or VB or whatever language can interacte with it and use the same components like the SQL client for example. They may attach to it slightly different but the methods are generally the same. Publishing is just essentially compiling the code and creating an installer. You just tell it where you want the installer and how it will be installed. Buuuttt you can get more technical in the applications properties prior to publishing
Kaz Baig
@kbaig
Jan 12 2018 21:24
@forkerino i don't think order matters for the second solution - can you clarify? The first solution is just a recursive, one line version of the second
Pieter Stokkink
@forkerino
Jan 12 2018 21:25
@kbaig but that last filter is taking out duplicates only if they are grouped together
maybe not sorted, but at least two identical elements in a row
if one of my arrays would be [1, 4, 1] and all of them are kept, you'd end up with an extra 1
Kaz Baig
@kbaig
Jan 12 2018 21:26
@forkerino doesn't e !== a[i - 1] make sure that doesn't happen
o wait not if the element is at index 0
Pieter Stokkink
@forkerino
Jan 12 2018 21:27
@kbaig I did not get a lot of sleep last night, but I'm pretty sure it only compares elements to the elements right before it
so [1, 1, 4] would become [1, 4], but [1, 4, 1] would remain the same
Kaz Baig
@kbaig
Jan 12 2018 21:27
tbh idk why I implemented that filter that way
Pieter Stokkink
@forkerino
Jan 12 2018 21:28
it happens
:)
@kbaig the one-liner I have is not perfect either, it uses .includes twice
and is therefore rather lengthy
but not sure how to compress it more
const sym = (...args) => args.reduce((a,b) => a.concat([...new Set(b)]).filter(v => !b.includes(v) || !a.includes(v)), [])
not the easiest to read either
Kaz Baig
@kbaig
Jan 12 2018 21:31
@forkerino well that's fixed now
function sym(args) {

  const diffHelper = (a1, a2) => a1.filter(e1 => !a2.includes(e1));
  const diff = (a1, a2) => [...diffHelper(a1, a2), ...diffHelper(a2, a1)];

  return Array.from(arguments).reduce((a, b) => diff(a, b)).filter((e, i, a) => i === 0 || !a.slice(0, i).includes(e));

}
Pieter Stokkink
@forkerino
Jan 12 2018 21:32
:+1:
@JLuboff So, are you enjoying C#? It's quite OOP-ish, no?
Jason Luboff
@JLuboff
Jan 12 2018 21:38
@forkerino It is ya. I'm liking it more now then I did when I first started. I definitely like it more then VB. I think I still prefer JS over it, but thats probably since I have a better grasp of JS, that and the JS docs are much easier to understand (IMO at least)
It is very verbose which can be a bit annoying. Not loose typed like JS
Pieter Stokkink
@forkerino
Jan 12 2018 21:43
@JLuboff Nothing wrong with typed languages
prevents those silly .map is not a function errors
when you pass a single value instead of an array
Jason Luboff
@JLuboff
Jan 12 2018 21:44
Ya.. you'll get the linter yelling at you long before that :P
Pieter Stokkink
@forkerino
Jan 12 2018 21:48
VS Code actually suggests the types based on what the function you are calling does in the body. I like that feature. But I'm on a path towards writing tests before writing code, it prevents a lot of bugs. Have been studying TDD for a couple weeks while finally learning Django.
I need some sleep. Catch you guys later!
forkerino @forkerino :zzz:
Jason Luboff
@JLuboff
Jan 12 2018 21:49
I've been using VS Community 2015 so similar to VS code
See ya, have a good weekend
Pieter Stokkink
@forkerino
Jan 12 2018 21:49
you 2
:wave: