These are chat archives for FreeCodeCamp/HelpJavaScript

26th
Jan 2019
Jason Luboff
@JLuboff
Jan 26 00:00
Is it supposed to render anything? I see the code but nothing on the page
Simon Cordova
@gbsimon87
Jan 26 00:01
I literally just copied and pasted that onto codepen, didn't do any imports, all it needs is react react dom and axios and it should render
Jason Luboff
@JLuboff
Jan 26 00:02
Ah. Got it lol
abraham anak agung
@padunk
Jan 26 00:05
@gbsimon87 you have state of players but you setStateplayersData is it working?
some small refactor if you like
filterPlayerData = players => {
    const playersData = [];

    players.map(player => {
      const { name, username, email, phone, website } = player;
      playersData.push(name, username, email, phone, website);
    });

    this.setState({
      playersData
    });
  };
Simon Cordova
@gbsimon87
Jan 26 00:08
@padunk thanks for taking a look let me check
as to your question, yes setting state to playersData works but I'll be using your deconstruction suggestion :)
abraham anak agung
@padunk
Jan 26 00:11
@gbsimon87 just curious, is React going to create new state with playersData :smile:
Simon Cordova
@gbsimon87
Jan 26 00:13
Ahhh that suggestion won't work in this case as it returns a string, I'd need a key value pair
abraham anak agung
@padunk
Jan 26 00:18
@gbsimon87 yeah, my bad, forgot to add {} playersData.push({name, username, email, phone, website});
Simon Cordova
@gbsimon87
Jan 26 00:19
I tried like that too but came up empty :/
Simon Cordova
@gbsimon87
Jan 26 00:30
@padunk never mind it worked like a charm and saved six lines of code!
abraham anak agung
@padunk
Jan 26 00:41
:thumbsup:
Jason Luboff
@JLuboff
Jan 26 00:43
Well this is annoying.,..I just created a new route test that I expect to fail...but instead just that one test failing, the whole test suite fails
Simon Cordova
@gbsimon87
Jan 26 00:49
lololol
at least that's a step up!
Jason Luboff
@JLuboff
Jan 26 00:51
:(
Oh well.. need to do a bunch of database redesign anyhow so tests will be rewritten for that
Brad
@bradtaniguchi
Jan 26 01:02
Damn prod deployments are scary AF
Nate Mallison
@NJM8
Jan 26 01:29
@bradtaniguchi Did two this week. :tongue:
With all 7 of my users haha
Brad
@bradtaniguchi
Jan 26 01:30
idk if we are much better... but an almost 100% grass-field re-write of whats being deployed makes things very scary
But everything is looking A ok
Nate Mallison
@NJM8
Jan 26 01:35
Eek, that's a lot
Brad
@bradtaniguchi
Jan 26 01:42
It had to be done, but over the hill finally it seems
Pagnito
@Pagnito
Jan 26 03:10
hey what do u guys use for fetch requests, just fetch with a polyfill or a package?
abraham anak agung
@padunk
Jan 26 03:12
axios is pretty good. https://github.com/axios/axios
Brad
@bradtaniguchi
Jan 26 03:12
@Pagnito Angular :P, or axios hehehe
But on pages that have like 1 request only deal and minimal JS, we use vanilla
Pagnito
@Pagnito
Jan 26 03:13
do u guys know axios size in kb?
abraham anak agung
@padunk
Jan 26 03:13
why we call it vanilla btw?
Brad
@bradtaniguchi
Jan 26 03:16
@padunk No libaries/packages/extra stuff
Its like vanilla ice cream...boring hehe
abraham anak agung
@padunk
Jan 26 03:25
But vanilla had some flavor and fragrant tho. not like plain water :smile:
Jason Luboff
@JLuboff
Jan 26 03:52
Vanilla = plain
Pagnito
@Pagnito
Jan 26 03:58
im getting this Unexpected token < in JSON at position 0 out of nowhere
trying to stringify an object
{email: "aaa", password: "aaa"}
oh nvm it wasnt there
Pagnito
@Pagnito
Jan 26 07:31
maybe im not understand this right, but there is a butt load of companies chargin up the ass for web rtc api abtractions?
一名路过的小码农
@MuchiiuByXiaLin
Jan 26 14:10
hello
Kevin Peña
@kebien6020
Jan 26 19:09
@Pagnito Axios minified is about 4.5 kb
image.png
That image shows the full code
Pagnito
@Pagnito
Jan 26 19:10
@kebien6020 thnx
Kevin Peña
@kebien6020
Jan 26 19:20
@gbsimon87 Another small refactoring
  filterPlayerData = players => {
    const playersData = players.map(player => {
      const { name, username, email, phone, website } = player;
      return {name, username, email, phone, website}
    });

    this.setState({
      playersData
    });
  };
Riadh
@KWFE
Jan 26 21:35
hi guys where is the problem here?
function nextInLine(arr, item) {
  // Your code here
  arr.shift();
  arr.push(item);
  return item;  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Christopher McCormack
@cmccormack
Jan 26 21:44
@KWFE heya - you should try to provide the actual issue you are having - are your tests failing? Are you getting an error?
Riadh
@KWFE
Jan 26 21:47
my tests are failling yes
image.png
Christopher McCormack
@cmccormack
Jan 26 21:52
@KWFE can you link the exercise?
My guess is you aren't returning the value expected
Christopher McCormack
@cmccormack
Jan 26 21:53

@KWFE

The nextInLine function should then return the element that was removed.

you are returning item
@KWFE check out the docs for shift and see what it returns
Riadh
@KWFE
Jan 26 21:58
@cmccormack thanks a lot i need to learn much more
function nextInLine(arr, item) {
  // Your code here
  //arr.shift();
  arr.push(item);
  //arr.shift([0]);
  return arr.shift(item);  // Change this line
}


// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
i took 2 hours without finding the solution till you came
Christopher McCormack
@cmccormack
Jan 26 21:59
@KWFE it really does help to read the MDN docs on the different array functions, their parameters, and their return value, especially when you need to use that function
These exercises used to have links to the relevant articles, not sure why they got removed, it was quite helpful
Riadh
@KWFE
Jan 26 22:00
yes they removed them
anyway thanks i'll bother you again soon
Christopher McCormack
@cmccormack
Jan 26 22:16
lol np
Pagnito
@Pagnito
Jan 26 22:49
anyone familiar with webRTC?
Pagnito
@Pagnito
Jan 26 23:42
anyone know how to confugre webpack to not open a new dev server in new new tab if the localhost tab is already open for that port