These are chat archives for FreeCodeCamp/HelpJavaScript

8th
May 2018
Brad
@bradtaniguchi
May 08 2018 04:28
Has anyone used the npm husky package??
JJ Megma
@megma_jj_twitter
May 08 2018 05:28
What is that?
Brad
@bradtaniguchi
May 08 2018 05:42
@megma_jj_twitter This package: https://www.npmjs.com/package/husky
abraham anak agung
@padunk
May 08 2018 08:11
Hi all, anyone know what is point free style?
Stephen James
@sjames1958gm
May 08 2018 09:49
@padunk It is a style where you use composition (combining functions) rather than parameters.
It is more common in functional languages, but you can adapt js to the style
http://lucasmreis.github.io/blog/pointfree-javascript/
tundeiness
@tundeiness
May 08 2018 09:57

i need help with this challenge. I keep getting the original collection in return

function whatIsInAName(collection, source){
  // What's in a name?
  var arr = [];
  // Only change code below this line

  for(var key in source){
    for(var x = 0; x < collection.length; x++){

        if(collection[x].hasOwnProperty(key)){
                arr.push(collection[x]); 
        }
    }
  }


  // Only change code above this line
  return arr;
}

what could be the problem?

Markus Kiili
@Masd925
May 08 2018 09:58
@tundeiness The outer loop needs to be over collection, and inner through source's keys.
Then you need some loop logic to keep those objects that have matching property values with source, for all the source's keys.
tundeiness
@tundeiness
May 08 2018 09:59
@Masd925 okay...let me tweak that a bit..but why? I should be comparing the source with the elements in the collection No?
Markus Kiili
@Masd925
May 08 2018 10:00
@tundeiness You need to check if the looped object (from array collection) has all the keys that source has and also that property values match. If they do, you keep the object.
tundeiness
@tundeiness
May 08 2018 10:02
@Masd925 I tried it right now, still the same result.
Markus Kiili
@Masd925
May 08 2018 10:02
@tundeiness Post the code please.
tundeiness
@tundeiness
May 08 2018 10:03
@Masd925
for(var x = 0; x < collection.length; x++){
    for(var key in source){

        if(collection[x].hasOwnProperty(key)){
                arr.push(collection[x]); 
        }
    }
  }
Stephen James
@sjames1958gm
May 08 2018 10:03
@tundeiness If you express it in english then maybe it makes more sense
for each value in collection
   keep that value if for every key in source
      the value has the key and the property values match
Markus Kiili
@Masd925
May 08 2018 10:04
@tundeiness You are pushing the object if it has one source key. You should be pushing if it has all the source's keys and also the property values match.
Stephen James
@sjames1958gm
May 08 2018 10:04
@tundeiness you aren't checking the value of the properties
tundeiness
@tundeiness
May 08 2018 10:05
@sjames1958gm hmmm..okay
Stephen James
@sjames1958gm
May 08 2018 10:06
As @Masd925 says you should push only if Every key/value from source is in collection[x]
tundeiness
@tundeiness
May 08 2018 10:06
@tundeiness i'm a bit confused on which to use though.. ".hasOwnProperty" or Object.keys()
Markus Kiili
@Masd925
May 08 2018 10:07
@tundeiness A loop solution needs a flag variable. Another way would be to use a suitable array iterator instead of the inner loop.
tundeiness
@tundeiness
May 08 2018 10:07
@sjames1958gm hasOwnProperty yields a boolean
@Masd925 how?
@sjames1958gm the Object.keys() only returns keys and not values...I have even seen index as well.
Stephen James
@sjames1958gm
May 08 2018 10:09
@tundeiness that only checks one property - you need to check all properties.
The use of a flag works like this
    var all = true;
    for (var key in source) {
       if key not in collection[x] or values don't match
         all = false
    }
    if (all) push value
Markus Kiili
@Masd925
May 08 2018 10:10
@tundeiness What @sjames1958gm posted is the basic loop logic for testing if many conditions hold.
tundeiness
@tundeiness
May 08 2018 10:11
@sjames1958gm okay...now I know about flagging.
Stephen James
@sjames1958gm
May 08 2018 10:11
Because all is outside the loop it can hold meaning about multiple values (the keys from source) rather than a single one
tundeiness
@tundeiness
May 08 2018 10:11
@Masd925 new lesson learnt on how to test if many conditions hold...(flagging)
@sjames1958gm nods slowly...never knew about flagging though.
tundeiness
@tundeiness
May 08 2018 10:55

@sjames1958gm

 for(var key in source){
      for(var x = 0; x < collection.length; x++){

        if( key !== collection[x]){
             all = false;
        }else{
        arr.push(collection[x]);
      }
    }
  }

got an empty array instead....i'm surely doing something the wrong way

Markus Kiili
@Masd925
May 08 2018 10:56
@tundeiness The outer loop still needs to be over collection and inner through source's keys.
tundeiness
@tundeiness
May 08 2018 11:00
@Masd925 yeah, I did. but i was still getting empty array instead
Markus Kiili
@Masd925
May 08 2018 11:01
@tundeiness Just make the two loops as I told and initialize the flag variable inside outer loop but before the inner loop.
Also, you need to test the flag after the inner loop (inside outer loop).
tundeiness
@tundeiness
May 08 2018 11:02
@Masd925 okay. so with the above for loop am I in the clear? just wanted to know if that's where the problem is..
Markus Kiili
@Masd925
May 08 2018 11:04
@tundeiness That is not correct at all. Make the two loops and initialize the flag. Then we can go further.
tundeiness
@tundeiness
May 08 2018 11:04
@Masd925 okay...will show you the codes soon.
@Masd925
 for(var x = 0; x < collection.length; x++){
        var all = true;
        for(var i = 0; i < source.length; i++){

        if( source[i] !== collection[x]){
             all = false;
        }else{
        arr.push(collection[x]);
      }
    }
    }
Markus Kiili
@Masd925
May 08 2018 11:08
@tundeiness Now collection[x] is the looped object and source[i] is the looped source key.
tundeiness
@tundeiness
May 08 2018 11:09
@Masd925 okay
Markus Kiili
@Masd925
May 08 2018 11:09
@tundeiness You need to check if the looped object doesn't have the property key OR the property values don't match. Use hasOwnProperty and !==.
tundeiness
@tundeiness
May 08 2018 11:10
@Masd925 okay
@Masd925
source[i] !== collection[x].hasOwnProperty()
Markus Kiili
@Masd925
May 08 2018 11:12
@tundeiness The syntax is obj.hasOwnProperty(key). What is the object and what is the key here?
tundeiness
@tundeiness
May 08 2018 11:13
@Masd925 key is collection[x] sorry...i didn't know I could use this variant as well
Markus Kiili
@Masd925
May 08 2018 11:15
@tundeiness collection[x] is the object and source[i] is the key.
Blauelf
@Blauelf
May 08 2018 11:31
Isn't source an object, and you need to iterate its properties?
Markus Kiili
@Masd925
May 08 2018 11:35
@Blauelf He had a for...in loop that was changed into a (wrong) for loop at some point.
Blauelf
@Blauelf
May 08 2018 11:36
But source[i] isn't the key even then. Some source_props[i], with var source_props = Object.keys(source); at the beginning would.
Markus Kiili
@Masd925
May 08 2018 11:37
@Blauelf That is true, but for...in loop was one way to go. Looping over source_props is another.
Blauelf
@Blauelf
May 08 2018 11:38
Sure. That last code is just confusing and I don't know what's the thought behind.
tundeiness
@tundeiness
May 08 2018 11:43
@Masd925 okay
Markus Kiili
@Masd925
May 08 2018 11:45
@tundeiness As @Blauelf spotted, the inner loop needs to be over Object.keys(source), and not over source which is not an array.
tundeiness
@tundeiness
May 08 2018 11:47
@Blauelf @Masd925 that was my approach earlier on though..I recognise that the confusion is coming from being able to access the property and value of an object separately and that's what I have not mastered
@Masd925 however @Blauelf said something like this yesterday and I was thinking would I not require a for loop for that or what exactly
Markus Kiili
@Masd925
May 08 2018 11:49
@tundeiness If you did for (key in source){...} then key would be the looped source key. That is another way.
Using array iterators is the third way.
Blauelf
@Blauelf
May 08 2018 11:50
You need two loops, an outer over the collection and an inner over the properties. Those two can be implemented in various ways. As I said, I used higher order functions filter and every instead of for loops. Many ways, you just have to pick one.
tundeiness
@tundeiness
May 08 2018 11:51
@Masd925 @Blauelf the idea behind var source_props = Object.keys(source) is what I don't know. why the source_props when I will still do source_props[i]? that would connote requiring a for loop.
@Masd925 which was what I started with initially...
Blauelf
@Blauelf
May 08 2018 11:51
This would create an array of property names, which you can iterate using a regular for loop.
Markus Kiili
@Masd925
May 08 2018 11:51
@tundeiness Yes.
tundeiness
@tundeiness
May 08 2018 11:53
@Masd925 now the comparison part is where the issue was....key !== collection[x]? which is wrong.
Markus Kiili
@Masd925
May 08 2018 11:53
@tundeiness It needs to be collection[x][key]!==source[key]
Combine that with the hasOwnProperty check (||)
tundeiness
@tundeiness
May 08 2018 11:55
@Blauelf meaning 2 for loops for the collection right? ...i'm now just getting it..so what I now have in the inner for loop is what I will compare with the source using Object.keys() right?
@Masd925 okay...I now get the whole idea...2 for loop for the collection not one for the source and one for the collection like I earlier thought.
Blauelf
@Blauelf
May 08 2018 11:56
@tundeiness Outer loop for collection, inner loop source properties. So for each element of the collection, you test it for all of source's properties.
And after the inner loop you decide whether to push (if you go the push route). Don't push in the inner loop.
tundeiness
@tundeiness
May 08 2018 11:57
@Blauelf okay...permit me to go back to the drawing board again...let me put it in codes :)
abraham anak agung
@padunk
May 08 2018 13:08
@sjames1958gm thank you. Quite confusing with all that arrow functions :smile:
CamperBot
@camperbot
May 08 2018 13:08
padunk sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9235 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
May 08 2018 13:35
@padunk I am reading and re-reading that article
Chris
@ConnectCodes
May 08 2018 14:37
:wave:
Ronique Ricketts
@RoniqueRicketts
May 08 2018 14:42
Greetings ladies and gents.
Jason Luboff
@JLuboff
May 08 2018 15:09
Morning :wave:
Ronique Ricketts
@RoniqueRicketts
May 08 2018 15:10
whats up bruv.
Jason Luboff
@JLuboff
May 08 2018 15:11
Just getting into work..you?
Ronique Ricketts
@RoniqueRicketts
May 08 2018 15:11
here at work. Remote in my machine at home and trying to build up my project.
Jason Luboff
@JLuboff
May 08 2018 15:13
Psh.. I just build my shit on my work computer lol
Ronique Ricketts
@RoniqueRicketts
May 08 2018 15:14
@JLuboff face palm. I can't bother will the annoyance from my team lead. He is a slave driver.
Jason Luboff
@JLuboff
May 08 2018 15:15
Tell him to chill brah
Christopher McCormack
@cmccormack
May 08 2018 15:40
Morning
Ronique Ricketts
@RoniqueRicketts
May 08 2018 15:41
sup?
Christopher McCormack
@cmccormack
May 08 2018 15:43
workin man
you?
Ronique Ricketts
@RoniqueRicketts
May 08 2018 15:51
I am here working on my little school app.
Jason Luboff
@JLuboff
May 08 2018 16:04
@cmccormack Morning
Christopher McCormack
@cmccormack
May 08 2018 16:04
@RoniqueRicketts not done with that yet??
@JLuboff heya :D
Jason Luboff
@JLuboff
May 08 2018 16:05
What up
Christopher McCormack
@cmccormack
May 08 2018 16:05
Working on a master template for work so I no longer have to build templates, any engineer can use it to build their own. Less work for me!
Jason Luboff
@JLuboff
May 08 2018 16:06
Template for networking device..?
Christopher McCormack
@cmccormack
May 08 2018 16:07
for our software-defined stuff, yeah
Jason Luboff
@JLuboff
May 08 2018 16:08
Ah. Neat!
Christopher McCormack
@cmccormack
May 08 2018 16:09
yeah it's been a pain working on creating standards for everything globally but I think we're finally close so I can start working on more fun projects like a frontend for our sdwan controllers
what's up with you?
Jason Luboff
@JLuboff
May 08 2018 16:11
Accomplished my three tasks of the morning, so happy about that lol. Still working on creating an image for WDS but.. getting closer on that I think
Christopher McCormack
@cmccormack
May 08 2018 16:20
dang three tasks and it's only 09:20, nice work :D
Jason Luboff
@JLuboff
May 08 2018 16:21
Luckily they were quick tasks haha (create a new user/send email to supervisor, add users to two different all-in-ones for scanning (damn office moves), and setup a computer)
Any other day I'd probably have been a little lazier about it... :P
Hopefully can get some programming in today too
Christopher McCormack
@cmccormack
May 08 2018 16:24
Man you do so much different stuff
Jason Luboff
@JLuboff
May 08 2018 16:25
Thats what happens when you're in a small team. Only 4 of us for a company of ~250? It might be 200 now.. not sure. But ya...all of us (except our network guy) are sort of jack of all trades
Christopher McCormack
@cmccormack
May 08 2018 16:31
yeah I bet. Ever want something more consistent?
Jason Luboff
@JLuboff
May 08 2018 16:39
I'm being tailored into the programming/database role..and I'd like for that to be my standard role..but most likely would still be doing everything i currently do.. so.. yes I would like for it to be consistent but I also know that position isn't always busy (if that all makes sense) @cmccormack
Christopher McCormack
@cmccormack
May 08 2018 16:43
yeah totally makes sense at your company
Ronique Ricketts
@RoniqueRicketts
May 08 2018 16:43
@cmccormack not yet I am working slowly because Its also a learning moment for me please work is distracting me
Jason Luboff
@JLuboff
May 08 2018 16:44
At one point we were a team of 5, but I don't think they would do that again unless they got someone cheap for helpdesk (I was hired on for helpdesk at what I would say is a much higher than normal helpdesk pay)
Christopher McCormack
@cmccormack
May 08 2018 16:47
that should be fairly easy - get an intern or something straight out of uni
Jason Luboff
@JLuboff
May 08 2018 16:48
Or something out of uni? What else comes out besides people? :P
Christopher McCormack
@cmccormack
May 08 2018 16:49
oops someone haha
Jason Luboff
@JLuboff
May 08 2018 16:49
Ya.. well.. they probably still don't want to do that. Not until oil is back at 90+ a barrel
Christopher McCormack
@cmccormack
May 08 2018 16:51
long drive?
Jason Luboff
@JLuboff
May 08 2018 16:51
long drive where?
Christopher McCormack
@cmccormack
May 08 2018 16:52
your office? You mentioned oil
oh wait isn't your company oil based?
Jason Luboff
@JLuboff
May 08 2018 16:53
Lol ya, we're an oil and gas company
Christopher McCormack
@cmccormack
May 08 2018 16:54
hah duh sorry
Jason Luboff
@JLuboff
May 08 2018 16:54
All good
Brad
@bradtaniguchi
May 08 2018 17:26
time to code :D
Jason Luboff
@JLuboff
May 08 2018 17:27
@bradtaniguchi Right there with you!
Brad
@bradtaniguchi
May 08 2018 17:27
:+1:
Jason Luboff
@JLuboff
May 08 2018 17:27
Actually..trying to figure out some code I have....it doesn't quite make sense...
Ah! Figured it out
Thats what happens when you copy and paste code from another section :P
Brad
@bradtaniguchi
May 08 2018 17:28
I try to never copy paste code cuse half the time I forget to change something :/
Time to write some tests before the code, this time ;D
Jason Luboff
@JLuboff
May 08 2018 17:33
@bradtaniguchi Only reason I did is becuase it does the same thing only difference is the user who submitted the post request. If its a regular individual, it only processes their portion of the form. If it's the user who can modify anyone (stupid..I know) than it processes everyones portion of the form so I have to handle the data slightly different
Brad
@bradtaniguchi
May 08 2018 17:34
beware, copy pasting code is a path to the dark side
hehe Im just kidding
Jason Luboff
@JLuboff
May 08 2018 17:35
Oh but it is. I still need to figure out a way to keep the modifications in check on Database side too (I'm auditing by changing who modified the data last but if the data hasn't changed, no reason to change that person)
I need an if or case statement but have to actually write the code for that
Brad
@bradtaniguchi
May 08 2018 17:42
Hmm Im probably to far from the use case to help haha
Jason Luboff
@JLuboff
May 08 2018 17:46
Ya no worries. Something I have to figure out, which will make me stronger
Brad
@bradtaniguchi
May 08 2018 17:56
Im just trying to figureout how to get data from the back XD
Jason Luboff
@JLuboff
May 08 2018 17:57
You're smarter than me...I'm sure you can figure that out
Oh fancy... Microsoft Word can now read my documents aloud lol
Daniel Simeonov
@dbsimeonov
May 08 2018 17:59
Guys can you tell me how I can filter my items by date/name ? Found few articles but nothing that really works..
Brad
@bradtaniguchi
May 08 2018 17:59
@dbsimeonov what does the data kinda look like?
Daniel Simeonov
@dbsimeonov
May 08 2018 18:01
@bradtaniguchi umm the items contain names/prices/etc so have not started but just trying to understand the logic. its kind of online shopping website that has the options to put them in those orders. Hope it makes sence
Jason Luboff
@JLuboff
May 08 2018 18:01
It really depends on your data structure
But you would need to have a date field
If using a database, its pretty simple to order or filter by date or name
Brad
@bradtaniguchi
May 08 2018 18:02
Id assume your datas coming back from some database right? So youd probably want to sort them in the DB query, and return just the top few, not all of them
Daniel Simeonov
@dbsimeonov
May 08 2018 18:04
not really, coming from the html :(
Jason Luboff
@JLuboff
May 08 2018 18:06
Well you could use .sort() with either name or date but you need to change date into a more useable format like UNIX time
Or just ms I guess
Then do a comparison in the sort
I've done that in the past. Used moment.js to convert a date into unix (or it may have been just regular ms, can't remember) and did a comparison in my sort
Daniel Simeonov
@dbsimeonov
May 08 2018 18:08
I will start with the easiest I guess which will be price, so the steps are to store all of the values to an array? sort it and then give the order to their parrent elements?
Jason Luboff
@JLuboff
May 08 2018 18:10
Ya something like that. Keep in mind to give .sort() an actual callback as
let arr = [10, 5, 1, 20];
console.log(arr.sort()); // result: [1, 10, 20, 5]
Versus with a callback
let arr = [10, 5, 1, 20];
console.log(arr.sort((a,b) => a > b)); // result: [1, 5, 10, 20]
Daniel Simeonov
@dbsimeonov
May 08 2018 18:11
amazing man thanks!
Jason Luboff
@JLuboff
May 08 2018 18:12
Good luck
Gulsvi
@gulsvi
May 08 2018 18:19
Or, go with a while loop ;)
let arr = [10, 5, 1, 20];
let swap = true;

while (swap) {
  swap = false;
  for (let i = 0; i < arr.length - 1; i++) {
    if (arr[i] > arr[i + 1]) {
      [arr[i], arr[i + 1]] = [arr[i + 1], arr[i]];
      swap = true;
    }
  }
}
console.log(arr);
Brad
@bradtaniguchi
May 08 2018 18:19
ew for loop barfs
wait, that sorting algo looks terrible :0
Gulsvi
@gulsvi
May 08 2018 18:20
I should probably not loop through the entire array again on every loop
let arr = [10, 5, 1, 20];
let swap = true;
let len = arr.length

while (swap) {
  len--;
  swap = false;
  for (let i = 0; i < len; i++) {
    if (arr[i] > arr[i + 1]) {
      [arr[i], arr[i + 1]] = [arr[i + 1], arr[i]];
      swap = true;
    }
  }
}
console.log(arr);
better :)
(still awful, I know) O(n^2)
Brad
@bradtaniguchi
May 08 2018 18:23
dont re-invent the wheel, especially if it comes out as a square :P (No offence hehe)
Gulsvi
@gulsvi
May 08 2018 18:24
I wonder what algo .sort() uses internally
Brad
@bradtaniguchi
May 08 2018 18:24
I heard it uses a special merge-sort internally, but then I might actually be different on different browsers. (but this is only what I heard, could be wrong)
Jason Luboff
@JLuboff
May 08 2018 18:27
What type of sort is it do you know? @bradtaniguchi (i.e bubble, etc)
Brad
@bradtaniguchi
May 08 2018 18:28
Off the top of my head none of them, I forget XD, I got spoiled with .sort(), but I personally liked heap sort for no other reason than I studied it the most. But if you asked me to make it right now, Id be screwed
Jason Luboff
@JLuboff
May 08 2018 18:29
Heh
Gulsvi
@gulsvi
May 08 2018 18:29
I'd think .sort() would choose an algo based on what's being sorted
Brad
@bradtaniguchi
May 08 2018 18:30
@JLuboff Oh I read your question wrong sorry
I think ?
I think I remember them mentioning for smaller arrays .sort() does something simplier
Gulsvi
@gulsvi
May 08 2018 18:31
Seems Chrome uses Insertion Sort if the array is less than 10 elements. QuickSort otherwise. Safari uses selection sort, Mozilla uses merge sort.
That code above is bubble sort, which I don't think is useful anywere
I guess it's good if the array is already sorted :laughing:
Jason Luboff
@JLuboff
May 08 2018 18:33
Interesting
JJ Megma
@megma_jj_twitter
May 08 2018 20:02
Merge Sort :one:
Brad
@bradtaniguchi
May 08 2018 20:03
Bucket sort is the best, can't beat the O(1) runtime :sunglasses:
Tiago Correia
@tiagocorreiaalmeida
May 08 2018 20:03
hey @JLuboff
Jason Luboff
@JLuboff
May 08 2018 20:06
@tiagocorreiaalmeida Yo
Tiago Correia
@tiagocorreiaalmeida
May 08 2018 20:06
is it today that we are going to fight for the most nasty lines of code?
Jason Luboff
@JLuboff
May 08 2018 20:07
Ya.. give me like an hour?
Tiago Correia
@tiagocorreiaalmeida
May 08 2018 20:07
sure, let me know
Jason Luboff
@JLuboff
May 08 2018 20:08
:+1:
Tiago Correia
@tiagocorreiaalmeida
May 08 2018 20:19
does anyone have some example of authentication using react + nodejs with passport on te server in this situatuion using social network strategies, im looking at an example just trying to figure out if there are more possible ways
JJ Megma
@megma_jj_twitter
May 08 2018 20:24
@tiagocorreiaalmeida i did that and it didn't go well lol
I have an example for you though
Jason Luboff
@JLuboff
May 08 2018 20:26
@tiagocorreiaalmeida I think @cmccormack has used react and passport?
Christopher McCormack
@cmccormack
May 08 2018 20:26
yeah
but not with a social network
Jason Luboff
@JLuboff
May 08 2018 20:27
Oh.. you used local auth?
Christopher McCormack
@cmccormack
May 08 2018 20:27
yeah
Jason Luboff
@JLuboff
May 08 2018 20:27
Ah. Nevermind then
Brad
@bradtaniguchi
May 08 2018 20:27
fff, something as simple as doing some checks before I save = death :/
Jason Luboff
@JLuboff
May 08 2018 20:31
@tiagocorreiaalmeida Alright.. I'm ready a little earlier than I thought
Tiago Correia
@tiagocorreiaalmeida
May 08 2018 20:45
ups sorry want around
@megma_jj_twitter I got it working thanks either way
CamperBot
@camperbot
May 08 2018 20:45
tiagocorreiaalmeida sends brownie points to @megma_jj_twitter :sparkles: :thumbsup: :sparkles:
api offline
Tiago Correia
@tiagocorreiaalmeida
May 08 2018 20:46
image.png
this is my only issue good old facebook doesnt let people turn the api on at the localhost
@JLuboff
Christopher
@bradley1492
May 08 2018 20:49

Good evening,
I am trying to push all the items of the sorted 2d-array to arr1 if there are none of the same items in arr1.
The problem is that I get this weird result, when logging to the console, where "Hair-Pin" gets added but "Bowling Ball" doesn't. Can someone explain to me what's happening here?

https://codepen.io/bradley1492/pen/qYpgpG?editors=0010

Tiago Correia
@tiagocorreiaalmeida
May 08 2018 20:49
in other words push the values that doesnt exist on the arr1 into it?
Christopher
@bradley1492
May 08 2018 20:50
@tiagocorreiaalmeida exactly :)
Tiago Correia
@tiagocorreiaalmeida
May 08 2018 20:51
I think I found your issue
if (arr1[k].includes(sorted[l][1]) == false){
Jason Luboff
@JLuboff
May 08 2018 20:51
@tiagocorreiaalmeida got stuck looking at a printer give me a few (not sure where the timers at)
Tiago Correia
@tiagocorreiaalmeida
May 08 2018 20:51
I think you mean
arr1[k][1] @bradley1492
2min @JLuboff but I can set it to 5 again maybe its better, take your time
I regreated immediately removing that break @bradley1492 :D
Christopher
@bradley1492
May 08 2018 20:53
@tiagocorreiaalmeida sorry for that crash
@tiagocorreiaalmeida I forgot to mention DON'T REMOVE THE BREAK
Tiago Correia
@tiagocorreiaalmeida
May 08 2018 20:54
either way It seems to be working?
Christopher
@bradley1492
May 08 2018 20:56
@tiagocorreiaalmeida I dealt with your tip before. It doesn't make a difference becuase the includes method checks on every element in the array anyway I think. I don't have to tell it to look for the first position here specifically... I hope it's clear what I am trying to say
Jason Luboff
@JLuboff
May 08 2018 20:56
@tiagocorreiaalmeida holy hell. This printer takes forever to warm up
Few more minutes haha
Tiago Correia
@tiagocorreiaalmeida
May 08 2018 20:56
sure np :D
in this case include wont work @bradley1492
sorry I was sleeping on it
Christopher
@bradley1492
May 08 2018 20:58
@tiagocorreiaalmeida Hm what a pity include seemed like the perfect solution for my needs here
I just don't get it. Why does it seem to work with "Bowling-Ball" but not with "Hair-Pin"
Jason Luboff
@JLuboff
May 08 2018 20:59
@tiagocorreiaalmeida Alright I'm, in. @cmccormack codefight?
Tiago Correia
@tiagocorreiaalmeida
May 08 2018 20:59
@bradley1492
for (let k = 0; k < arr1.length; k++){
    for (let l = 0; l < sorted.length; l++){
      if (arr1[k][1].includes(sorted[l][1]) == false){
        arr1.push(sorted[l]);
    }
  }
  break;
}
cause
it will check value by value
and it will return that the current position doesnt includes the value sometimes
so it will push it to there
imagine
you are on arr[2]
arr1[2] and you are checking for Bowling Ball
it will return false
im not sure if im being clear :\
console.log(arr1[1].includes(sorted[2][1]));
try this will give you an idea why its not working
so is the printer alive or you just used the hammer method @JLuboff ?
Jason Luboff
@JLuboff
May 08 2018 21:03
It's alive! Had to power cycle it for it to tell me there was a stuck piece of paper. But it takes a couple minutes to shut down and then even longer to "warm up"
It's a Canon ImageRunner. Great All-In-One device but this particular one is always giving us trouble
Tiago Correia
@tiagocorreiaalmeida
May 08 2018 21:05
did you pet it? some say it helps
Jason Luboff
@JLuboff
May 08 2018 21:05
:joy:
Christopher
@bradley1492
May 08 2018 21:05
@tiagocorreiaalmeida ohhh I think I understand. Does include only result in true if in my case both of the item-names are on an identical position in each of the arrays?
Tiago Correia
@tiagocorreiaalmeida
May 08 2018 21:06
includes works on 1d array not 2d :\
Christopher
@bradley1492
May 08 2018 21:07
@tiagocorreiaalmeida did you just find that out?
Tiago Correia
@tiagocorreiaalmeida
May 08 2018 21:07
nah I knew it but I wasn't thinking about it
the way of doing the exercise you have to do is t ocheck that if every element on the arr1 is differentt from the one you are trying to see if exists
if so then push it
Christopher
@bradley1492
May 08 2018 21:08
@tiagocorreiaalmeida ah ok hm I thought about that, but then I thought because I am looping through the 2d array, that I am sort of dealing with 1d arrays.... :)
Tiago Correia
@tiagocorreiaalmeida
May 08 2018 21:08
I would reverse things
loop the second array
and for each value check if it doesnt exists on the second one if it exists you can break and avoid the loop from going on
you could also use the method .every
Christopher
@bradley1492
May 08 2018 21:10
@tiagocorreiaalmeida I also thought about using filter on the sorted array to filter out all the double-listed items, but I then didn't know any further.
Thanks in the meanwhile I'll check out your advice!
CamperBot
@camperbot
May 08 2018 21:10
bradley1492 sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
:cookie: 525 | @tiagocorreiaalmeida |http://www.freecodecamp.org/tiagocorreiaalmeida
Tiago Correia
@tiagocorreiaalmeida
May 08 2018 21:17
@JLuboff the first one might sound confusing at first
but the only thing you need to check is that if the next letter on the string is the next letter on the alphabet
Jason Luboff
@JLuboff
May 08 2018 21:20
@tiagocorreiaalmeida ya got the first one but ran out of time for the last
Tiago Correia
@tiagocorreiaalmeida
May 08 2018 21:20
np, still always good to code one or two ;)
Jason Luboff
@JLuboff
May 08 2018 21:21
And my co-worker was talking to me lol
charcodeat was definitely the better and qicker way to do that one
Tiago Correia
@tiagocorreiaalmeida
May 08 2018 21:22
does that mean it was 2vs1 ? :|
:D
Jason Luboff
@JLuboff
May 08 2018 21:23
He doesn't know shit about programming...unless its a cisco switch. He'll run circles around me when it comes to that
Brad
@bradtaniguchi
May 08 2018 21:32
I fixed my issue ive been working on for 2 hours by saying screw it :P
Jason Luboff
@JLuboff
May 08 2018 21:34
Thats a good fix
Brad
@bradtaniguchi
May 08 2018 21:46
Best and worse part of using strict typing, when you refactor you turn something off/change it and everything explodes :D
Jason Luboff
@JLuboff
May 08 2018 22:07
Grr... I hate when my node app hangs for no reason
Christopher McCormack
@cmccormack
May 08 2018 22:09
@JLuboff no reason...
Jason Luboff
@JLuboff
May 08 2018 22:10
There was no reason!
None! Ziltch. Zero. Negative reasons!
Christopher McCormack
@cmccormack
May 08 2018 22:10
Maybe a solar flare?
Jason Luboff
@JLuboff
May 08 2018 22:10
I'll go with that
Christopher McCormack
@cmccormack
May 08 2018 22:11
those things are no joke, we used to have to send out emails when there was a solar flare because our SatCom would be highly impacted
Jason Luboff
@JLuboff
May 08 2018 22:12
We have issues with your ethernet radios on particular clear sunny days due to I guess refraction off the water
Christopher McCormack
@cmccormack
May 08 2018 22:13
2.4GHz I bet
Jason Luboff
@JLuboff
May 08 2018 22:14
Correct. We have a few 5 GHz but the majority are 2.4
Christopher McCormack
@cmccormack
May 08 2018 22:15
We moved to higher density, lower power 5Ghz mainly, vast improvement
quite a bit pricier though
Jason Luboff
@JLuboff
May 08 2018 22:17
We use Ubiquity radios exclusively. They're pretty good and not very expensive. The 2.4's (Rocket M5) were I think $300? for the set (two radios, two dishes). The 5 ghz's models I can't remember but still I think around the same price for the set
Christopher McCormack
@cmccormack
May 08 2018 22:22
Yeah they make good stuff - when oil prices go back up you guys should definitely get some more 5GHz AC Wave 2 APs :D
Jason Luboff
@JLuboff
May 08 2018 22:23
That'd be cool
Ah... these are the 5GHz radio's we have https://www.ubnt.com/airmax/nanobeam-ac-gen2/ super easy to mount and small which is nice
Christopher McCormack
@cmccormack
May 08 2018 22:26
Their stuff looks so nice
Norvin Burrus
@ndburrus
May 08 2018 22:27
@NikolaNbgd you may enjoy thsse: :fallen_leaf:
Jason Luboff
@JLuboff
May 08 2018 22:30
@cmccormack They are and super inexpensive in comparison to other options out there. Rarely go down. You can monitor multiple radios from a single web app (unfortunately does not work across all platforms)
Christopher McCormack
@cmccormack
May 08 2018 22:32
@JLuboff i'll take 10!
Jason Luboff
@JLuboff
May 08 2018 22:34
Do ittt
Jason Luboff
@JLuboff
May 08 2018 22:40
@cmccormack Don't you have two houses? You could link them up with a pair of radios and then only pay for one internet connection!
Christopher McCormack
@cmccormack
May 08 2018 22:43
Haha it's like 150 miles apart, think they have that range?
Jason Luboff
@JLuboff
May 08 2018 22:46
Nah...at least the ones I showed dont
I think up to 30 miles
Christopher McCormack
@cmccormack
May 08 2018 22:46
still pretty good
although only as a backhaul
Jason Luboff
@JLuboff
May 08 2018 22:52
True
Whooo. Think I figured out my SQL query. It's ugly..but..so are most of my queries lol
Christopher McCormack
@cmccormack
May 08 2018 22:54
aaaand all of your tables were dropped
Jason Luboff
@JLuboff
May 08 2018 22:57
Hahahaha luckily that wouldn't be the worst thing ever but it would be a pain
Christopher McCormack
@cmccormack
May 08 2018 22:58
good man has backups
Jason Luboff
@JLuboff
May 08 2018 23:00
Meh. Just a development database. I have all my creation steps and what not technically backed up
Once the database is live, it will be backed up though
Christopher McCormack
@cmccormack
May 08 2018 23:04
make sure you also write it out on paper with pen just in case
Jason Luboff
@JLuboff
May 08 2018 23:04
My hand writing is atrocious. Wouldn't be able to read it (I have my creation steps in a sql file which is part of my git repo)
Christopher McCormack
@cmccormack
May 08 2018 23:06
maybe you should have been a doctor!
Jason Luboff
@JLuboff
May 08 2018 23:07
I don't think I'm smart enough lol
Christopher McCormack
@cmccormack
May 08 2018 23:07
Everyone is very smart, it's how much we apply ourselves to something that makes it happen
Jason Luboff
@JLuboff
May 08 2018 23:08
...Fine...I don't like blood
Christopher McCormack
@cmccormack
May 08 2018 23:08
Everyone has blood in them, it's how much we apply ourselves to playing with blood that makes it happen
... or something
Jason Luboff
@JLuboff
May 08 2018 23:09
:P
Brad
@bradtaniguchi
May 08 2018 23:10
When I get blood taken I start to histarically laugh if I look at it, and feel like fainting
Jason Luboff
@JLuboff
May 08 2018 23:10
I only recently semi-conquered my fear of needles. Still can't look
Christopher McCormack
@cmccormack
May 08 2018 23:14
Just use a knife instead!
Well I'm off for the night, see you all later!
Jason Luboff
@JLuboff
May 08 2018 23:14
See ya