These are chat archives for FreeCodeCamp/Help

31st
Jul 2018
Karma Drukpa
@coderkarma
Jul 31 2018 00:18
String.prototype.toAlternatingCase = function () {
   let newStr = '';
    // loop through string
    for (let i = 0; i < this.length; i += 1){

     // if char is uppercase covert to lowerCASE
      if (this[i] === this[i].toUpperCase()){
         newStr += this.toLowerCase());
          // If char is lower then convert to upper
      } else {
          newStr += this.UpperCase();
      }
    }
    return  newStr;
  }
Kyle Holm
@thekholm80
Jul 31 2018 00:19
it's a good try
Karma Drukpa
@coderkarma
Jul 31 2018 00:22
so with this we could refer for particular things what we want to ?
Kyle Holm
@thekholm80
Jul 31 2018 00:22
my dude i don't know how to teach you what this is
you're gonna have to do some reading
Karma Drukpa
@coderkarma
Jul 31 2018 00:22
okay sir
Bjorn van de Peut
@bjorno43
Jul 31 2018 00:57
woohoo, IM chat fully implemented
Karma Drukpa
@coderkarma
Jul 31 2018 00:58
can I see that?
@bjorno43
congratulations
Bjorn van de Peut
@bjorno43
Jul 31 2018 00:58
Erm, you can, but it's in Dutch so you might struggle a bit in navigating around :P
Kyle Holm
@thekholm80
Jul 31 2018 00:59
Hoeveel kazen hondenkus?
i dutch like a pro
Karma Drukpa
@coderkarma
Jul 31 2018 01:00
It's all good. I want just to see. even i want to build full functional web application in future.
Bjorn van de Peut
@bjorno43
Jul 31 2018 01:00
@coderkarma You can register here: https://icecub.nl It's fine supply a fake email address. It's not used yet
@thekholm80 You just said: How many cheese dog kiss :joy:
Kyle Holm
@thekholm80
Jul 31 2018 01:01
and i mean it
okay, dutch is hard
Bjorn van de Peut
@bjorno43
Jul 31 2018 01:03
Ye it is, lol
Karma Drukpa
@coderkarma
Jul 31 2018 01:04
@bjorno43 looks good. I hit the translation option.
Kyle Holm
@thekholm80
Jul 31 2018 01:05
so, so blue
so very blue
Bjorn van de Peut
@bjorno43
Jul 31 2018 01:06
Though you basicly click "Registreren".
Gebruikersnaam = Username
Wachtwoord = Password
Wachtwoord herhalen = Repeat Password
Geslacht = Gender (male / female)
Geboortedatum = Date of birth
Check all checkboxes and done
Karma Drukpa
@coderkarma
Jul 31 2018 01:08
what technology did you used to build that? @bjorno43
Bjorn van de Peut
@bjorno43
Jul 31 2018 01:08
@coderkarma PHP and websockets
Karma Drukpa
@coderkarma
Jul 31 2018 01:09
oh!! @ why not react and redux @bjorno43
new technology...
Kyle Holm
@thekholm80
Jul 31 2018 01:09
hahaha
bob's scared of JS
Karma Drukpa
@coderkarma
Jul 31 2018 01:09
@thekholm80 hahahah really
Bjorn van de Peut
@bjorno43
Jul 31 2018 01:11
@coderkarma The same reason you won't just fire up an airplane to get to your destination faster. Just because it's there, doesn't mean you know how to use it. And just because it's more convenient for that situation, doesn't mean you're willing to learn it either :P
The problem isn't the learning of Node and whatever else. The problem is actually getting it work on my server. My server is quite complicated with multiple domains using apache. You can't just install Node to it and make it available for all domains. Cuz damn Node has to use its own webserver..
Kyle Holm
@thekholm80
Jul 31 2018 01:14
are you using laravel?
Bjorn van de Peut
@bjorno43
Jul 31 2018 01:14
Nope
Tom
@moT01
Jul 31 2018 01:15
anyone got the legacy data viz cert since the new site ?
Bjorn van de Peut
@bjorno43
Jul 31 2018 01:15
With my 16+ years of PHP experience, I think I know how to safely program my own login scripts :P And I really see no reason to use Laravel for anything else, lol
Kyle Holm
@thekholm80
Jul 31 2018 01:16
oh i thought it was a front end framework
Bjorn van de Peut
@bjorno43
Jul 31 2018 01:16
No Laravel is a backend PHP framework
Karma Drukpa
@coderkarma
Jul 31 2018 01:17
@bjorno43 oh my gosh, you have 16 + years of experience in php. that is incredible .
Kyle Holm
@thekholm80
Jul 31 2018 01:17
oh look now i know 100% more about php than i want to know
Bjorn van de Peut
@bjorno43
Jul 31 2018 01:17
:joy:
Karma Drukpa
@coderkarma
Jul 31 2018 01:19
I want to build full web application but I don't know how long will it take me to do that since I don't know much things @bjorno43
how long did it take you to build that @bjorno43
Bjorn van de Peut
@bjorno43
Jul 31 2018 01:20
@coderkarma Completely depends on what kind of application you'll be building and how much you're able to do by head and have to research first.
Erm, I think so far in total I've spend about 30 hours on this chatsystem @coderkarma
Did a quick check and within that time I've written about 1900 lines of code, lol
Kyle Holm
@thekholm80
Jul 31 2018 01:25
oh wow, 63 lines of code per hour
you're going to set your keyboard on fire
Bjorn van de Peut
@bjorno43
Jul 31 2018 01:25
Ghehe :P
Problem is, you spend a lot of time thinking about problems and how you're going to solve them before you actually solve them :P
Kyle Holm
@thekholm80
Jul 31 2018 01:27
i don't have that problem, maybe it's because i use JS?
Bjorn van de Peut
@bjorno43
Jul 31 2018 01:28
Or maybe it's because you're not working on such complicated systems? :P
Kyle Holm
@thekholm80
Jul 31 2018 01:28
nothing's complicated in JS
korzo
@korzo
Jul 31 2018 01:28
80–90% of a developer’s day is spent Googling how to do things. -- Isaac Newton
Kyle Holm
@thekholm80
Jul 31 2018 01:28
75% of quotes and statistics are made up on the spot. -- Benjamin Franklin
Bjorn van de Peut
@bjorno43
Jul 31 2018 01:30
Alright. I'll give you 30 hours @thekholm80 Go ahead, make a chatsystem in JS that supports multiple rooms and IM. And make it yourself! Don't just download one :P
Kyle Holm
@thekholm80
Jul 31 2018 01:30
and if i win?
Bjorn van de Peut
@bjorno43
Jul 31 2018 01:31
Then I'll admit that JS isn't complicated
Kyle Holm
@thekholm80
Jul 31 2018 01:31
pfft
not worth 30 hours of my time for that
Bjorn van de Peut
@bjorno43
Jul 31 2018 01:32
Not much else I can offer xD Even a starbucks giftcard from the EU doesn't work in the US, lol
Kyle Holm
@thekholm80
Jul 31 2018 01:32
lol
Bjorn van de Peut
@bjorno43
Jul 31 2018 01:34
Ye I had that happen to me. Some US university guys were facing a problem they couldn't fix. So I helped them out and they mailed me a Starbucks giftcard. So I go Starbucks and they're like: Ye sorry, US giftcards don't work in EU or visa versa xD
Kyle Holm
@thekholm80
Jul 31 2018 01:34
i never would have even guessed that's possible
Bjorn van de Peut
@bjorno43
Jul 31 2018 01:36
I just gave it away to someone from the US
Kyle Holm
@thekholm80
Jul 31 2018 01:42
i really dislike building front ends
korzo
@korzo
Jul 31 2018 01:47
@thekholm80 Same. It's such a waste of time.
Kyle Holm
@thekholm80
Jul 31 2018 02:01
i do have to say, though, once i learned to do my styling in the browser instead of changing the file, saving, refreshing the browser, etc it got somewhat better
Fikry82
@Fikry82
Jul 31 2018 02:47
i have problem with that test
its a bug or what
Add an hr tag underneath the h4 which contains the card title.
keep saying (The hr tag should come between the title and the paragraph.) ??
every thing looks okay but i have that error
Kyle Holm
@thekholm80
Jul 31 2018 02:50
@Fikry82 in freeCodeCamp/freeCodeCamp#17944 they suggest
Try to switch you <p><em> tag like this..
i'm guessing there's a problem with the test, hopefully they'll get it fixed
Fikry82
@Fikry82
Jul 31 2018 02:52
@thekholm80 thx it works ;)
Karma Drukpa
@coderkarma
Jul 31 2018 02:59
@thekholm80
I know you have shorter solution for this
i Tried to do short one comparing each element but couldn't get it right
could you please have a look
function letterCount(str){
// declare the emtpy object
   let count = {};
    //loop through the str, make char all lower or uppercase
    for (let i = 0; i < str.length; i += 1){
       let char = str[i].toLowerCase();
    // check to see if the value is in the object or not , therefor it will be undefine
     if (count[char] === undefined){
    // if it is then  initilize to 1
        count[char] = 1;
    // if not then increment 
        }  else {
         count[char] += 1;
        }
    }
    // return the count of char
    return count;
  } 

    // call the main isogram function 
    function isIsogram(str){
    // call the helper funtion 
     let count = letterCount(str);
    // loop through the object
     for (let letter in count){
    // check if charcount is more then 1 
      if ( count[letter] > 1){
    // if it is more then 1 return false;
       return false;
    // esle return true
        }
      }
      return true;
    }
that is longer one
but let me sent you other one
but i didn't get it right
Karma Drukpa
@coderkarma
Jul 31 2018 03:05
function isIsogram(str){
     for (let i = 0; i < str.length; i += 1){
         let char = str[i].toLowerCase();

         if(str[i] === str[i + 1] || str[i] === str[i -1]){
             return false;
         }
     }
     return true;
 }
Kyle Holm
@thekholm80
Jul 31 2018 03:05
k, got it
const isIsogram = str => str.split('').reduce((a, b) => str.match(RegExp(`[${b}]`, 'gi')).length > 1 ? false : a, true);
Karma Drukpa
@coderkarma
Jul 31 2018 03:06
wht
nice
regular expression was so helpful there
plus reduce
Kyle Holm
@thekholm80
Jul 31 2018 03:07
i'm sure there's a better way without splitting the string into an array, but i always think arrays
Karma Drukpa
@coderkarma
Jul 31 2018 03:07
arrays are mutable but string are not right?
Kyle Holm
@thekholm80
Jul 31 2018 03:07
lol
function isIsogram(str){ 
  return !/(\w).*\1/i.test(str)
}
way better than mine
Karma Drukpa
@coderkarma
Jul 31 2018 03:08
no idea about that
Kyle Holm
@thekholm80
Jul 31 2018 03:08
just regex
Karma Drukpa
@coderkarma
Jul 31 2018 03:08
there is to many slashes
ok
Manish Giri
@Manish-Giri
Jul 31 2018 03:09
regex all about slashes
Karma Drukpa
@coderkarma
Jul 31 2018 03:09
@Manish-Giri teach me those explicitly
also what is wrong with my second approach I was thinking , that approach should work as wel @Manish-Giri @thekholm80
Manish Giri
@Manish-Giri
Jul 31 2018 03:12
for (let i = 0; i < str.length; i += 1){ - with this loop, when you reach str[i], what would str[i+1] be?
Karma Drukpa
@coderkarma
Jul 31 2018 03:13
undefined
oh!!!
Manish Giri
@Manish-Giri
Jul 31 2018 03:14
:thumbsup:
Karma Drukpa
@coderkarma
Jul 31 2018 03:14
so what would be best way of comparing each element then
char
Manish Giri
@Manish-Giri
Jul 31 2018 03:20
I would use a Set
get rid of the loops altogether
Kyle Holm
@thekholm80
Jul 31 2018 03:21
set would be good, but it has to be case insensitive
Manish Giri
@Manish-Giri
Jul 31 2018 03:21
.toLowerCase()
Kyle Holm
@thekholm80
Jul 31 2018 03:21
without a loop?
oh, duh never mind lol
Manish Giri
@Manish-Giri
Jul 31 2018 03:23
public static boolean  isIsogram(String str) {
        return str.length() == 0 ? true : str.length() == new HashSet<>(Arrays.asList(str.toLowerCase().split(""))).size();
    }
this was my soln
Karma Drukpa
@coderkarma
Jul 31 2018 03:23
wow
Manish Giri
@Manish-Giri
Jul 31 2018 03:24
ignore the static, boolean, etc
Kyle Holm
@thekholm80
Jul 31 2018 03:24
so you could just do return new Set(string.split('')).size == string.length;
Manish Giri
@Manish-Giri
Jul 31 2018 03:25
you'll need to take care of case
o and O will be counted 2 otherwise
Kyle Holm
@thekholm80
Jul 31 2018 03:25
oops new Set(string.toLowerCase().split('')).size == string.length;
Manish Giri
@Manish-Giri
Jul 31 2018 03:25
:thumbsup:
Karma Drukpa
@coderkarma
Jul 31 2018 03:26
new HashSet<> ?
Kyle Holm
@thekholm80
Jul 31 2018 03:26
it's java
Manish Giri
@Manish-Giri
Jul 31 2018 03:26
:point_up:
Kyle Holm
@thekholm80
Jul 31 2018 03:26
don't pollute your mind with that garbage
Claudio Restifo
@Marmiz
Jul 31 2018 03:26
My imperative solution :smile:
function isIsogram(str){
  if(str.length === 0) return true;

  const arr = str.split('').map(x => x.toLowerCase());
  const unique = [...new Set(arr)];

  return unique.length === arr.length

}
Manish Giri
@Manish-Giri
Jul 31 2018 03:26
:unamused:
Claudio Restifo
@Marmiz
Jul 31 2018 03:27
wanted to make an even more imperative one with a while loop, but was too boring :smirk:
Kyle Holm
@thekholm80
Jul 31 2018 03:27
lol
Karma Drukpa
@coderkarma
Jul 31 2018 03:28
my solution looks so terrible and super long
Claudio Restifo
@Marmiz
Jul 31 2018 03:28
a super high ops solution with a while that stop as soon as a letter is not unique, C style... but meh
Karma Drukpa
@coderkarma
Jul 31 2018 03:28
why I can't solve like you folks damit.
Kyle Holm
@thekholm80
Jul 31 2018 03:28
we've been doing this for a long time
Manish Giri
@Manish-Giri
Jul 31 2018 03:29
I haven't
I just copy - paste kyle's solutions
Claudio Restifo
@Marmiz
Jul 31 2018 03:29
people who tough about regex are secretly killer. They should be incarcerated
Manish Giri
@Manish-Giri
Jul 31 2018 03:29
ez pz
Kyle Holm
@thekholm80
Jul 31 2018 03:29
that explains why your code is crap @Manish-Giri
Claudio Restifo
@Marmiz
Jul 31 2018 03:29
I copied @Manish-Giri. ezer pzier
Kyle Holm
@thekholm80
Jul 31 2018 03:29
you should copy @Marmiz instead
Manish Giri
@Manish-Giri
Jul 31 2018 03:30
lol
Karma Drukpa
@coderkarma
Jul 31 2018 03:30
oh boy!!!!
Manish Giri
@Manish-Giri
Jul 31 2018 03:31
 Testing for [[-7, -736, 61, -74, -37, -22, 877, 32, -94, -1, 69, 799, 560, 10, -64, -372, 410, 437, -56, 737, -878, 5, 94, -1, -23, 173, -85, 33, -98, -8, -189, 508], [-2, 82, -9, -73, -588, -457, 27, 641, -803, 985, -2, 3, -79, -721, 4, 424, -400, 313, -1, -27, 191, 5, 72, 12, 483, 91, 5], [773, -343, -10, 204, -1, 790, 13, 359, -73, -87, 369, 456], [-48, 972, -94, 252], [-1, 5, -2, 1, 333, -59, 6, -816, 53, -6, 409, -823, -99, -1, 671, -54, 64, -44, -635, -95, -40, -650, -78, -181, -5, -69, 51, 57, -95, -111, -10, 42, -349, 0, -64], [-919, -70, 10, 2, -2, -23, 31, 70], [392, -2, 71, 626, -3, 25, 6, 48], [426, -462, -102, 40, -200, -7, -5, -480, 8, 82, -377, 42, -763, 8, 271, -99, 719, 107, 95, 1, -137, 0, 50, 446, 3, 234, -1, -279, 572, -5, 9, -350, 791, -9, -850, 428, -59], [0, 1, -1, 8, 11, -21, -7, 77, 7, 13, 16, 9, 135, -1, 806, 89, 254, 48, 230, 3, 834, 285, -132, 356, -387, 444, 643, -2, 613, -595, 2, 1, -709, -781], [-603, 0, 96, -12, 0, 5, -467, -318, -5], [7, -52, 20, 683, 43, -42], [0, -794, -48, -65, 5, 6, 6, -3, -891, 23, -568, 335, -79, 0, 608, 22, 93, 393, -10], [641, 1, 589, 482, -923, 208, -963, -1, -470, -88, 6, 0, 1, -887, -83, 362, -4, 5, 39, 1, 217, -53, 9, -5, 33, 9, 818, -372, -868, 55, 310, -1, -346, -979, 899, 0], [-268, 0, -56, 367, -10, 45, -7, -879, -804, 8, -271, -47, -316, -21, -648, 329, 652, -25, 7, -9, 365, 129, 13, 695, -136, 94, -188, -44, -288, -669, -283, 2, -771, 4, 66, 190, 39, 213, -880], [135, 1, -821, -4, -31, 79, 94, -1, 5, 34, 705, -811, 152, 107, 727, -61, -774, 846, -857, -767, 787, -9, 0, -5, 668, 818], [-1, 31, -1, 888, -561, -787], [-18, 74, -4, 2, 3, -2, 7], [-17, 746, 87, 8, -6, -1, -9, -53, 9, 51, 742, -89, -993, -352, -16, 1, 87, -23, -44, 58, -407, 571, 222], [-561, 9, 6, 1, 5, -34, 0, 5, 584, -94, -1, 24, -828, -754, 51, 965, 50, -9, 3, -868, 36, 0, 1, -42, -5, 513], [-1, 619, -845, 638, -208, 58, 945, 365, 62, -516, 976, -10, 417, 19, -7], [315, 1, -58, -727, 311, -86, 26, -1, -863, 381, -855, 29, 288, 0, 1, 357, -70, 590, -9, 93], [1, 489, -34, 101, -3, 223, 377, -102, 3, 7, -643, -175, -534, 425, 1, -708, 1, -1, -70, 523, -5, 277, -18, -623, 1, 378, 48, 866, 63, 3, -15, -55, 0, 1], [-258, 27, -2, -922, 12, 773, 77, 38, 103, 171, 81, -8, -890, -544, -1, -138, 60, 4, -809, -58, -86, -31, -69, 6, -238], [82], [-53, -399, 72, 753, -129, -604, -669, -32, -79, 147], [-901, -17, -215, -85, 424, 9], [53, 784, -3, 4, 497, 319, 808, -695, 10, 351, -493, 0, -287, -2, -14, 1, 498, -4, 2, -8, 939, 443, 28, -5, -41, 22, -10, -559, 47, -10], [45, 759, 13, 0, -1, 2, 800, 1, -1, 254, -143, 10, 788, -5, 306, -1, -4, -2, 488, -25], [7, -1, 239, 33, -716, 87, 1, 6, -8, -3, -712, 848, -13, -3, 2, 29, 2, 0, -6, 77, 71, 265, -607, 386, 269, -80, -5, -597, -100, -67, -10, -79, 507, 531, 12], [76, 979, -634, -203, 44, -6, 251, 29, -1, -48, -29, -891, 51, -61, -17, 10, -669, 88, -46, -3, -17, 61, -98, 78, 10, -546, 4], [-8, 84, -575, -764, 4, -690, 21, 0, 69, -664, 0, -46, 80, -8, 4, 676, -59, 1, -3, 0, -4, -1, -346, -56, -6, 860, 393, 1, 459, -224, 3, -2, 71, 37, -454], [515, -98, 60, 25, 5, -99, 1, -60, -41, 260, -715, -2, 970, -8, -7, 0, 1, -8, -3, -1, -603, -56, 57, -76], [-1, 0], [-10, -39, -258, 0, 3, 35, -926, -59, 4, -2, 0], [5, -616, -828, 83, 0], [211, 367, 693, -749, 43, -525, -461, 516, -72, 301, -95, -1, 57, -24, -2], [-94, 622, -123, -10, 0, 848, 0, 94, 43, 425, 67, 6, -3, 605, 908, -7, 93, 126, -95, 55, -54, 6, 822, -665, 55], [441, -28, -9, -3, 7], [-16]] and 1
i need to go thru that array & figure out why the code won't work
Claudio Restifo
@Marmiz
Jul 31 2018 03:32
@coderkarma anyway don't be fooled. Sometimes a "shorter" code doesn't means a faster / more efficient solution
mine for example is kinda crappy
Kyle Holm
@thekholm80
Jul 31 2018 03:33
i write golf code for codewars, i would never use it in one of my projects
Manish Giri
@Manish-Giri
Jul 31 2018 03:33
not to mention one line solutions probably won't be accepted in interviews
:boot:
Claudio Restifo
@Marmiz
Jul 31 2018 03:33
@Manish-Giri git blame @thekholm80
ez
Manish Giri
@Manish-Giri
Jul 31 2018 03:33
pz
if anyone is interested
Karma Drukpa
@coderkarma
Jul 31 2018 03:34
Thank you folks for helping me out
@Manish-Giri i got the answer for that
lol ...... jk
Manish Giri
@Manish-Giri
Jul 31 2018 03:34
@coderkarma :thumbsup:
Kyle Holm
@thekholm80
Jul 31 2018 03:34
and so the student becomes the master
Karma Drukpa
@coderkarma
Jul 31 2018 03:34
no no
no noo\
@thekholm80 no no no no nonono
Claudio Restifo
@Marmiz
Jul 31 2018 03:36
@Manish-Giri can we solve it in a ML language so it won't even complie because the type is so dumb you should be ashamed of yourself?
Manish Giri
@Manish-Giri
Jul 31 2018 03:36
rofl
Claudio Restifo
@Marmiz
Jul 31 2018 03:36
like a type CustomList = List(List(List(List)
@Manish-Giri what exactly is the second param d in your kata?
Karma Drukpa
@coderkarma
Jul 31 2018 03:40
@Manish-Giri so we need to find sum of frist nested 3rd element, second element of second arr and 1 st element of 3rd arr
?
we need 2 for loops for sure I will try to do this problems thanks
Manish Giri
@Manish-Giri
Jul 31 2018 03:41
@Marmiz its a default parameter to be used, in case the element at the specific array index doesn't exist
Claudio Restifo
@Marmiz
Jul 31 2018 03:41
@Manish-Giri I thought it would be 0
Manish Giri
@Manish-Giri
Jul 31 2018 03:42
it is 0 if d is not supplied
Claudio Restifo
@Marmiz
Jul 31 2018 03:42
oh ok, re read it and make more sense :)
Manish Giri
@Manish-Giri
Jul 31 2018 03:42
my solution is arr.map(...).reduce(...) and it fails about 4 random cases
Time: 627ms Passed: 40 Failed: 5 Exit Code: 1
Kyle Holm
@thekholm80
Jul 31 2018 03:45
wait, isn't a non-zero exit code an error?
Manish Giri
@Manish-Giri
Jul 31 2018 03:47
it is
but somehow the error in case of this kata just states that random cases are failing
not the actual error
Kyle Holm
@thekholm80
Jul 31 2018 03:48
oh
Manish Giri
@Manish-Giri
Jul 31 2018 03:48
Unhandled rejection TestError: It should work for random inputs too - Expected: -379, instead got: -369
Kyle Holm
@thekholm80
Jul 31 2018 03:48
did you try adding 2?
err -2
err -10
Manish Giri
@Manish-Giri
Jul 31 2018 03:48
lol
Kyle Holm
@thekholm80
Jul 31 2018 03:48
damn i suck at math
Manish Giri
@Manish-Giri
Jul 31 2018 03:48
me too
Karma Drukpa
@coderkarma
Jul 31 2018 03:48
lol
Manish Giri
@Manish-Giri
Jul 31 2018 03:49
unless you go through each array in that list
and figure it out
Karma Drukpa
@coderkarma
Jul 31 2018 03:50
oh my god !! that's a lot of arrays
Manish Giri
@Manish-Giri
Jul 31 2018 03:51
thats the problem with random tests in codewars
no easy way to debug
Manish Giri
@Manish-Giri
Jul 31 2018 03:57
It should work for random inputs too - Expected: 479, instead got: 478
Kyle Holm
@thekholm80
Jul 31 2018 03:57
that kind of crap really bugs me
Manish Giri
@Manish-Giri
Jul 31 2018 03:57
its really annoying
Manish Giri
@Manish-Giri
Jul 31 2018 04:01
true story lol
Alexander R Bott
@Abott1222
Jul 31 2018 04:07
@thekholm80 this is great lol
Claudio Restifo
@Marmiz
Jul 31 2018 04:07

@Manish-Giri I have the dumb, but why on earth:

  Test.assertEquals(elementsSum([[3, 2, 1, 0], [4, 6, 5, 3, 2], []]), 7);

is 7?

3rd == [] --> def 0;
2nd == [4,6,5 ...] --> 6 (position 2)
1st == [3,2,1 ...] --> 3 (position 1)
Manish Giri
@Manish-Giri
Jul 31 2018 04:09
from 1st array, 1, from 2nd array, 6, and 0 from last
@Marmiz
in 0th array, you pick the 3rd element, coz length of outer array is 3
and so on
Claudio Restifo
@Marmiz
Jul 31 2018 04:10

: you should consider the third element of the first sub-array

ooooooohhhh. I should start actually reading the instructions

Manish Giri
@Manish-Giri
Jul 31 2018 04:10
lol
Bjorn van de Peut
@bjorno43
Jul 31 2018 04:11
One small note if that not always each sub-array will have enough elements, in which case you should then use a default value if provided or 0 if not provided, as shown in the test cases. So I guess you need to use 7 as it's provided and not 0?
Manish Giri
@Manish-Giri
Jul 31 2018 04:11
7 is the expected result
not the provided value
Bjorn van de Peut
@bjorno43
Jul 31 2018 04:11
Ah right
Claudio Restifo
@Marmiz
Jul 31 2018 04:12

how you guys actually do this. I found them so... random.

I know why... but WHY? (in a general sense)
lemme build a videogame in less than 64k instead of finding some random number in a random collection of randomness that you'll never find in real life

Manish Giri
@Manish-Giri
Jul 31 2018 04:12
lol
Kyle Holm
@thekholm80
Jul 31 2018 04:12
oh look at mr fancy actually has fun stuff to work on so he doesn't have to do codewars
Manish Giri
@Manish-Giri
Jul 31 2018 04:13
all you need to do is find the pattern
Kyle Holm
@thekholm80
Jul 31 2018 04:13
i think i've found something i don't like about the context api
Manish Giri
@Manish-Giri
Jul 31 2018 04:14
You mean apart from it being ugly
Kyle Holm
@thekholm80
Jul 31 2018 04:14
ooooh @Marmiz will know
what's an elegant way of having more than one context?

for example, if i add more providers to

const Main = () => (
  <NavProvider>
    <App />
  </NavProvider>
);

i assume i'd just keep wrapping that poor component. surely there's a better way?

or is it better to just use a single provider/context?
Christopher McCormack
@cmccormack
Jul 31 2018 04:17
@thekholm80 why not just wrap the component that needs it?
Claudio Restifo
@Marmiz
Jul 31 2018 04:18

@thekholm80

what's an elegant way of having more than one context?

lol. elegant.
the average app has:

<context>
  <store> 
    <route>
       <a11y>
         <theme>
             <add flour and eggs to the mix>
                 <bake in oven>

                     maybe <app>

and that's how I like it

alpox
@alpox
Jul 31 2018 04:18
@thekholm80 put boxes in boxes in boxes in boxes in boxes.....
Christopher McCormack
@cmccormack
Jul 31 2018 04:18
I mean, if you put that in it's own file and never look at it again, maybe not so bad :D
Claudio Restifo
@Marmiz
Jul 31 2018 04:19
^ every index.js in a React app ever
Kyle Holm
@thekholm80
Jul 31 2018 04:19
that doesn't mean i have to like it lol
Christopher McCormack
@cmccormack
Jul 31 2018 04:20
yeah index is where I put my ugly code by default, importing stylesheets and favicons and junk
Kyle Holm
@thekholm80
Jul 31 2018 04:20
maybe i'll make one HOC for all my providers
or just use a single provider
Christopher McCormack
@cmccormack
Jul 31 2018 04:21
I've yet to see a best practices article for Context API but sure would like to see one
especially for a large app, which I doubt many have done
Claudio Restifo
@Marmiz
Jul 31 2018 04:21
@thekholm80 depends how many level "up" you actually need the context.
In many places I wrap provider and consumer pretty much at the same level in order to pass them on condition
(my usercase an editable row in a table)
Kyle Holm
@thekholm80
Jul 31 2018 04:22
i thought about that ... chase the tree to the lowest point i would need any given context and add it in there
Claudio Restifo
@Marmiz
Jul 31 2018 04:23
like
<Table />

const EditbaleRow = (v) =>   <EditableContext.Provider value={v}>
    <tr {...props} />
  </EditableContext.Provider>

const EditableCell = () => { editable ? <Consumer> ... </Consumer>
:fire: formatting on gitter
Christopher McCormack
@cmccormack
Jul 31 2018 04:24
where is props coming from?
alpox
@alpox
Jul 31 2018 04:24
@thekholm80 you can programmatically nest those providers and build a new one like this if you are uncomfortable with the look :D
Just .reduce them
Christopher McCormack
@cmccormack
Jul 31 2018 04:25
or compose!
alpox
@alpox
Jul 31 2018 04:26
@cmccormack is there a prebuilt vompose function for components? :D
compose*
Christopher McCormack
@cmccormack
Jul 31 2018 04:26
There's gotta be
functional programmers love React
Kyle Holm
@thekholm80
Jul 31 2018 04:26
i think react api has a compose
Claudio Restifo
@Marmiz
Jul 31 2018 04:27
@alpox voilla:
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
i think this is where i was reading it
Claudio Restifo
@Marmiz
Jul 31 2018 04:29
@cmccormack cut off during paste. The actual EditableRow = ({v, ...props}) => [...]
alpox
@alpox
Jul 31 2018 04:29
@Marmiz thats function composition. Not component :)
Christopher McCormack
@cmccormack
Jul 31 2018 04:31
@Marmiz humor me - you pass a value to EditableRow which is updating state that then effects whatever's a child of the Consumer?
alpox
@alpox
Jul 31 2018 04:31
@thekholm80 right, higher order components can be composed to an enhancer because they are all factory functions
But that doesnt work for normal components. I guess you are better off with that react-compose shown by @cmccormack
Kyle Holm
@thekholm80
Jul 31 2018 04:32
i'll just suck it up and have ugly code
no extra dependencies
Christopher McCormack
@cmccormack
Jul 31 2018 04:33
Or just cram all of your state and methods into one giant awesome context!
Kyle Holm
@thekholm80
Jul 31 2018 04:33
i just threw up a little in my mouth
Christopher McCormack
@cmccormack
Jul 31 2018 04:33
it's not so bad
Claudio Restifo
@Marmiz
Jul 31 2018 04:33
recompose is pretty popular tool as well
Christopher McCormack
@cmccormack
Jul 31 2018 04:33
less mental fatigue trying to find a method
Bjorn van de Peut
@bjorno43
Jul 31 2018 04:33
@Manish-Giri Solved that challenge:
function elementsSum(arr,d = 0){
  let nrArrays = arr.length;
  let result = 0;

  nrArrays--;

  for(let i=0; i < arr.length; i++){
    if(nrArrays in arr[i]){
      result += arr[i][nrArrays];
    } else {
      result += d;
    }

    nrArrays--;
  }

  return result;
}
Claudio Restifo
@Marmiz
Jul 31 2018 04:33
@alpox read it wrong there :)
alpox
@alpox
Jul 31 2018 04:34
@Marmiz recompose ends up in all of my react apps :D
Christopher McCormack
@cmccormack
Jul 31 2018 04:34
@bjorno43 needs more map
Kyle Holm
@thekholm80
Jul 31 2018 04:34
@Marmiz cool, i'll check that out tomorrow. it's bed time for me
Bjorn van de Peut
@bjorno43
Jul 31 2018 04:34
@cmccormack Screw that. It works :laughing:
Claudio Restifo
@Marmiz
Jul 31 2018 04:35
@alpox same, that's why I suggested a function compose, cos in the end I have so many functions that render enhanced component that was always fine for me.
Like redux compose or apollo compose does
Christopher McCormack
@cmccormack
Jul 31 2018 04:35
you can rid yourself of that -- by just using length - 1 :)
Bjorn van de Peut
@bjorno43
Jul 31 2018 04:35
Ye I know, lol
Christopher McCormack
@cmccormack
Jul 31 2018 04:35
haha
Manish Giri
@Manish-Giri
Jul 31 2018 04:36
@bjorno43 this was mine
function elementsSum(arr,d=0){
  return arr.map((e,i) => e[arr.length-i-1] || d).reduce((a,b)=>a+b);
}
not sure what's wrong
alpox
@alpox
Jul 31 2018 04:36
@Marmiz exactly. Composing those higher order components is awesome anyways :D
Christopher McCormack
@cmccormack
Jul 31 2018 04:37
@Manish-Giri which problem?
Christopher McCormack
@cmccormack
Jul 31 2018 04:38
thanks
Manish Giri
@Manish-Giri
Jul 31 2018 04:38
:thumbsup:
ADUYE TUESDAY
@AduyeTuesday_twitter
Jul 31 2018 05:22
i am a little bit confuse here because this is my first time in doing token transfer. i got a token i want to transfer but i got no ethereum on my wallet to pay gas fee, so i am looking at sending the token to the receiver so as for the receiver to pay the gas fee and the second option is to use the Approve and transferfrom. How can i go about this please i need.
I got a program that can be used with the second option at ethfiddle.com but i don't know where to start. here is the link of the programe: https://github.com/bitfwdcommunity/Issue-your-own-ERC20-token/blob/master/contracts/erc20_tutorial.sol
Christopher McCormack
@cmccormack
Jul 31 2018 05:29
@Manish-Giri it's hideous but it passes:
const elementsSum = (arr,d=0) =>
  arr.reduce((a, v, i) => a + (v[arr.length - i - 1] === 0 ? 0 : (v[arr.length - i - 1] || d)), 0)
the 0 being falsy was killing me though
ADUYE TUESDAY
@AduyeTuesday_twitter
Jul 31 2018 05:30
@cmccormack can you help?
Bjorn van de Peut
@bjorno43
Jul 31 2018 05:31
ethereum.. paying a gas fee.. 0 f*cks given in source code of url.. My :hammer: is tingling here..
Christopher McCormack
@cmccormack
Jul 31 2018 05:33
I have no idea what any of that is
Bjorn van de Peut
@bjorno43
Jul 31 2018 05:33
It's a very weird question that's for sure
ADUYE TUESDAY
@AduyeTuesday_twitter
Jul 31 2018 05:33
i just want to use that example of code to suit mine
or using a thired party account for handling th gas fee
It's right in the README for that project
Bjorn van de Peut
@bjorno43
Jul 31 2018 05:37
Honestly, as much as we try to help everyone here, I believe questions about crypto currency and how to implement it is very, very off-topic for FCC
Christopher McCormack
@cmccormack
Jul 31 2018 05:37
I would agree, the questions should be at least tangential to the curriculum
Bjorn van de Peut
@bjorno43
Jul 31 2018 05:42
Yup. I'm working on that chatsystem. If I come across a problem I can't solve, I move to SO. It doesn't come anywhere near FCC's curriculum
But ye. On SO you can't ask questions like "How do I do this?". You actually need to know what you're talking about and have most of the code functional
Christopher McCormack
@cmccormack
Jul 31 2018 05:46
I've never had a programming emergency that I can recall, that's for sure
welp I finished my work for tonight, I'm off - have a good night!
Bjorn van de Peut
@bjorno43
Jul 31 2018 05:46
Ghehe gn8 @cmccormack
Karma Drukpa
@coderkarma
Jul 31 2018 05:59
goodnight guys
Nicegirls
@Nicegirls
Jul 31 2018 06:36
it's difficult to solve it!!!!
Claudio Restifo
@Marmiz
Jul 31 2018 07:46
what exactly is difficult to solve?
Alexander R Bott
@Abott1222
Jul 31 2018 07:46
anything NP
May Kittens Devour Your Soul
@diomed
Jul 31 2018 10:02
                   ;,_            ,
                  _uP~"b          d"u,
                 dP'   "b       ,d"  "o
                d"    , `b     d"'    "b
               l] [    " `l,  d"       lb
               Ol ?     "  "b`"=uoqo,_  "l
             ,dBb "b        "b,    `"~~TObup,_
           ,d" (db.`"         ""     "tbc,_ `~"Yuu,_
         .d" l`T'  '=                      ~     `""Yu,
       ,dO` gP,                           `u,   b,_  "b7
      d?' ,d" l,                           `"b,_ `~b  "1
    ,8i' dl   `l                 ,ggQOV",dbgq,._"  `l  lb
   .df' (O,    "             ,ggQY"~  , @@@@@d"bd~  `b "1
  .df'   `"           -=@QgpOY""     (b  @@@@P db    `Lp"b,
 .d(                  _               "ko "=d_,Q`  ,_  "  "b,
 Ql         .         `"qo,._          "tQo,_`""bo ;tb,    `"b,
(qQ         |L           ~"QQQgggc,_.,dObc,opooO  `"~~";.   __,7,
`qp         t\io,_           `~"TOOggQV""""        _,dg,_ =PIQHib.
 `qp        `Q["tQQQo,_                          ,pl{QOP"'   7AFR`
   `         `tb  '""tQQQg,_             p" "b   `       .;-.`Vl'
              "Yb      `"tQOOo,__    _,edb    ` .__   /`/'|  |b;=;.__
                            `"tQQQOOOOP""        `"\QV;qQObob"`-._`\_~~-._
                                 """"    ._        /   | |oP"\_   ~\ ~\_  ~\
                                         `~"\ic,qggddOOP"|  |  ~\   `\  ~-._
                                           ,qP`"""|"   | `\ `;   `\   `\
                                _        _,p"     |    |   `\`;    |    |
                                 "boo,._dP"       `\_  `\    `\|   `\   ;
                                  `"7tY~'            `\  `\    `|_   |
                                                           `~\  |
John
@taloloy18
Jul 31 2018 10:04
Is that a mouse? XD
May Kittens Devour Your Soul
@diomed
Jul 31 2018 10:07
how dare you :smirk_cat:
John
@taloloy18
Jul 31 2018 10:18
hahaha..
Smootimus
@Smootimus
Jul 31 2018 14:17
KITTY
Kyle Holm
@thekholm80
Jul 31 2018 14:18
@Smootimus good job!
Smootimus
@Smootimus
Jul 31 2018 14:18
Thanks :D
Still waiting for this LinkedIn thing to open up :eyes:
Kyle Holm
@thekholm80
Jul 31 2018 14:19
i don't think i'm gonna do it
Smootimus
@Smootimus
Jul 31 2018 14:20
I'll shoot an app over their way and see if they respond or something
Kyle Holm
@thekholm80
Jul 31 2018 14:20
you should
i hope you get it
Smootimus
@Smootimus
Jul 31 2018 14:21
But my schooling takes 100% precedence
So, if it would conflict in any way, shape or form then I'll have to let someone else take the opportunity
Bjorn van de Peut
@bjorno43
Jul 31 2018 14:38
Well that was certainly interesting
Fetching rows from the database on page scroll in reverse :P
Kyle Holm
@thekholm80
Jul 31 2018 14:39
pfft just have the client pull down the entire chat history when the page loads
Bjorn van de Peut
@bjorno43
Jul 31 2018 14:39
:joy:
Honestly, kudos for inmediately understanding what I was talking about! @thekholm80 :thumbsup:
Kyle Holm
@thekholm80
Jul 31 2018 14:40
i've made a chat room before lol
was part of a game i never finished
something @diomed was begging for
oh, tell me @bjorno43 why chrome is ignoring cookies served over http?
Bjorn van de Peut
@bjorno43
Jul 31 2018 14:42
I hardly ever work with Chrome. Might be just a setting. But I do know that my website refuses to set a cookie if https is unavailble. But that's because I coded it that way
May Kittens Devour Your Soul
@diomed
Jul 31 2018 14:43
yes, when shall Cards Against Developers be done already?
you'll never get 3 fidy like that, Kyle
Kyle Holm
@thekholm80
Jul 31 2018 14:44
i lost all the cards when i re-imaged my laptop
so it will never be done
May Kittens Devour Your Soul
@diomed
Jul 31 2018 14:44
all lies
coz - there is online repo on github with them
Kyle Holm
@thekholm80
Jul 31 2018 14:45
i never could have launched it anyway, i don't want to pay to host it
Bjorn van de Peut
@bjorno43
Jul 31 2018 14:46
And here I am with 2 dedicated and 1 local server at my disposal not know what the hell I'm gonna do with them..
Kyle Holm
@thekholm80
Jul 31 2018 14:47
pr0n
May Kittens Devour Your Soul
@diomed
Jul 31 2018 14:47
see? see? it's like match made in heaven!
Kyle Holm
@thekholm80
Jul 31 2018 14:47
it's the only solution
Bjorn van de Peut
@bjorno43
Jul 31 2018 14:47
Ye.. definitely pr0n
May Kittens Devour Your Soul
@diomed
Jul 31 2018 14:47
yeah, I mean, I tried to get piece of that hosting, but nooo
still waiting
I mean where shall I host my pr0n?
Bjorn van de Peut
@bjorno43
Jul 31 2018 14:49
Nah. Gonna troll my visiters. Have website 1 redirect to website 2. Wait 1 second and forward to website 3. Wait 1 second and back to website 1. Avoid the browser "too many redirects" and sit back :joy:
Kyle Holm
@thekholm80
Jul 31 2018 14:49
that sounds fun
May Kittens Devour Your Soul
@diomed
Jul 31 2018 14:50
I'd just have all websites redirect to chinese FreeCodeCamp
Kyle Holm
@thekholm80
Jul 31 2018 14:52
i found my new ui design
Bjorn van de Peut
@bjorno43
Jul 31 2018 14:52
lol. That reminds me of highschool. Where they had a local proxy to control which websites could be visited. Untill one day a certain Bjorn saw that the network manager left the room with that proxy server open.. :innocent:
May Kittens Devour Your Soul
@diomed
Jul 31 2018 14:54
I miss that scrolling text every day
@thekholm80 pffft. this the best website
Bjorn van de Peut
@bjorno43
Jul 31 2018 14:57
@diomed The horse following the mouse just killed it for me :joy:
Smootimus
@Smootimus
Jul 31 2018 15:00
Trying to teach this kid in my class Arrays :eyes:
lol
C++ arrays, and Javascript arrays. Tried to explain it's gonna cause him to trip up a bit
Kyle Holm
@thekholm80
Jul 31 2018 15:01
@diomed i started watching that on netflix - think i'm about done with the first season
i still think vincent adultman is the best part, but there's other good stuff too
i think the simpsons creator has a new show coming to netflix in august
Bjorn van de Peut
@bjorno43
Jul 31 2018 15:07
I'm waiting for Lucifer to continue. Saved by Netflix ^^
May Kittens Devour Your Soul
@diomed
Jul 31 2018 15:08
@thekholm80 I actually published a theme and I put vincent's page as placeholder :yum:
that's a grown up man, if I ever saw one
Bjorn van de Peut
@bjorno43
Jul 31 2018 15:09
I mean seriously, Fox dropped Lucifer while it was still averaging 2 / 3 million viewers each episode release, lol
May Kittens Devour Your Soul
@diomed
Jul 31 2018 15:10
FOX dropped Satan himself . Classic FOX.
Even Satan isn't safe from those Network Executives
Kyle Holm
@thekholm80
Jul 31 2018 15:12
and they picked up that Last Man Standing that got cancelled on another network
stupid fox
but - they have The Orville so it's not all bad
May Kittens Devour Your Soul
@diomed
Jul 31 2018 15:12
Tim Allen is national treasure
Ene Catalin
@EneCatalin
Jul 31 2018 15:12
tbh with the way that show was going they did it a mercy and put it out of its misery
May Kittens Devour Your Soul
@diomed
Jul 31 2018 15:17
hue hue hue
Smootimus
@Smootimus
Jul 31 2018 16:10
hyuck hyuck hyuck
Anand Potukuchi
@anandpotukchi
Jul 31 2018 16:21
Anyone whose doen the mongo challeneges?
please
I need help desparately
tundeiness
@tundeiness
Jul 31 2018 16:26
hi guys, i'm having challenges with my product landing page..it's not passing the test and it's just one test remaining for it to pass....i'm getting this error: "Each .nav-link element should have an href attribute : expected false to equal true". But the class nav-link has a href attribute. How do I solve this?
Kyle Holm
@thekholm80
Jul 31 2018 16:26
@tundeiness can you share your project?
tundeiness
@tundeiness
Jul 31 2018 16:28
@thekholm80 okay
Smootimus
@Smootimus
Jul 31 2018 16:32
Sent that app in
alpox
@alpox
Jul 31 2018 16:32
@tundeiness the class nav-link must be applied to the a element. On the li element should be the class nav-item
Refer to the bootstrap docs for this matter:
tundeiness
@tundeiness
Jul 31 2018 16:35
@alpox it's not working
Bjorn van de Peut
@bjorno43
Jul 31 2018 16:36
@tundeiness Try to read the error. It states "Each .nav-link should have an href attribute." If you look at your <li class='nav-link'> it doesn't contain a href attribute. I mean, of course it doesn't. It's not a link like <a>. So to solve the issue, you need to remove class='nav-link' from the <li> elements and add them to your <a> elements as those DO have a href attribute.
Kyle Holm
@thekholm80
Jul 31 2018 16:36
@tundeiness @alpox is right, that fixed it
alpox
@alpox
Jul 31 2018 16:36
@tundeiness from what I see in your pen until now, you did it only for one element
Kyle Holm
@thekholm80
Jul 31 2018 16:36
image.png
tundeiness
@tundeiness
Jul 31 2018 16:37
@alpox it works now..Thanks
alpox
@alpox
Jul 31 2018 16:37
@tundeiness np
Bjorn van de Peut
@bjorno43
Jul 31 2018 16:39
I just learned about childElementCount. Have to admit.. JS rly does have handy functions when you don't expect it :P
Kyle Holm
@thekholm80
Jul 31 2018 16:41
@bjorno43 JS has all the good stuff
Bjorn van de Peut
@bjorno43
Jul 31 2018 16:42
So it seems.. I expected that I would have to traverse the DOM manually and start counting as I wanted to know the number of child elements, but not include children of children. But no, JS was like: Here you go buddy! :joy:
Hmm. Maybe by now I should do some html encoding on strings submitted by users in my chat. It seems to be more than happy to parse <script> xD
Kyle Holm
@thekholm80
Jul 31 2018 16:47
i thought day one of learning web stuff was "sanitize anything you get from the user"
Bjorn van de Peut
@bjorno43
Jul 31 2018 16:47
I knowwwww! Just didn't get around to it yet :P
Kyle Holm
@thekholm80
Jul 31 2018 16:51
what's dutch for users?
then i can sign up as kyle); DROP TABLE gebruikers;
Bjorn van de Peut
@bjorno43
Jul 31 2018 16:52
That won't work, lol. I do use prepared statements you know :P
Christopher McCormack
@cmccormack
Jul 31 2018 16:53
prepared statements?
Kyle Holm
@thekholm80
Jul 31 2018 16:53
from his publicist
Christopher McCormack
@cmccormack
Jul 31 2018 16:53
hah why sanitize inputs when you can just say I'm sorry when there's an incident
Bjorn van de Peut
@bjorno43
Jul 31 2018 16:54
@cmccormack Prepared statements is like having placeholders in your queries for user provided data. It prevents SQL injection
Kyle Holm
@thekholm80
Jul 31 2018 16:54
i think the mongodb node driver does a good job of that
Christopher McCormack
@cmccormack
Jul 31 2018 16:54
oh yes I have seen those
like curly braces right?
Bjorn van de Peut
@bjorno43
Jul 31 2018 16:56
No. In MySQLi it's questionmarks. Like SELECT username FROM users WHERE id = ? and then you bind $_POST['id'] to it. In PDO they use named placeholders like SELECT username FROM users WHERE id = :userid and then bindParam(':userid', $_POST['id'])
One of the several reasons why I prefer PDO over MySQLi. It's much more clear
Christopher McCormack
@cmccormack
Jul 31 2018 16:59
clear as mud
Thanks for the explanation though :)
Bjorn van de Peut
@bjorno43
Jul 31 2018 17:00
Ghehe ye it's not something so easily explained untill you've worked with it a couple of times :P
Just keep in mind: Whenever you work with SQL and user provided data, it's a MUST. Can't do without or have a meet and greet with Bobby Tables
Christopher McCormack
@cmccormack
Jul 31 2018 17:02
no I do understand it just messing with you
I have worked with SQL ages ago
Bjorn van de Peut
@bjorno43
Jul 31 2018 17:04
Ah cool :)
@thekholm80 Just because my frontend is Dutch, doesn't mean my backend is :P I prefer to keep it easy for myself should I ever decide to open source or sell the project :P
Kyle Holm
@thekholm80
Jul 31 2018 17:05
i see. it is important to make everything as confusing as possible
Bjorn van de Peut
@bjorno43
Jul 31 2018 17:05
:joy:
Trust me. Anyone reading my code will be confused as hell xD
Kyle Holm
@thekholm80
Jul 31 2018 17:06
my company's production software is all coded in ... swedish, i think? and nobody can work on it
if i remember right, anyway
Christopher McCormack
@cmccormack
Jul 31 2018 17:06
I write all my code in Esperanto
Bjorn van de Peut
@bjorno43
Jul 31 2018 17:07
lol
Quite impressed with myself though. The core websocket server is still only 403 lines of code ^^
Kyle Holm
@thekholm80
Jul 31 2018 17:08
be careful, patting yourself on the back. don't want an injury
Bjorn van de Peut
@bjorno43
Jul 31 2018 17:09
Someone has to do it
Kyle Holm
@thekholm80
Jul 31 2018 17:10
lol
May Kittens Devour Your Soul
@diomed
Jul 31 2018 17:11
@cmccormack so it's artificial, just like your code
Bjorn van de Peut
@bjorno43
Jul 31 2018 17:11
Right. Now for the next problem: Flood protection
Bjorn van de Peut
@bjorno43
Jul 31 2018 17:12
:joy:
Christopher McCormack
@cmccormack
Jul 31 2018 17:12
@diomed all languages are made up
Alexander R Bott
@Abott1222
Jul 31 2018 17:37
@bjorno43 hey would you mind sharing the code for the chat app? I would be curious to see how you did it
Kyle Holm
@thekholm80
Jul 31 2018 17:39
@alpox @cmccormack https://github.com/acdlite/recompose/blob/master/docs/API.md#nest i think this is what i needed
Christopher McCormack
@cmccormack
Jul 31 2018 17:41
@thekholm80 are the inner components going to pass down props from the outer components to the children?
oh these are Providers
Kyle Holm
@thekholm80
Jul 31 2018 17:42
right-o
trying to take an ugly pile of providers and turn it into something not-so-ugly
Christopher McCormack
@cmccormack
Jul 31 2018 17:42
I need to learn how Context actually works under the covers
Kyle Holm
@thekholm80
Jul 31 2018 17:43
witchcraft, mostly
Christopher McCormack
@cmccormack
Jul 31 2018 17:43
I think nesting them like you were saying is probably fine :)
Kyle Holm
@thekholm80
Jul 31 2018 17:43
i think i have to be mindful of naming, but otherwise should be fine
Christopher McCormack
@cmccormack
Jul 31 2018 17:43
I have questions like why Provider is needed outside in the first place
@thekholm80 naming props?
won't it still be determined by the Consumer props?
Bjorn van de Peut
@bjorno43
Jul 31 2018 17:47
@Abott1222 I haven't decided about that yet. The code is going to be used in production so making it open source might not be the brightest idea. Aside from that it's mostly PHP. I don't think you're formiliar with that?
alpox
@alpox
Jul 31 2018 17:47
@thekholm80 Looks about right
@cmccormack Is your question why the context api is needed? I am not sure I understood your question :D
Alexander R Bott
@Abott1222
Jul 31 2018 17:50
@bjorno43 oh ya I dont know php :(
no problem. I was just curious what the pieces of something like that would be
Christopher McCormack
@cmccormack
Jul 31 2018 17:50
Why Provider is required around your components that want to utilize the Consumer @alpox
Alexander R Bott
@Abott1222
Jul 31 2018 17:50
I still need to learn websockets
lol
and aws
and docker
and ....
Bjorn van de Peut
@bjorno43
Jul 31 2018 17:50
@Abott1222 Not to mention that it's most likely way too complicated for beginners :P It's not like I commented every line and every function to explain what exactly it does. It's made for devs that understand code by reading it, haha
alpox
@alpox
Jul 31 2018 17:50
@cmccormack Because the provider passes down props to the consumer with ignoring the components in between
Kyle Holm
@thekholm80
Jul 31 2018 17:51
@cmccormack i mean the naming of the props
<MyContext.Provider
        value={{
          state: this.state,  // can't have duplicate names
          fetchData: this.fetchData  // here in other providers
        }}
      >
        {this.props.children}
      </MyContext.Provider>
Alexander R Bott
@Abott1222
Jul 31 2018 17:51
@bjorno43 Well I am a little seasoned but that makes sense. I was looking for a more high level overview
alpox
@alpox
Jul 31 2018 17:51
@cmccormack If you only have a consumer - what would he consume?
May Kittens Devour Your Soul
@diomed
Jul 31 2018 17:51
hope that house has some cork in case water comes in
Christopher McCormack
@cmccormack
Jul 31 2018 17:51
@alpox that makes sense but how is that an advantage over just using a straight Comonent to manage all state and methods?
alpox
@alpox
Jul 31 2018 17:52
@cmccormack The best example is probably react-router
Bjorn van de Peut
@bjorno43
Jul 31 2018 17:52
@Abott1222 I don't mind teaching you the basics of websockets with PHP if that's what you wish to learn.
alpox
@alpox
Jul 31 2018 17:53
react-router needs to know what routes exist and where to redirect. It has NavLinks to do the routing. But where is the routing effectively done? The links have to tell something where they want to route to
May Kittens Devour Your Soul
@diomed
Jul 31 2018 17:53
what is the best example for - I enter information in form, it prints out json?
alpox
@alpox
Jul 31 2018 17:53
So there is a provider at toplevel to which all NavLinks register to so the provider can do the route dispatching
Christopher McCormack
@cmccormack
Jul 31 2018 17:53
@diomed prints to where?
May Kittens Devour Your Soul
@diomed
Jul 31 2018 17:54
prints out object literals to json file
Bjorn van de Peut
@bjorno43
Jul 31 2018 17:54
@Abott1222 I mean, setting up a basic chatsystem is fairly easy. Once you get the basics, you should be able to expand upon it yourself
alpox
@alpox
Jul 31 2018 17:55
@cmccormack In addition, the Route elements of react-router get the information about the current route from the provider so they can hook in or not depending on the information they get
Christopher McCormack
@cmccormack
Jul 31 2018 17:55
@alpox I'm still not certain why that couldn't be handled by a single component, do you have any good articles that describe it better? Don't get me wrong I love Context API and I have used it, and I'm aware React Router has been using it for a while, I'd just like to understand it better
alpox
@alpox
Jul 31 2018 17:55
I don't read many articles so I sadly do not :/
But I wonder what approach you would go with a single component
Christopher McCormack
@cmccormack
Jul 31 2018 17:56
No worries I'll try to find something now that my curiosity has peaked
alpox
@alpox
Jul 31 2018 17:56
@cmccormack I think one can say that in general, the provider solves the problem of needing information distributed accross your application
Its like an information dispatcher - a centralized postal central :D
Christopher McCormack
@cmccormack
Jul 31 2018 17:57
In React Router does every component between the Provider and Consumer have access to the location state?
May Kittens Devour Your Soul
@diomed
Jul 31 2018 17:57
any answer to me question, mates?
alpox
@alpox
Jul 31 2018 17:57
@cmccormack No, only the consumer and the provider do
Christopher McCormack
@cmccormack
Jul 31 2018 17:57
@diomed if you need an actual file are you using any backend like PHP or node?
May Kittens Devour Your Soul
@diomed
Jul 31 2018 17:58
no
I mean is there any app for that
that I can modify
Kyle Holm
@thekholm80
Jul 31 2018 17:58
am i remembering right, that if i include a big library for the front end, webpack will pull from it only what is needed in the production bundle? i won't end up with the entire thing bloating my bundle?
May Kittens Devour Your Soul
@diomed
Jul 31 2018 17:58
My cup of coffee has turned 2-dimensional this morning. How do i free it from this pain?
Bjorn van de Peut
@bjorno43
Jul 31 2018 17:59
@diomed Get some 3D glasses at your local theater for $1
Christopher McCormack
@cmccormack
Jul 31 2018 17:59
@alpox I think I'm hung up on something silly, I'll do some research and see where I'm mistaken
@thekholm80 depends
from my experience it depends on how you import it
that's why I don't use destructuring anymore where I can avoid it
Kyle Holm
@thekholm80
Jul 31 2018 18:01
so if i import { method } from 'library'; it's bad?
May Kittens Devour Your Soul
@diomed
Jul 31 2018 18:01
y use webpack
Christopher McCormack
@cmccormack
Jul 31 2018 18:01
@thekholm80 I think it depends on how the dependency is packaged
Kyle Holm
@thekholm80
Jul 31 2018 18:02
because i have a coupon that saves me 20% @diomed
May Kittens Devour Your Soul
@diomed
Jul 31 2018 18:02
wHen there's parcel
Christopher McCormack
@cmccormack
Jul 31 2018 18:02
like for fontawesome, you can access specific items, but for others you have to do it the way you have above
This message was deleted
I think it depends on if it's all in one file or if there are separate files
Kyle Holm
@thekholm80
Jul 31 2018 18:03
i just don't want to bring in recompose for that single method, if i'm going to have the whole library in my bundle
Christopher McCormack
@cmccormack
Jul 31 2018 18:03
Parcel has the exact same issue I believe
but I agree Parcel is awesome
@thekholm80 I usually look in my node_modules and see if they are broken out by file
Kyle Holm
@thekholm80
Jul 31 2018 18:05
maybe i'll just see how they made it and try to duplicate it
Christopher McCormack
@cmccormack
Jul 31 2018 18:05
if so you can usually access it by the file directly, like import Nest from "recompose/Nest" or whatever
or see if there is a node module that just does that
they've been working to break up modules for this reason I believe
Kyle Holm
@thekholm80
Jul 31 2018 18:06
import { createFactory } from 'react'
import getDisplayName from './getDisplayName'

const nest = (...Components) => {
  const factories = Components.map(createFactory)
  const Nest = ({ children, ...props }) =>
    factories.reduceRight((child, factory) => factory(props, child), children)

  if (process.env.NODE_ENV !== 'production') {
    const displayNames = Components.map(getDisplayName)
    Nest.displayName = `nest(${displayNames.join(', ')})`
  }

  return Nest
}

export default nest
not a big deal, really
Christopher McCormack
@cmccormack
Jul 31 2018 18:06
@thekholm80 I like to use the webpack visualizer to see how much space each module uses and it often surprises me
that link is to my webpack config not the plugin
Kyle Holm
@thekholm80
Jul 31 2018 18:07
i'm using create-react-app
Christopher McCormack
@cmccormack
Jul 31 2018 18:07
oh
Kyle Holm
@thekholm80
Jul 31 2018 18:07
because i'm lazy
Christopher McCormack
@cmccormack
Jul 31 2018 18:07
isn't there some escape thing for webpack?
Kyle Holm
@thekholm80
Jul 31 2018 18:07
eject, i think
Christopher McCormack
@cmccormack
Jul 31 2018 18:07
I always forget the name
yeah
Christopher McCormack
@cmccormack
Jul 31 2018 18:32
Anyone happen to know any good alternatives to SecureCRT for Mac? Shot in the dark but looking for something better
Elias Curran
@eliascurran
Jul 31 2018 18:47
Why is it saying join is undefined ?
const List = (props) => {
  { /* change code below this line */ }
  return <p>{props.tasks.join(', ')}</p>
  { /* change code above this line */ }
};

class ToDo extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
      <div>
        <h1>To Do Lists</h1>
        <h2>Today</h2>
        { /* change code below this line */ }
        <List/>
        <h2>Tomorrow</h2>
        <List tasks={["dlfj", "dlkfj", "lsdjkf"]} />
        <List/>
        { /* change code above this line */ }
      </div>
    );
  }
};
Kyle Holm
@thekholm80
Jul 31 2018 18:51
@eliascurran you have 2 <List /> components, one with tasks and one without
the one without will have tasks as undefined
Elias Curran
@eliascurran
Jul 31 2018 18:52
so i put tasks on all of them
Aditya
@ezioda004
Jul 31 2018 18:54
@eliascurran You can also do return props && <p>{props.tasks.join(', ')}</p>
Elias Curran
@eliascurran
Jul 31 2018 18:55
ok @ezioda004 ill try that
i tried it and i got the same answer
Aditya
@ezioda004
Jul 31 2018 18:59
@eliascurran Is this a FCC challenge?
Christopher McCormack
@cmccormack
Jul 31 2018 19:00
@eliascurran you should update your code or present the new code, simply stating you tried something and it didn't work doesn't tell us if you implemented it correctly
Elias Curran
@eliascurran
Jul 31 2018 19:01
@ezioda004 Yes, it is, it's "React: Pass an Array as Props"
Christopher McCormack
@cmccormack
Jul 31 2018 19:01
it should look more like return props && props.tasks && <p>{props.tasks.join(', ')}</p> I believe
Moisés Man
@moigithub
Jul 31 2018 19:02
pass data to ur other List component too
Christopher McCormack
@cmccormack
Jul 31 2018 19:02
or just return props.tasks && <p>{props.tasks.join(', ')}</p>
Kyle Holm
@thekholm80
Jul 31 2018 19:02
Today's list should have at least 2 tasks and tomorrow's should have at least 3 tasks
so <List /> isn't gonna cut it
Christopher McCormack
@cmccormack
Jul 31 2018 19:03
right
Elias Curran
@eliascurran
Jul 31 2018 19:05
this is what i have now, it's not working can you guys help
const List = (props) => {
  { /* change code below this line */ }
  return  props.tasks && <p>{props.tasks.join(', ')}</p>
  { /* change code above this line */ }
};

class ToDo extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
      <div>
        <h1>To Do Lists</h1>
        <h2>Today</h2>
        { /* change code below this line */ }
        <List/>
        <h2>Tomorrow</h2>
        <List tasks = {["dlfj", "dlkfj", "lsdjkf"]} />
        <List/>
        { /* change code above this line */ }
      </div>
    );
  }
};
Christopher McCormack
@cmccormack
Jul 31 2018 19:05
@eliascurran :point_up: July 31, 2018 12:02 PM
Elias Curran
@eliascurran
Jul 31 2018 19:06
what do mean by only list
Christopher McCormack
@cmccormack
Jul 31 2018 19:06
@eliascurran you didn't pass tasks to your first List
Kyle Holm
@thekholm80
Jul 31 2018 19:07

you have 3 lists

       <List/>
        <h2>Tomorrow</h2>
        <List tasks = {["dlfj", "dlkfj", "lsdjkf"]} />
        <List/>

only one has tasks

you should have 2 lists, each list should have tasks
Elias Curran
@eliascurran
Jul 31 2018 19:07
ok
@thekholm80 , @cmccormack , @ezioda004 it't working now. thank you for helping me with this challenge i am only 11 and this challenge was very difficult for my to understand. Thank you for helping me.
Kyle Holm
@thekholm80
Jul 31 2018 19:10
:+1:
Christopher McCormack
@cmccormack
Jul 31 2018 19:13
@eliascurran doesn't matter your age, people of all ages run into similar issues :) it's all about reading the description and requirements very closely, and if you don't understand a concept, maybe go back and review.
Kyle Holm
@thekholm80
Jul 31 2018 19:15
i just ask chris
Christopher McCormack
@cmccormack
Jul 31 2018 19:22
@thekholm80 that chris guy must hate it
Kyle Holm
@thekholm80
Jul 31 2018 19:23
oh man i hope so
Kyle Holm
@thekholm80
Jul 31 2018 19:34
well my context wrapper is awesome, my customized nest not so much
Christopher McCormack
@cmccormack
Jul 31 2018 19:38
@thekholm80 not working?
or just not awesome
Kyle Holm
@thekholm80
Jul 31 2018 19:38
not working
something about expecting a render method - i don't care enough to keep trying to squash it
besides, once i add apollo and all that to my front end my index is going to be ugly anyway
Christopher McCormack
@cmccormack
Jul 31 2018 19:47
hah going to be, sure
Kyle Holm
@thekholm80
Jul 31 2018 20:12
@diomed x
May Kittens Devour Your Soul
@diomed
Jul 31 2018 20:13
BLESS YOU,kitty!
Uriel Guzmán
@Burinson
Jul 31 2018 20:17
Does anyone know why my github website looks weird on mobile devices but looks better on Codepen? It seems as if media queries are not working
Christopher McCormack
@cmccormack
Jul 31 2018 20:19
@Burinson add this to your head if you don't already have it:
<meta name="viewport" content="width=device-width, initial-scale=1">
Uriel Guzmán
@Burinson
Jul 31 2018 20:21
@cmccormack Thanks, I'll let you know if it worked
Christopher McCormack
@cmccormack
Jul 31 2018 20:21
@Burinson it's bit me a few times - I believe you need something like that for media queries to work effectively, especially on mobile
Codepen may have that by default, and you can add it in the Pen Settings under HTML, button at the bottom ↑ Insert the most common viewport meta tag
Uriel Guzmán
@Burinson
Jul 31 2018 20:25
@cmccormack Lol, it did work
Hahaha
Thanks
Christopher McCormack
@cmccormack
Jul 31 2018 20:26
@Burinson np
May Kittens Devour Your Soul
@diomed
Jul 31 2018 20:26
@cmccormack so, got any ideas
Christopher McCormack
@cmccormack
Jul 31 2018 20:26
@diomed lots, anything specific?
May Kittens Devour Your Soul
@diomed
Jul 31 2018 20:26
for generating json files via forms
Christopher McCormack
@cmccormack
Jul 31 2018 20:26
@diomed building, or an existing tool?
I didn't know of any existing tool so I didn't respond sorry
May Kittens Devour Your Soul
@diomed
Jul 31 2018 20:26
existing if possible
Christopher McCormack
@cmccormack
Jul 31 2018 20:31
May Kittens Devour Your Soul
@diomed
Jul 31 2018 20:34
@cmccormack I'm aware of such thing being possible
but problem is that it only generates one,
and I need literally hundreds of them
so I'd need smth like
upon clicking on submit everything clears, so I can start over, but sends to json
Christopher McCormack
@cmccormack
Jul 31 2018 20:37
you could probably update this code to append the new json to an existing object then only display when you're done. Clearing the existing form should be trivial in a submit event listener
May Kittens Devour Your Soul
@diomed
Jul 31 2018 20:42
I could if I knew JS. :stuck_out_tongue:
Kyle Holm
@thekholm80
Jul 31 2018 20:44
when you say generates json, do you mean in a local file?
May Kittens Devour Your Soul
@diomed
Jul 31 2018 20:46
yes
Kyle Holm
@thekholm80
Jul 31 2018 20:49
knocking something up
May Kittens Devour Your Soul
@diomed
Jul 31 2018 20:50
oh. cool cool cool
you provide backend, I'll make it pretty
and mby we publish it together - Yesh! :yum:
Kyle Holm
@thekholm80
Jul 31 2018 20:55
lol nope
Manish Giri
@Manish-Giri
Jul 31 2018 20:55
@cmccormack fixed that problem -
function elementsSum(arr,d=0){
  return arr.reduce((a,b,i) => {
    const e = b[arr.length-i-1];
    return e || e === 0 ? a + e: a + d;
  }, 0);
}
Karma Drukpa
@coderkarma
Jul 31 2018 20:55
@Manish-Giri i HAVE NOT DONE IT YET
Manish Giri
@Manish-Giri
Jul 31 2018 20:55
not one line, too bad
@coderkarma haha keep trying, you'll get it :thumbsup:
Christopher McCormack
@cmccormack
Jul 31 2018 20:57
@Manish-Giri looks good, I debated storing b[arr.length-i-1] but needed it to be one line for some stupid personal reason :D
Kyle Holm
@thekholm80
Jul 31 2018 20:57
caps lock is like cruise control for cool
Ollie Page
@Revix
Jul 31 2018 20:58
is this a public chat room for helping eachother on the FCC challenges?
Kyle Holm
@thekholm80
Jul 31 2018 20:58
yep
Ollie Page
@Revix
Jul 31 2018 20:58
that's cool
Manish Giri
@Manish-Giri
Jul 31 2018 20:59
@cmccormack I tried to invent something stupid to make it one line, but it didn't work lol
return arr.reduce((a,b,i) => x=b[arr.length-i-1] && (x || x === 0) ? ... )
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:00
@Manish-Giri make me an app
:smiling_imp:
Christopher McCormack
@cmccormack
Jul 31 2018 21:00
@Manish-Giri did you see my last answer?
Manish Giri
@Manish-Giri
Jul 31 2018 21:00
:smirk_cat: @diomed
yeah just a few minutes back
Ollie Page
@Revix
Jul 31 2018 21:01
Manish how are you formatting your code in this chat so that the colours aren't lost?
Manish Giri
@Manish-Giri
Jul 31 2018 21:01
@diomed you've entered the JS world from what I've been hearing
@Revix you either use three backticks (```) and paste your code between them (for multiline code)
or use single backtick (`) for single line code
Ollie Page
@Revix
Jul 31 2018 21:02
let squaredIntegers = arr.filter((arr) => arr > 0 && Number.isInteger(arr)).map((arr) => arr * arr);
how come it isn't coloured like yours with a black background?
Manish Giri
@Manish-Giri
Jul 31 2018 21:03
use three backticks
Ollie Page
@Revix
Jul 31 2018 21:03
let squaredIntegers = arr.filter((arr) => arr > 0 && Number.isInteger(arr)).map((arr) => arr * arr);
maybe mine needs to be longer code
Manish Giri
@Manish-Giri
Jul 31 2018 21:03
let squaredIntegers = arr.filter((arr) => arr > 0 && Number.isInteger(arr)).map((arr) => arr * arr);
Kyle Holm
@thekholm80
Jul 31 2018 21:03
there's no sytax highlighting for inline code
only code blocks
Manish Giri
@Manish-Giri
Jul 31 2018 21:04
i got syntax highlighting
:smiling_imp:
Christopher McCormack
@cmccormack
Jul 31 2018 21:04
```
Code
```
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:04
mlem mlem
Christopher McCormack
@cmccormack
Jul 31 2018 21:04
not
` Code `
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:04
@Revix just press spacebar 4 times and paste your code. lol
alpox
@alpox
Jul 31 2018 21:04
And sometimes, gitter doesnt recognize the language. In that case you can just add the language shortcut right after the first three backticks
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:04
they're all lying to you
Ollie Page
@Revix
Jul 31 2018 21:04
If you quote my syntax you'll see I'm using 3 ticks
alpox
@alpox
Jul 31 2018 21:04
Like ```js
Manish Giri
@Manish-Giri
Jul 31 2018 21:05
let squaredIntegers = arr.filter((arr) => arr > 0 && Number.isInteger(arr)).map((arr) => arr * arr);
Christopher McCormack
@cmccormack
Jul 31 2018 21:05
@Revix backticks go on their own line
own line
own line
Manish Giri
@Manish-Giri
Jul 31 2018 21:05
you're putting it in one line
try separate lines
```
Code
```
like that
Ollie Page
@Revix
Jul 31 2018 21:05
let squaredIntegers = arr.filter((arr) => arr > 0 && Number.isInteger(arr)).map((arr) => arr * arr);
oooh!
Bjorn van de Peut
@bjorno43
Jul 31 2018 21:05
Syntax highlighting kinda relies on the way you start your code. Like at default it assumes html / css / javascript. But if you start your code with
<?php

echo "It recognised <?php so it highlights this as php code";

?>
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:06
ARRRAYYYYY!!!!
Ollie Page
@Revix
Jul 31 2018 21:06
Nice one guys. Thanks for all pooling together to figure this out
Manish Giri
@Manish-Giri
Jul 31 2018 21:06
bingo
Christopher McCormack
@cmccormack
Jul 31 2018 21:06
@bjorno43 it barely even implies js
alpox
@alpox
Jul 31 2018 21:06
@bjorno43 You can also force it with the shortcut
Ollie Page
@Revix
Jul 31 2018 21:06
I take it it also works on forums that way
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:06
we've known this since forever
Christopher McCormack
@cmccormack
Jul 31 2018 21:06
I start most of my code with
```js
alpox
@alpox
Jul 31 2018 21:06
let squaredIntegers = arr.filter((arr) => arr > 0 && Number.isInteger(arr)).map((arr) => arr * arr);
This is with js highlight
Christopher McCormack
@cmccormack
Jul 31 2018 21:06
or
```sh
if shell script or whatever
Karma Drukpa
@coderkarma
Jul 31 2018 21:06
@Manish-Giri you guys are using map, reduce, filter, god damn.. i am trying to get comfortable with those , but still i am not.
alpox
@alpox
Jul 31 2018 21:06
@cmccormack Same
@coderkarma They are the best
Manish Giri
@Manish-Giri
Jul 31 2018 21:07
practice practice and more practice :smile: @coderkarma
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:07
[carbon.png
pht. amateurs
Bjorn van de Peut
@bjorno43
Jul 31 2018 21:07
Ye. It's just Github markdown flavor. So anything that works with Github, should work here
Ollie Page
@Revix
Jul 31 2018 21:07
I've just started the ES6 FCC where it uses them @coderkarma
Manish Giri
@Manish-Giri
Jul 31 2018 21:07
you'll get it
alpox
@alpox
Jul 31 2018 21:07
map,filter, reduce, reduceRight, find, findIndex
Karma Drukpa
@coderkarma
Jul 31 2018 21:07
i want to be part of best folks
Kyle Holm
@thekholm80
Jul 31 2018 21:08
@diomed here you go
Karma Drukpa
@coderkarma
Jul 31 2018 21:08
Thank you thank you.... @Revix
Kyle Holm
@thekholm80
Jul 31 2018 21:08
what a pain in the butt, i've never used Blob() before
Ollie Page
@Revix
Jul 31 2018 21:10
does anyone know how to change your display name on here? feels a little weird having my github full name when everyone else is on nicknames/usernames
Kyle Holm
@thekholm80
Jul 31 2018 21:10
who's using nicknames?
i only see alpox
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:10
@thekholm80 wait, how is this different?
Kyle Holm
@thekholm80
Jul 31 2018 21:10
oh and @diomed but he's a bot
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:11
I still get only 1 result. beeep-bop
Manish Giri
@Manish-Giri
Jul 31 2018 21:11
and mlem
Kyle Holm
@thekholm80
Jul 31 2018 21:11
@diomed maybe you should make it more clear, what you're asking?
Ollie Page
@Revix
Jul 31 2018 21:11
and May Kittens Devour Your Soul
Kyle Holm
@thekholm80
Jul 31 2018 21:11
you wanted json in a file from form data
i gave you json in a file from form data
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:12
{"name":"Phoebe","age":"24"}
looks like this
with " " around name and age
can it be removed
Kyle Holm
@thekholm80
Jul 31 2018 21:13
if it's removed, it's not JSON anymore
it's just object data
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:13
ok. I need object data then :P
Kyle Holm
@thekholm80
Jul 31 2018 21:13
too bad
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:13
why?
Bjorn van de Peut
@bjorno43
Jul 31 2018 21:14
I recently discovered a major website that managed to use JSON in a very bad way..
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:14
@bjorno43 pft. I can do worse than them! just watch me!
Bjorn van de Peut
@bjorno43
Jul 31 2018 21:14
lol
Manish Giri
@Manish-Giri
Jul 31 2018 21:15
@cmccormack const elementsSum = (a, d=0,l=a.length) => a.reduce((s,n,i)=> s + (--l >= n.length? d: n[l] ),0);
smh
Christopher McCormack
@cmccormack
Jul 31 2018 21:15
does it work?
Manish Giri
@Manish-Giri
Jul 31 2018 21:15
probably, it's the top solution
Christopher McCormack
@cmccormack
Jul 31 2018 21:15
I like the --l
it's clever hah
Bjorn van de Peut
@bjorno43
Jul 31 2018 21:16
Nah it's the RIPE EU ip database server. They're the offical "go to" when you want information regarding an EU ip address. They present you with that information in a nice JSON file so you can query it from your scripts. But here's the catch: They move the data around so it's not consistent..
Manish Giri
@Manish-Giri
Jul 31 2018 21:16
its a nice way to account for the -1 index
Kyle Holm
@thekholm80
Jul 31 2018 21:16
@diomed the only way i could do that is with regex and it probably wouldn't work reliably
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:17
@thekholm80 that's actually not the main problem at all
I can remove that easily
problem is functionality.
coz I want it to save everything I write
not just 1 entry
Kyle Holm
@thekholm80
Jul 31 2018 21:18
are you trying to build a keylogger?
in like the worst possible way?
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:18
IDK maybe? what is keylogger
Kyle Holm
@thekholm80
Jul 31 2018 21:18
something that creates a log of all your keystrokes
Bjorn van de Peut
@bjorno43
Jul 31 2018 21:19
Keyloggers.. oldskool password stealing xD
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:19
I'm trying to build a json list via form entering
Kyle Holm
@thekholm80
Jul 31 2018 21:20
but not the way that i did it
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:20
but when I click submit form should clear and let me enter new data
Kyle Holm
@thekholm80
Jul 31 2018 21:20
oh that part is easy lol
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:20
but save one that I already entered
Kyle Holm
@thekholm80
Jul 31 2018 21:20
i didn't use an actual form, all that functionality can be added
#learnYouHTML
i got you a proof-of-concept not a custom tailored solution lol
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:21
you got me nothing that I didnt have already :(
Kyle Holm
@thekholm80
Jul 31 2018 21:22
oh well i'm sorry i wasted my time for you
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:22
I'm sorry too :/
Bjorn van de Peut
@bjorno43
Jul 31 2018 21:22
Basicly you create an empty variable that holds your JSON string. Then catch form submit. Prevent default. Encode JSON and concatenate to JSON string. Empty form. Repeat untill finished. Do something with final JSON string
Well that's the basic idea. Pretty sure it's a bit more complicated than that :P
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:24
#easier said than done ;)
Christopher McCormack
@cmccormack
Jul 31 2018 21:25
It's almost exactly the same advice I gave so it must be easy right?
@diomed do you have any code of your own? Start with something and we can add info as needed
May Kittens Devour Your Soul
@diomed
Jul 31 2018 21:27
I do have something alike but can't do anything today anymore. coz it's late and gotta go to sleep. see you tomorrow, guys. hopefully
Christopher McCormack
@cmccormack
Jul 31 2018 21:32
@diomed that was ominous
@thekholm80 @Manish-Giri one liner plz
function twoSort(s) {
  // create a empty arr result
  let result = [];
  // sort the str
     s.sort();
  // get the firs element of that arr
    let first = s[0];
  // split that element in arr
     let newArr = first.split('');
  //loop through 1st sorted element and
      for (let i = 0; i < newArr.length; i += 1){
         result.push(newArr[i]);
    }
  return newArr.join('***');
}
why i can't think of arrow function
can I USE map for this?
Bjorn van de Peut
@bjorno43
Jul 31 2018 22:24
@diomed I case you're seeing this tomorrow:
let myObj = {};
let myArr = [];

document.getElementById('myForm').addEventListener('submit', processForm, false);

function processForm(e){
    e.preventDefault();

    const formData = new FormData(document.getElementById('myForm'));

    for(let key of formData.entries()){
        myObj[key[0]] = key[1];
    }

    myArr.push(myObj);

    myObj = {};

    document.getElementById('myForm').reset();

    getResult();
}

function getResult(){
    const result = JSON.stringify(myArr);

    console.log(result);
}
// First form submit: [{"user":"test1","age":"40"}]
// Second form submit: [{"user":"test1","age":"40"},{"user":"test2","age":"32"}]
Karma Drukpa
@coderkarma
Jul 31 2018 22:25
@bjorno43
Kyle Holm
@thekholm80
Jul 31 2018 22:32
@coderkarma const twoSort=s=>s.sort()[0].split('').map((a,i,o)=>i==o.length-1?a:`${a}***`).join('');
Karma Drukpa
@coderkarma
Jul 31 2018 22:32
lol
found out this
return s.sort()[0].split('').join('*');
omg...
Kyle Holm
@thekholm80
Jul 31 2018 22:33
yeah lol i've used that before but i didn't even think of it
Karma Drukpa
@coderkarma
Jul 31 2018 22:34
lol!! why this kind of solution doesn't form into my brain.
damit
Bjorn van de Peut
@bjorno43
Jul 31 2018 22:34
curse of being used to doing complicated stuff.. you become blind to simple solutions
Karma Drukpa
@coderkarma
Jul 31 2018 22:35
@bjorno43 no I am not pro like other folks, i am doing basic kata8 in codewars
Bjorn van de Peut
@bjorno43
Jul 31 2018 22:36
@coderkarma I was refering to @thekholm80 's solution :P
Anyway, going off to bed 0:40 AM here. Gn8 guys :wave:
Kyle Holm
@thekholm80
Jul 31 2018 22:39
@bjorno43 g'night