These are chat archives for FreeCodeCamp/HelpJavaScript

20th
Mar 2018
Norvin Burrus
@ndburrus
Mar 20 2018 01:07
@sjames1958gm thanks for sharing....i needed that.... ur a king! :sparkles:
CamperBot
@camperbot
Mar 20 2018 01:07
ndburrus sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9117 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Mar 20 2018 01:18
@ndburrus :)
Dan Malone
@danmalone89
Mar 20 2018 03:28
Need some help here guys.. I have an array of objects and I'm trying to list each item in a table. I'm only able to get the root [0] contact to show, and not any others. I think I'm iterating over the array incorrectly, but not sure. I've probably been staring at this screen too long :worried: Anyone have any tips?
function drawData(data) {
    for (i = 0; 0 <= data.Contacts; i++) {
    }
    var row = $("<tr />")
    $("#contactTable").append(row);
    row.append($("<td>" + data.Contacts[i].FullName4 + "</td>"));
    row.append($("<td>" + data.Contacts[i].ContactID + "</td>"));
}
Here's what my JSON response looks like
{Contacts: Array(2), TotalRecords: 2}
Contacts:Array(2)
0:{ContactID: 123456, DatabaseID: 0, FullName2: null, FullName3: null, FullName4: "John Doe", …}
1:{ContactID: 123456, DatabaseID: 0, FullName2: null, FullName3: null, FullName4: "Jane Doe ", …}
Kelechi Chinaka
@ke1echi
Mar 20 2018 03:32
your loop is wrongly defined
you need to initialize i
Brad
@bradtaniguchi
Mar 20 2018 03:36
@danmalone89 Your loop does nothing for a number of reasons
Id suggest skimming through this document on all the ways you could iterate over the data returned from your response:
Norvin Burrus
@ndburrus
Mar 20 2018 04:03
@sjames1958gm you might enjoy this :sparkles:
Ayush Bahuguna
@relentless-coder
Mar 20 2018 07:51
export function getAllHost(req, res) {
    function findAllHost() {
        let query = {};

        query.company = req.query && req.query.companyId ? req.query.companyId : res.locals.payload.companyId;
        query.active = true;

        if(req.query && req.query.name) {
            let regexp = new RegExp('\\b' + req.query.name);
            query['name'] = {$regex: regexp, $options: 'i'};
        }

        return Host.find(query);
    }

    async function sendRes() {
        let allHost = [];
        for (let host of await findAllHost()) {
            allHost.push(new Host_V1(host));
        }
        res.status(200).json(allHost);
    }

    return sendRes().catch(error => {
        res.status(error.status || 500).json({
            message: error.status ? error.message : 'Server Error'
        });
    });
}
need help with trying to learn async/await
the above doesn't work
Rabira
@rabira-hierpa
Mar 20 2018 07:54
hi everyone. I'm trying to create a function expression for rot13 encryption algorithm. Here is what my code looks like
var rot13 = function(text) {
    var Text = text.split('');
    var cipher = [];
    var encrypt = function () {
        cipher = [];
      for (var i = 0; i < Text.length; i++) {
            if ( (text.charCodeAt(i)>=65 && text.charCodeAt(i)<=77) || (text.charCodeAt(i) >=97 && text.charCodeAt(i) <=109) ){
               cipher.push(String.fromCharCode(text.charCodeAt(i)+13));
            }else if ((text.charCodeAt(i)>=78 && text.charCodeAt(i) <=90) || (text.charCodeAt(i)>=110 && text.charCodeAt(i)<=122)) {
                cipher.push(String.fromCharCode(text.charCodeAt(i)+13));
            }
        }
        return this;
    };

    var decrypt = function () {
        cipher = [];
        for (var i = 0; i < Text.length; i++) {
           if ( (text.charCodeAt(i)>=65 && text.charCodeAt(i)<=77) || (text.charCodeAt(i) >=97 && text.charCodeAt(i) <=109) ){
              cipher.push(String.fromCharCode(text.charCodeAt(i)+13));
           }else if( (text.charCodeAt(i)>=78 && text.charCodeAt(i) <=90) || (text.charCodeAt(i)>=110 && text.charCodeAt(i)<=122) ){
               cipher.push(String.fromCharCode(text.charCodeAt(i)-13));
           }
       }
       return this;
   };

    var show = function(){
        console.log(cipher.join('').toString());
    };

   var get = function get(){
     return cipher;
   };

    return {
        encrypt:encrypt,
        decrypt:decrypt,
        show:show,
        get:get
    };
};

var message = "hello world";
// console.log(rot13(message).encrypt());
var inc = rot13(message).encrypt().get();
var dec = rot13(inc).decrypt().show();
console.log(dec);
but i get the error text.split('') is not a function when i try to run it with node.
Markus Kiili
@Masd925
Mar 20 2018 08:03
@rabira-hierpa inc holds an array [ 'u', 'r', 'y', 'y', '|', '„', '|', '', 'y', 'q' ] and you call rot13(inc) so you are calling split method on an array with text.split('').
Rabira
@rabira-hierpa
Mar 20 2018 08:07
@Masd925 Oh! thanks, I didn't notice.
CamperBot
@camperbot
Mar 20 2018 08:07
rabira-hierpa sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4734 | @masd925 |http://www.freecodecamp.org/masd925
Markus Kiili
@Masd925
Mar 20 2018 08:15
@rabira-hierpa For your information, there are simple one-line solutions for rot13 and with 3 lines you can do it without any magic numbers like 13,78, and 90. So you could refactor it somewhat.
ZAHEER AFZAL
@zaheer442
Mar 20 2018 08:42
Hi

i want to add server link in separate config file so i can change it easily

var RPiService = {};
var RPi_Url = "http://192.168.10.75:1337/"
// i want to add above address in separate config file so i can change it easily

    RPiService = {
        changeDeviceState: function (state) {
            //+ "?state=" + state
            var jqXhr = $.ajax({
                url: RPi_Url + "?state=" + state,
                crossDomain: true,
                datatype: "jsonp",
                success: function (data) {
                    console.log(data);
                }
            });
            return jqXhr;
        }
    };
Stephen James
@sjames1958gm
Mar 20 2018 09:03
@zaheer442 Assuming you are not using a server side bundler. You can put that declaration in a separate file and just
load it before your script file that has the code from above. You can put it in the global space if desired.
Rabira
@rabira-hierpa
Mar 20 2018 09:23
Why can't I access the encoded array in the decrypt() method
var rot13 = function(text) {
    var cipher = [];
    var encoded = [];
    var encrypt = function () {
        var Text = text.split('');
      for (var i = 0; i < Text.length; i++) {
            if ( (text.charCodeAt(i)>=65 && text.charCodeAt(i)<=77) || (text.charCodeAt(i) >=97 && text.charCodeAt(i) <=109) ){
               cipher.push(String.fromCharCode(text.charCodeAt(i) + 13));
            }else if ((text.charCodeAt(i)>=78 && text.charCodeAt(i) <=90) || (text.charCodeAt(i)>=110 && text.charCodeAt(i)<=122)) {
                cipher.push(String.fromCharCode(text.charCodeAt(i) - 13));
            }else{
                cipher.push(String.fromCharCode(text.charCodeAt(i)));
            }
        }
        encoded = Object.assign([],cipher);
        return this;
    };

    var decrypt = function () {
        plain = [];
        console.log("Inside decrypt()" + cipher);// prints out only Inside decrypt() 
        for (var i = 0; i < cipher.length; i++) {
           if ( (cipher.charCodeAt(i)>=65 && cipher.charCodeAt(i)<=77) || (cipher.charCodeAt(i) >=97 && cipher.charCodeAt(i) <=109) ){
              plain.push(String.fromCharCode(cipher.charCodeAt(i) + 13));
           }else if( (cipher.charCodeAt(i)>=78 && cipher.charCodeAt(i) <=90) || (cipher.charCodeAt(i)>=110 && cipher.charCodeAt(i)<=122) ){
               plain.push(String.fromCharCode(cipher.charCodeAt(i) - 13));
           }else{
            plain.push(String.fromCharCode(cipher.charCodeAt(i)));
        }
       }
       return this;
   };

    var show = function(){
        return cipher.join('').toString();
    };

   var get = function get(){
     return cipher;
   };

    return {
        encrypt:encrypt,
        decrypt:decrypt,
        show:show,
        get:get
    };
};

var message = "hello world";
// console.log(rot13(message).encrypt());
var enc = rot13(message).encrypt().show();
var dec = rot13(enc).decrypt().show();
console.log(enc);
console.log(dec);
Markus Kiili
@Masd925
Mar 20 2018 09:29
@rabira-hierpa You can. In that case both cipher and encoded are empty arrays.
If you console.log their length, you will get 0.
Rabira
@rabira-hierpa
Mar 20 2018 10:12
@Masd925 Yes they are empty. How can I make encoded array hold the vaule of the cipher array after the encrypt function call.
Naveenjake
@Naveenjake
Mar 20 2018 10:46
Hi I'm new to java script where can i learn from basics
Markus Kiili
@Masd925
Mar 20 2018 10:47
@Naveenjake Here is one place https://developer.mozilla.org/bm/docs/Web/JavaScript . Avoid W3Schools javascript content. There are several books that are free to read online: Speaking javascript, You don't know javascript, ...
FCC javascript challenges of course.
Naveenjake
@Naveenjake
Mar 20 2018 10:48
Thanks...!
Greg Duncan
@GregatGit
Mar 20 2018 12:27
@rabira-hierpa you need to use your debugger in the chome console to and follow it line by line to see where you are going wrong
MrCDSWB
@MrCDSWB
Mar 20 2018 13:20
Hi ! everyone .Now I have a problem
Return Early Pattern for Functions
this problem
who can help me thanks
h1tag
@h1tag
Mar 20 2018 13:23
@MrCDSWB what have you done so far?
Stephen James
@sjames1958gm
Mar 20 2018 13:39
@MrCDSWB You can post your code - use this link https://forum.freecodecamp.com/t/markdown-code-formatting/18391
Chris
@ConnectCodes
Mar 20 2018 14:19
Hi all stuck on Exact Change challenge, I don’t know why condition in my inner while loopcurrencyAmount[i] > local && changeCent > total doesn’t exit and set i =4 I console logged key elements but nothing makes sense.
https://codepen.io/Codeconnect/pen/dZQygY?editors=0012
Elia
@elia-russad
Mar 20 2018 14:21
var x = function() {
  var i = 0
  add = function(j) {
    i += j
    return this
  }
  sub = function(j) {
    i -= j
    return this
  }
  print = function() {
    console.log(i)
  }
  return {add: add, sub: sub, print: print}
}

var y = x()
y.add(3).sub(1).print() // works 
x.add(3).sub(1).print() // doesnt work
sup guys. i'm tryin to chain functions. can you explain why it doesnt work when i chain directly with X ? how to make it work with x?
Sweet Coding :)
@SweetCodingInc
Mar 20 2018 14:22
@elia-russad {add: add, sub: sub, print: print} is returned, when you call the x
the right syntax would be x().add(3).sub(1).print()
Marianissimus
@Marianissimus
Mar 20 2018 14:24
@ConnectCodes I don't understand all your code, but you are decreasing the i inside the while loop, and the condition is while(changeCent >= total);
shouldn't they match?
Elia
@elia-russad
Mar 20 2018 14:24
@SweetCodingInc daamn, thanks
CamperBot
@camperbot
Mar 20 2018 14:24
elia-russad sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 382 | @sweetcodinginc |http://www.freecodecamp.org/sweetcodinginc
Sweet Coding :)
@SweetCodingInc
Mar 20 2018 14:25
@elia-russad :+1:
@ConnectCodes You might wanna use repl.it instead
Marianissimus
@Marianissimus
Mar 20 2018 14:25
meaning (while i > 0) {// do something; i--} @ConnectCodes
Chris
@ConnectCodes
Mar 20 2018 14:29
@SweetCodingInc Why repl.it ?
Matej Bošnjak
@mbosnjak01
Mar 20 2018 14:30
while loop is a trouble
Sweet Coding :)
@SweetCodingInc
Mar 20 2018 14:30
@ConnectCodes Easy to run...
and it's has dedicated js section..
Chris
@ConnectCodes
Mar 20 2018 14:41
@mbosnjak01 what do you mean?
Matej Bošnjak
@mbosnjak01
Mar 20 2018 14:43
well I always prefer using if/for instead of while since while loop is infinite if you don't break it manualy
which a lot of people forget to do :P
Chris
@ConnectCodes
Mar 20 2018 15:00
@mbosnjak01 Makes sense, did I do that in my code? :smile: As I undrestod if condition is set corretly while loop is just like a for loop?
Jason Luboff
@JLuboff
Mar 20 2018 15:49
:wave:
Chris
@ConnectCodes
Mar 20 2018 15:56
:wave:
Jason Luboff
@JLuboff
Mar 20 2018 15:56
How's it going?
Chris
@ConnectCodes
Mar 20 2018 15:57
Good good. trying to finish my last challenge, so i can move to frontend projects
you?
Jason Luboff
@JLuboff
Mar 20 2018 15:58
Changing my Atom theme lol Tired of my current one need something different then continuing on with my project
Chris
@ConnectCodes
Mar 20 2018 16:00
ha I started using VSC, dark theme is my go to
Jason Luboff
@JLuboff
Mar 20 2018 16:01
I've been using Seti for syntax and I think atom material for theme but time for a change
Chris
@ConnectCodes
Mar 20 2018 16:05
Cool, one question
Stuck on Exact change challenege”return change in coin and bills, sorted in highest to lowest order."
Jason Luboff
@JLuboff
Mar 20 2018 16:07
Its been a long time since I've worked on that... loong...long time.. lol
Chris
@ConnectCodes
Mar 20 2018 16:08
lol ok
Fabien SHAN
@X140hu4
Mar 20 2018 16:08
@ConnectCodes that one took some time haha. careful about float >.>
Chris
@ConnectCodes
Mar 20 2018 16:09
Yea so float I changed everything to cents
Fabien SHAN
@X140hu4
Mar 20 2018 16:09
that works :)
Chris
@ConnectCodes
Mar 20 2018 16:10
I get two currencies right but rest are wrong I have two while loops but inner doesn’t move to i = 4 dont undrestand why
Arturo Mago
@ArturoMago
Mar 20 2018 16:28
I would like to help please I do not understand this exercise
Jason Luboff
@JLuboff
Mar 20 2018 16:28
@ArturoMago Have you tried anything?
Arturo Mago
@ArturoMago
Mar 20 2018 16:31
Yes, but I really believe that what I have tried does not work for me, since I really do not understand it very well: S
myStorage.inside["glove box"].maps;
Jason Luboff
@JLuboff
Mar 20 2018 16:32
Ok, so thats a good start
Arturo Mago
@ArturoMago
Mar 20 2018 16:32
yes?
Jason Luboff
@JLuboff
Mar 20 2018 16:33
you're correct in starting at myStorage thats the initial object. Next you have inside but, you can't access inside directly from myStorage, as inside is within the car object. So how would you change what you have to reflect that?
Arturo Mago
@ArturoMago
Mar 20 2018 16:34
change inside for car no?
Jason Luboff
@JLuboff
Mar 20 2018 16:34
Well we still need inside
but car would go where you currently have inside (if that makes sense)
Arturo Mago
@ArturoMago
Mar 20 2018 16:35
myStorage.car["inside"] ?
Jason Luboff
@JLuboff
Mar 20 2018 16:37
Yes that works or you could do myStorage.car.inside either one is suitable
So, now, we're inside the inside object and we want to access "globe box" since there is a space, we have to use bracket notation
As a side note, whenever we have a space in the key name or we're using a variable to check for the key name, we must use bracket notation. With dot notation, it is looking for string literals.
Arturo Mago
@ArturoMago
Mar 20 2018 16:39
myStogare.car.inside["glove box];
I have that very clear
what about the square brackets thanks.
Jason Luboff
@JLuboff
Mar 20 2018 16:40
You have a spelling error and a missing " but yes, myStorage.car.inside["glove box"] that will return the value of the key glove box
Arturo Mago
@ArturoMago
Mar 20 2018 16:50
@JLuboff thanks
CamperBot
@camperbot
Mar 20 2018 16:50
arturomago sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2373 | @jluboff |http://www.freecodecamp.org/jluboff
Jason Luboff
@JLuboff
Mar 20 2018 16:54
:+1:
Onome Sotu
@onomesotu
Mar 20 2018 16:59
Hey guys good evening
I have a question on regExp
Do word character include digit characters as well?
Stephen James
@sjames1958gm
Mar 20 2018 17:05
@onomesotu yes a-ZA-Z0-9_
Onome Sotu
@onomesotu
Mar 20 2018 17:06
@sjames1958gm Ok thank you very much
CamperBot
@camperbot
Mar 20 2018 17:06
onomesotu sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9119 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Mar 20 2018 17:39
@onomesotu :+1:
Jason Luboff
@JLuboff
Mar 20 2018 17:42
@sjames1958gm Can I get a quick opinion from you (I know you're probably just on a break)
Onome Sotu
@onomesotu
Mar 20 2018 17:55
Can anyone give ideas about the validation of phone numbers (first exercise in advance algorithm scripting). This is my solution and i feel like i hard coded the entire regex pattern
function telephoneCheck(str) {
  var whiteSpaces = /\s/g;//remove whitespace from the string
  str = str.replace(whiteSpaces, "");

  var regex1 = /^\d{3}\-\d{3}\-\d{4}$/g, 
      regex2 = /^\(\d{3}\)\-\d{3}\-\d{4}$/g, 
      regex3 = /^\(\d{3}\)\d{3}\-\d{4}$/g,
      regex4 = /^1\(\d{3}\)\d{7}$/g,
      regex5 = /^\d{10}$|^1\d{10}$/g,
      regex6 = /^1\(\d{3}\)\d{3}\-\d{4}$/g,
      regex7 = /^1\d{3}\-\d{3}\-\d{4}$/g;



  var regexArray = [regex1, regex2, regex3, regex4, regex5, regex6, regex7];
  for(var i = 0; i < regexArray.length; ++i){
    if(regexArray[i].test(str)){
      return true;
    }
  }

  return false;
}
Can anyone suggest a better way to do this?
Dardan Demiri
@dardandmr
Mar 20 2018 17:57

@onomesotu And you are right you hard coded the solution

But you are close to make the optimal solution

/^(1\s?)?(\(\d{3}\)|\d{3})[\s\-]?\d{3}[\s\-]?\d{4}$/;
Try the regex and Learn in this site:
https://www.regexpal.com/
Onome Sotu
@onomesotu
Mar 20 2018 17:59
:O
Dardan Demiri
@dardandmr
Mar 20 2018 17:59
In the right side you have the Cheat Sheet whitch you can use to learn
Onome Sotu
@onomesotu
Mar 20 2018 17:59
wow.....
Dardan Demiri
@dardandmr
Mar 20 2018 18:00
The key is to use
a+? a{2,}? match as few as possible
@onomesotu But you are on the good path, great work ;)
Onome Sotu
@onomesotu
Mar 20 2018 18:01
Thanks mate @dardandmr
CamperBot
@camperbot
Mar 20 2018 18:01
onomesotu sends brownie points to @dardandmr :sparkles: :thumbsup: :sparkles:
:cookie: 301 | @dardandmr |http://www.freecodecamp.org/dardandmr
Dardan Demiri
@dardandmr
Mar 20 2018 18:01
You are Welcome
Onome Sotu
@onomesotu
Mar 20 2018 18:04
I appreciate the help.. it's just mind blowing how the solution can be a single line
Nate Mallison
@NJM8
Mar 20 2018 18:12
I have a question on my twitch tv project.
The buttons are not going back to their unclicked state after clicking them
https://www.natethedev.com/FreeCodeCampFrontEndProjects/twitchTV/
ninja is currently streaming, click on his channel from the dropdown then click the link to open the channel on twitch, when you come back to my page it still displays the tooltip and clicked styling
My other question is why the top header does not stay responsive. As it collapses the buttons crowd over each other. I used the same row classes for bootstrap flexbox as I did here: https://www.natethedev.com/FreeCodeCampFrontEndProjects/localWeather/
but it doesn't work
maybe because the twitch tv page uses divs?
Onome Sotu
@onomesotu
Mar 20 2018 18:43
@NJM8 for the first question, you have an anchor <a> element, sometimes, they browser adds default styling when a link has been visited
Stephen James
@sjames1958gm
Mar 20 2018 18:44
@JLuboff If you still need one I am available
Jason Luboff
@JLuboff
Mar 20 2018 18:45
@sjames1958gm I was just going to ask your opinion of hidden input fields to hold information, in my case, a personid. Right now I'm attaching it to one of the names of the inputs.. but trying to determine the best way to handle it
Stephen James
@sjames1958gm
Mar 20 2018 18:46
@JLuboff As opposed to holding the data in some js variable?
Jason Luboff
@JLuboff
Mar 20 2018 18:47
@sjames1958gm Yes, the id is being passed from my backend to the frontend via my template engine
Stephen James
@sjames1958gm
Mar 20 2018 18:48
Interesting - not something I am familiar with. A sort of, backdoor data transfer mechanism?
@NJM8 If you have the devtools open and click on that and then come back without going into the page.
You can see that the browser still thinks you are hovering over that field.
Jason Luboff
@JLuboff
Mar 20 2018 18:51
@sjames1958gm Ya sort of I guess lol This would be easier with mongo...but gotta use SQL
Markus Kiili
@Masd925
Mar 20 2018 18:54
:ear:
Nate Mallison
@NJM8
Mar 20 2018 19:11
thanks @sjames1958gm @onomesotu I'll take a look at that. Been struggling with bootstraps flex system, about to throw the computer out the window
CamperBot
@camperbot
Mar 20 2018 19:11
njm8 sends brownie points to @sjames1958gm and @onomesotu :sparkles: :thumbsup: :sparkles:
:cookie: 322 | @onomesotu |http://www.freecodecamp.org/onomesotu
:star2: 9121 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Nate Mallison
@NJM8
Mar 20 2018 19:12
Why does it take a hour of screwing around with bootstraps flex implementation when you can do it with the regular flex system in 3 minutes. :-1:
Ion Varsescu
@Nei-V
Mar 20 2018 20:13
hello, can someone explain me this syntax in javascript: '''var counter = (function() {
var privateCounter = 0;
function changeBy(val) {
privateCounter += val;
}
return {
increment: function() {
changeBy(1);
},
decrement: function() {
changeBy(-1);
},
value: function() {
return privateCounter;
}
};
})();'''
CamperBot
@camperbot
Mar 20 2018 20:13
:bulb: to format code use backticks! ``` more info
Ion Varsescu
@Nei-V
Mar 20 2018 20:15
  1. why is the function in ( ) ;2 what is increment: or decrement: function
(something with colon followed by the function
)
thank you
Jason Luboff
@JLuboff
Mar 20 2018 20:17
@Nei-V Looks like an IIFE
(Immediately-invoked function expression)
increment/decrement are keys in a returned object with respective functions as values to the keys
Sorry, it actually looks like you're returning an object with several keys (increment, decrement, and value)
Ion Varsescu
@Nei-V
Mar 20 2018 20:23
thanks @JLuboff . 1) i'll look into IIFE and 2) isn't an object like this {xxx:xxxx,yyy:yyyy} - It doesn't seem to look like this in the return statement... or is it an object with just one pair, with the value taken by function...the xxxx in my example
CamperBot
@camperbot
Mar 20 2018 20:23
nei-v sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2374 | @jluboff |http://www.freecodecamp.org/jluboff
Jason Luboff
@JLuboff
Mar 20 2018 20:26
No, it's a regular object
return { //open object
increment : function() {changeBy(1) }, //first key/value
decrement : function(){ changeBy(-1)}, //second key/value
value: function(){return privateCounter} //third key/value
} // close object
Ion Varsescu
@Nei-V
Mar 20 2018 20:27
yes, you are absolutely correct :) now I see it
Jason Luboff
@JLuboff
Mar 20 2018 20:35
:+1:
Christopher McCormack
@cmccormack
Mar 20 2018 20:36
:wave:
Jason Luboff
@JLuboff
Mar 20 2018 20:48
@cmccormack Howdy!
Christopher McCormack
@cmccormack
Mar 20 2018 20:49
@JLuboff whatsup mang
Jason Luboff
@JLuboff
Mar 20 2018 20:49
@cmccormack Same ol' same ol. Waiting for the rain to begin. You?
Christopher McCormack
@cmccormack
Mar 20 2018 20:56
Studying hard this week for a test
always fun :(
Jason Luboff
@JLuboff
Mar 20 2018 20:56
What kind of test?
Christopher McCormack
@cmccormack
Mar 20 2018 20:57
Networking stuff, need to get at least up to snuff, been a while since I've messed in the weeds
Jason Luboff
@JLuboff
Mar 20 2018 20:57
:D
Markus Kiili
@Masd925
Mar 20 2018 20:57
Yo.
Jason Luboff
@JLuboff
Mar 20 2018 20:58
Yo
Christopher McCormack
@cmccormack
Mar 20 2018 20:58
@Masd925 yo
Markus Kiili
@Masd925
Mar 20 2018 21:01
I had a tough dive last night in a freediving competition. Held my breath for 6min16s. Did the surface protocol in exactly 15 seconds when the limit is 15 seconds. New competition best for me.
Jason Luboff
@JLuboff
Mar 20 2018 21:01
I can't even hold my breath beyond 20 seconds..
Markus Kiili
@Masd925
Mar 20 2018 21:02
Looking good for the national championships in 3 weeks.
Everyone including the judges were laughing after my dive, because I was so shaky but managed to do the protocol in last two seconds of the regulated 15.
Bit risky, but this was a warm up competition before nationals.
Jason Luboff
@JLuboff
Mar 20 2018 21:06
Do they have rescue people in the water with you while you're doing your dive?
Markus Kiili
@Masd925
Mar 20 2018 21:06
@JLuboff Of course, yes.
Jason Luboff
@JLuboff
Mar 20 2018 21:08
At what point do they say "ok, we need to rescue this person"?
Markus Kiili
@Masd925
Mar 20 2018 21:09
@JLuboff When you don't respond to given signals that are given periodically.
Jason Luboff
@JLuboff
Mar 20 2018 21:09
Got it
Markus Kiili
@Masd925
Mar 20 2018 21:10
Pool disciplines are very safe when such measures are taken.
Jason Luboff
@JLuboff
Mar 20 2018 21:12
I'd imagine so
sigh... I keep forgetting to do JSON.stringify() in my console.log messages
Markus Kiili
@Masd925
Mar 20 2018 21:16
@JLuboff I am trying to learn clojure, which is fun.
Jason Luboff
@JLuboff
Mar 20 2018 21:17
@Masd925 Looks like it has close interactions with Java?
Markus Kiili
@Masd925
Mar 20 2018 21:17
@JLuboff Runs on JVM yes. Modern lisp with focus on functional programming and concurrency.
Has access to the platform so can call java objects and libraries.
Lisp stuff is very interesting, because I have never learned any lisp.
Jason Luboff
@JLuboff
Mar 20 2018 21:21
I've never learned any Java, albeit, C# is similar from my understanding
Markus Kiili
@Masd925
Mar 20 2018 21:22
@JLuboff Syntax at least is very similar. Don't know C# that deeply to say about deeper stuff.
Jason Luboff
@JLuboff
Mar 20 2018 21:22
I believe in the beginning they were extremely similar and over time have gone in different routes
Brad
@bradtaniguchi
Mar 20 2018 21:23
I still don't know the difference, but then I work on Java a lot compared to C# so idk
Jason Luboff
@JLuboff
Mar 20 2018 21:23
I'm surprised that Java is still going strong, I thought there had been a push a while back to start phasing it out or at least not a lot of people were liking it due to security reasons?
Markus Kiili
@Masd925
Mar 20 2018 21:23
@JLuboff It shines on large corporate projects I think.
Brad
@bradtaniguchi
Mar 20 2018 21:24
Yea its HUGE in corporate
I didn't hear about any security issues for Java tho, must not of been major
Markus Kiili
@Masd925
Mar 20 2018 21:25
@JLuboff There were some major problems some years ago.
Jason Luboff
@JLuboff
Mar 20 2018 21:26
Ya I believe what I'm recalling is some years ago indeed (3+?)
Markus Kiili
@Masd925
Mar 20 2018 21:27
In Finland the government told people to remove java from computers and not use java based bank websites. Didn't last too long though.
Brad
@bradtaniguchi
Mar 20 2018 21:27
So like Java7 right?
I heard Java has the financial sector on lockdown too, so im amazed there was security risks. Must be fixed tho
Markus Kiili
@Masd925
Mar 20 2018 21:28
There was some security hole that was fixed.
Jason Luboff
@JLuboff
Mar 20 2018 21:30
There we go
Tiago Correia
@tiagocorreiaalmeida
Mar 20 2018 22:30
hello everyone
so im thinking about building a chat and in this case something close to gitter but I feel a bit lost, I know I will have to use sockets(broadcast..) but other than that I have no idea from where to start.. if someone allready made one and can point a few things would be great
Jason Luboff
@JLuboff
Mar 20 2018 22:31
@tiagocorreiaalmeida While I haven't built one...you'd also need a database
Tiago Correia
@tiagocorreiaalmeida
Mar 20 2018 22:35
yeah but other than those things that come to mind right after you think in a chat I have no idea what to do first :D
I guess I have to start from somewhere and with time make the needed changes and learn with it :D
Jason Luboff
@JLuboff
Mar 20 2018 22:35
Yup!
Tiago Correia
@tiagocorreiaalmeida
Mar 20 2018 22:36
also started a new langauge so I feel close to polyglot :D
Jason Luboff
@JLuboff
Mar 20 2018 22:38
what language?
Tiago Correia
@tiagocorreiaalmeida
Mar 20 2018 22:40
python
Jason Luboff
@JLuboff
Mar 20 2018 22:41
Cool
Brad
@bradtaniguchi
Mar 20 2018 22:53
I know making chat with something like Firebase is actually pretty easy (its a real-time database, so I think it runs off sockets deep down)
Henry
@GitHub-Henry
Mar 20 2018 22:53
Can someone explain the following:
var a1 = [1, 2, 3],
  a2 = [];

[a2[2], a2[0], a2[1]] = a1;

console.log(a2); 
// I expected [3,1,2] but got  [2,3,1]
Brad
@bradtaniguchi
Mar 20 2018 23:00
@GitHub-Henry holy moly thats ugly code
Jason Luboff
@JLuboff
Mar 20 2018 23:02
Lol
Brad
@bradtaniguchi
Mar 20 2018 23:03
Truthfully I don't understand how it works
Jason Luboff
@JLuboff
Mar 20 2018 23:03
I don't either, hence not responding haha
I mean... I'm pretty sure its destructuring
but I don't know really much, if anything, about that
Henry
@GitHub-Henry
Mar 20 2018 23:05
Trying to figure out destructuring
Brad
@bradtaniguchi
Mar 20 2018 23:05
Yea its de-structuring the array but idk how it comes out as 2,3,1
wait..
Jason Luboff
@JLuboff
Mar 20 2018 23:05
It has something to do with specifying the index
Brad
@bradtaniguchi
Mar 20 2018 23:06
[1, 2, 3] => [a2[2], a2[0], a2[1]]
a2[2] == 1
a2[0] == 2
a2[1] == 3
reordered:
a2[0] == 2
a2[1] == 3
a2[2] == 1
thus: [2,3,1]
So Like its backwards, out-side in haha
Jason Luboff
@JLuboff
Mar 20 2018 23:08
That looks roughly right
Henry
@GitHub-Henry
Mar 20 2018 23:08
@bradtaniguchi thank you, appreciate it
CamperBot
@camperbot
Mar 20 2018 23:08
github-henry sends brownie points to @bradtaniguchi :sparkles: :thumbsup: :sparkles:
:cookie: 425 | @bradtaniguchi |http://www.freecodecamp.org/bradtaniguchi
Brad
@bradtaniguchi
Mar 20 2018 23:08
I don't like it tho
Henry
@GitHub-Henry
Mar 20 2018 23:09
it's only for learning
Brad
@bradtaniguchi
Mar 20 2018 23:09
Yea, after figuring that one out it does feel like doing assignments backwards, not sure when Id ever use that
Henry
@GitHub-Henry
Mar 20 2018 23:12
@bradtaniguchi your response is true for your arrow function, but that wasn't the example, the example produces the results as shown without an arrow function, so I'm still wondering about it
Brad
@bradtaniguchi
Mar 20 2018 23:15
no its not a real arrow function that was more of me just saying this goes to this
sorry if I confused you
It made more sense once I flipped it, then imaged the values going into the a2 array
Henry
@GitHub-Henry
Mar 20 2018 23:24
finally clicked, got it now
@bradtaniguchi that was a real head scratcher for a bit
Brad
@bradtaniguchi
Mar 20 2018 23:28
Yea pretty trippy