These are chat archives for FreeCodeCamp/HelpFrontEnd

19th
Sep 2017
Moustapha
@moustaflo
Sep 19 2017 00:19

Please help! i'm trying to install npm install async
``
npm ERR! Linux 4.9.17-c9
npm ERR! argv "/home/ubuntu/.nvm/versions/node/v6.11.2/bin/node" "/home/ubuntu/.nvm/versions/node/v6.11.2/bin/npm" "install" "async"
npm ERR! node v6.11.2
npm ERR! npm v3.10.10
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! syscall connect

npm ERR! Error: connect ECONNREFUSED 127.0.0.1:15443
npm ERR! at Object.exports._errnoException (util.js:1020:11)
npm ERR! at exports._exceptionWithHostPort (util.js:1043:20)
npm ERR! at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)
npm ERR! { Error: connect ECONNREFUSED 127.0.0.1:15443
npm ERR! at Object.exports._errnoException (util.js:1020:11)
npm ERR! at exports._exceptionWithHostPort (util.js:1043:20)
npm ERR! at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)
npm ERR! code: 'ECONNREFUSED',
npm ERR! errno: 'ECONNREFUSED',
npm ERR! syscall: 'connect',
npm ERR! address: '127.0.0.1',
npm ERR! port: 15443 }
npm ERR!
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly. See: 'npm help config'

npm ERR! Please include the following file with any support request:
npm ERR! /home/ubuntu/workspace/npm-debug.log
``

Doreen Lu
@ThoughtProvoking
Sep 19 2017 00:31
Hello, I'm trying to move the background using the keyframes rule, but the background isn't moving. Can anyone see what's wrong? https://codepen.io/ThoughtProvoking/pen/QqydGE
Coy Sanders
@coymeetsworld
Sep 19 2017 00:40
I'm not sure if you can move the body
@ThoughtProvoking
I would try moving a div background instead
piteto
@piteto
Sep 19 2017 00:43
@ThoughtProvoking you'll need to give your background a size to be able to use percentages with background-position.
body {
  background: radial-gradient(circle at 0% 50%, black, white);
  background-size: 500vw 200vh;
  animation: 4s linear infinite sky-change;
}
that size is a crazy example, but you get the idea...adjust as needed for the effect you want
Coy Sanders
@coymeetsworld
Sep 19 2017 00:46
or that could be it too
Doreen Lu
@ThoughtProvoking
Sep 19 2017 00:48
OK. I'll try that.
Thanks
Marcus Rogers
@marcusrogers23
Sep 19 2017 02:28
can anyone help with java?
fefo360
@fefo360
Sep 19 2017 03:04
What do you guys use for responsive text ? Em rem or ..?
Toni Shortsleeve
@KoniKodes
Sep 19 2017 03:10
@fefo360 I like to use 'em'. It seems to give me more control because I can calculate based on the set px. And, I'm not very familiar with rem.
Gegiskhan
@gegiskhan
Sep 19 2017 03:10
hello guys. can i have a help on React.js here?
Toni Shortsleeve
@KoniKodes
Sep 19 2017 03:10
Sorry @gegiskhan . I'm in the baby stages of React myself.
Ben Hart
@Benjmhart
Sep 19 2017 03:17
Hey there, just coming back to a project on the wikipedia API after a long hiatus
I think I'm having some trouble with function scope would someone be able to help me out?
iso
@iso1048
Sep 19 2017 03:27
@Benjmhart i will try and help
basically i can't seem to call my wikiSearch function from the console
and my event handler for the enter keystroke keeps coming back as undefined too
sorry, there's a lot broken, I just came back to the project after quitting months ago
Ruchika Sharma
@ruchika90
Sep 19 2017 03:33
@Manish-Giri got it centered, ty!
CamperBot
@camperbot
Sep 19 2017 03:33
ruchika90 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6552 | @manish-giri |http://www.freecodecamp.com/manish-giri
iso
@iso1048
Sep 19 2017 03:35

@Benjmhart

$("#searchBox").keypress(function(e,searchTerm){ if (event.keyCode == 13) {
        e.preventDefault();
        searchTerm = document.getElementById('searchBox').value;
  console.log(searchTerm);

  searchTerm = encodeURI(searchTerm);
  wikiSearch(searchTerm);
};

so you forgot to pass the event-handler (e) into the function. You previously had # when getting the element by Id, so that needed to be removed. Not sure if you need the encodeURI..

(by the way, I am no expert)
Ben Hart
@Benjmhart
Sep 19 2017 03:36
I'm sure I had a good reason in my brain months ago
iso
@iso1048
Sep 19 2017 03:37
@Benjmhart so in your ajax call url, if you request jsonp instead of json, you will see the json in the console - the parameters you are using are not what I used. give me a sec
yeah so i had action=opensearch in my url
Ben Hart
@Benjmhart
Sep 19 2017 03:38
yeah i was looking at stack overflow and someone was saying query was a better choice.
oh ok then
Ben Hart
@Benjmhart
Sep 19 2017 03:39
I'm getting the object on ready.
I just can't call the wikisearch function from the console.
and the object has an error, but I think that's because it only is running a blank search term
which i can't test because I can't call the function from the console
arugh
ok, so there's a problem with how I'm passing my search term
iso
@iso1048
Sep 19 2017 03:44
i've never called a function from the console so can't help you there sorry
Ben Hart
@Benjmhart
Sep 19 2017 03:45
@gothamknight - isn't that what the first like 100 exercises are? it's basically a console
fefo360
@fefo360
Sep 19 2017 03:45
@KoniKodes thanks
CamperBot
@camperbot
Sep 19 2017 03:45
fefo360 sends brownie points to @konikodes :sparkles: :thumbsup: :sparkles:
:cookie: 398 | @konikodes |http://www.freecodecamp.com/konikodes
iso
@iso1048
Sep 19 2017 03:46
@Benjmhart typing myFunction() into the console gives me an error
Ben Hart
@Benjmhart
Sep 19 2017 03:46
is it a not defined error?
iso
@iso1048
Sep 19 2017 03:46
yep
Ben Hart
@Benjmhart
Sep 19 2017 03:49
yeah thats what I got... oh well I'll try some more tomorrow
have a good one, thanks for your time
iso
@iso1048
Sep 19 2017 03:54
no problem
Richard
@rylew0925
Sep 19 2017 06:16
I am stuck on the "Make Object Properties Private" lesson
var Car = function() {
  // this is a private variable
  var speed = 10;

  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

  this.getSpeed = function() {
    return speed;
  };
};

var Bike = function() {

  // Only change code below this line.

};
var gear;

this.setGear = function(x) {
  gear = x;
};
this.getGear = function() {
  return gear;
};

var myCar = new Car();

var myBike = new Bike();
Not sure what I did wrong
Markus Kiili
@Masd925
Sep 19 2017 06:19
@rylew0925 The code you wrote needs to be inside the constructor function. Not after it.
Richard
@rylew0925
Sep 19 2017 06:21
So I move the closing bracket to the very bottom?
Markus Kiili
@Masd925
Sep 19 2017 06:22
@rylew0925 Move it before the myCar and myBike lines.
Richard
@rylew0925
Sep 19 2017 06:23
I didn't work
Markus Kiili
@Masd925
Sep 19 2017 06:24
@rylew0925 Post the code again.
Richard
@rylew0925
Sep 19 2017 06:24

var Car = function() {
  // this is a private variable
  var speed = 10;

  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

  this.getSpeed = function() {
    return speed;
  };
};

var Bike = function() {

  // Only change code below this line.

};
var gear;

this.setGear = function(x) {
  gear = x;
};
this.getGear = function() {
  return gear;
};

var myCar = new Car();

var myBike = new Bike();
Markus Kiili
@Masd925
Sep 19 2017 06:25
@rylew0925 Your constructor still ends here:
var Bike = function() {

  // Only change code below this line.

};
Richard
@rylew0925
Sep 19 2017 06:25
Oh duh
@Masd925 Thanks!
CamperBot
@camperbot
Sep 19 2017 06:26
rylew0925 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4490 | @masd925 |http://www.freecodecamp.com/masd925
linkin-park
@linkin-park
Sep 19 2017 07:46
@rylew0925 hi
Carlos Nah
@RA9
Sep 19 2017 08:31
Hi
GabriRa
@GabriRa
Sep 19 2017 09:40
I have never use node + react/express. How can i use the data I send with express .get()?
santhoshbalaguru001
@santhoshbalaguru001
Sep 19 2017 09:54
i cannot able to add background image
heroiczero
@heroiczero
Sep 19 2017 09:55
@santhoshbalaguru001 missing ; inbackground:url( "https://exp.cdn-hotels.com/hotels/1000000/20000/16200/16135/1c2a3bbe_z.jpg")
Pascal Clanget
@Gh05d
Sep 19 2017 10:19
Anybody else really hated that Twitch.tv Viewer Project? Finally been able to finish it, but it was really a pain in the ass :angry: If anybody wants to check my solution out: https://codepen.io/Gh05d/full/gGaVBo/
heroiczero
@heroiczero
Sep 19 2017 10:21
@Gh05d Well it looks good. Nice Job :+1:
Pascal Clanget
@Gh05d
Sep 19 2017 10:23
@heroiczero thx :smile:
CamperBot
@camperbot
Sep 19 2017 10:23
gh05d sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1749 | @heroiczero |http://www.freecodecamp.com/heroiczero
Elizabeth Paul
@Kowalatam
Sep 19 2017 10:37
@Gh05d looks way better than mine :+1:
Long Nguyen
@longnt80
Sep 19 2017 10:49
@Gh05d what do you hate about it?
Munkhmanlai
@munkhmanlai
Sep 19 2017 10:53

[{"GOV":[
{
"date": "2014-01-01T16:00:00.000Z",
"value": 5800,
"volume": 1
},
{
"date": "2014-01-06T16:00:00.000Z",
"value": 5750,
"volume": 1
},
{
"date": "2014-01-07T16:00:00.000Z",
"value": 5375,
"volume": 56
},
{
"date": "2014-01-08T16:00:00.000Z",
"value": 5600,
"volume": 20
}
],{"MIK":[
{
"date": "2016-01-03T16:00:00.000Z",
"value": 12100,
"volume": 3056
},
{
"date": "2016-01-04T16:00:00.000Z",
"value": 12180,
"volume": 107
},
{
"date": "2016-01-05T16:00:00.000Z",
"value": 12200,
"volume": 1120
},
{
"date": "2016-01-06T16:00:00.000Z",
"value": 12200,
"volume": 2022
}
]}]

I have this JSON file and when you hit search button, it is supposed to search JSON file and "MIK","GOV" will be what is searched, those are company names and when MIK is written and hit search button it is supposed to display the latest price of MIK is there anyone can help me thanks

Pascal Clanget
@Gh05d
Sep 19 2017 10:53
@longnt80 Mostly this fake twitch api that had to be used, because it made really complicated to fetch the data as I needed it and the restrictions from codepen.io. They prevented me from using import/export statements and so I had to use one single state, which was/is also really ugly.
santhoshbalaguru001
@santhoshbalaguru001
Sep 19 2017 11:00
Long Nguyen
@longnt80
Sep 19 2017 11:13
@Gh05d can you give more detail on how to use import/export statement?
For that project of course
Pascal Clanget
@Gh05d
Sep 19 2017 11:16
@longnt80 Well, I wanted to define several components, each with their individual state and import them into my main file. On codepen, you can't can't do this, because you can only import via the settings of a project and - as far as I know - you can't export any components you've written in the same pen. Maybe this link is helpful: http://exploringjs.com/es6/ch_modules.html#sec_basics-of-es6-modules
santhoshbalaguru001
@santhoshbalaguru001
Sep 19 2017 11:18
i created nav bar with background -color :black , its not showing
@Gh05d
@heroiczero
Long Nguyen
@longnt80
Sep 19 2017 11:21
@Gh05d yeah I've used es6 modules in one of my project. So mostly it is for organizing your js, isn't it?
Pascal Clanget
@Gh05d
Sep 19 2017 11:25
Yes, and for managing state. because every component can have it's own state and reacht it around via properties.
@santhoshbalaguru001 Your background image is overlaying it. The only quick fix I can think of now is giving pageone a margin-top: 100px;
tundeiness
@tundeiness
Sep 19 2017 11:59
hi guys i'm a bit confused about the usage of the wikipedia API...the sandbox is confusing can anyone help out?
Renan Teixeira Ferraz
@RTFerraz
Sep 19 2017 12:08
Hi there
Renan Teixeira Ferraz
@RTFerraz
Sep 19 2017 12:51
Do I have to use asynchrony in the Twitch.tv project?
korzo
@korzo
Sep 19 2017 12:52
@RTFerraz sure. ajax calls are async by it's nature
Renan Teixeira Ferraz
@RTFerraz
Sep 19 2017 12:52
@korzo It's working without ajax
I couldn't figure out how to use ajax in the project
korzo
@korzo
Sep 19 2017 12:54
@RTFerraz you have to use callback.
It's function, which is called after ajax returns data from API
In callback you process the data and display them
Renan Teixeira Ferraz
@RTFerraz
Sep 19 2017 12:56
but it's really confusing to use the data from more than one different http request
korzo
@korzo
Sep 19 2017 13:03
@RTFerraz you need chain of callbacks
First callback pass data to second http request and callback from second callback you process final data and display them
Renan Teixeira Ferraz
@RTFerraz
Sep 19 2017 13:07
Do you have some example?
korzo
@korzo
Sep 19 2017 13:09
@RTFerraz
var step_3 = function() {
    c.finish();
};

var step_2 = function(c, b) {
    ajax(c(b.somedata), step_3);
};

var step_1 = function(b, a) {
  ajax(b(a.somedata), step_2);
};

ajax(a, step_1);
Renan Teixeira Ferraz
@RTFerraz
Sep 19 2017 13:13
Thanks @korzo I'll try this here
CamperBot
@camperbot
Sep 19 2017 13:13
rtferraz sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 512 | @korzo |http://www.freecodecamp.com/korzo
Sorin Ruse
@sorinr
Sep 19 2017 13:40
@korzo i don't see the need in having more then just two functions. one that makes the http request and passes the response to the second function that interpret the response
korzo
@korzo
Sep 19 2017 13:48
@sorinr As far as I remember, you need to http requests.
First for profile info, second for channel info, if user is online
Sorin Ruse
@sorinr
Sep 19 2017 13:50
@korzo yes. in the second function in the if clause you can recall the first function passing the url u want that will call back the same function
@korzo with the proper response to be interpreted
@korzo and ofc i would use promises for my first function
Ben Hart
@Benjmhart
Sep 19 2017 13:57
@tundeiness - I'm having trouble with that too, wanna work it out together?
Renan Teixeira Ferraz
@RTFerraz
Sep 19 2017 14:03
Is it better to use jQuery in the ajax request?
korzo
@korzo
Sep 19 2017 14:08
@RTFerraz jQuery is probably easier for ajax
Sorin Ruse
@sorinr
Sep 19 2017 14:09
@RTFerraz jquery syntax its more simple but u can use also vanilla js XMLHttpRequest
Ben Hart
@Benjmhart
Sep 19 2017 14:10
can anyone give me a hand with the wikipedia viewer project? Something is very wrong with how I'm scoping functions
Sorin Ruse
@sorinr
Sep 19 2017 14:11
@Benjmhart can u share a codepen link to see how u did it so far?
@sorinr right now I'm just working on the wikiSearch function - the other stuff is going to be broken but that's the one I care about atm
Sorin Ruse
@sorinr
Sep 19 2017 14:13
@Benjmhart first change keypress event to keyup. keypress does not read the last pressed key
Ben Hart
@Benjmhart
Sep 19 2017 14:14
ok
Renan Teixeira Ferraz
@RTFerraz
Sep 19 2017 14:15
@sorinr @korzo I'll post my code
var usersObj;
var channelsObj;

function Request(){
    for(var i = 0; i < playersList.length; i++){
        var users = new XMLHttpRequest();
        var streams = new XMLHttpRequest();

        var urlStreams = "https://wind-bow.glitch.me/twitch-api/streams/";
        var urlUsers = "https://wind-bow.glitch.me/twitch-api/users/";
        urlUsers += playersList[i];
        urlStreams += playersList[i];

        streams.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
                streamsObj = JSON.parse(this.responseText);
            }
        };

        users.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
                usersObj = JSON.parse(this.responseText);
            }
        };
    }
}
I need to use what is inside streamsObj in the users.onreadystatechange callback
Ben Hart
@Benjmhart
Sep 19 2017 14:19
@sorinr my main problem is that the function is just running on ready and I can't seem to call the API function (wikiSearch) from the console to debug
Renan Teixeira Ferraz
@RTFerraz
Sep 19 2017 14:19
but I don't know how to do this
Munkhmanlai
@munkhmanlai
Sep 19 2017 14:22
is there anyone who can help me out with my JSON problem
i have been trying to figure out for days
stuck
[{"GOV":[
{
"date": "2014-01-01T16:00:00.000Z",
"value": 5800,
"volume": 1
},
{
"date": "2014-01-06T16:00:00.000Z",
"value": 5750,
"volume": 1
},
{
"date": "2014-01-07T16:00:00.000Z",
"value": 5375,
"volume": 56
},
{
"date": "2014-01-08T16:00:00.000Z",
"value": 5600,
"volume": 20
},
{
"date": "2014-01-09T16:00:00.000Z",
"value": 5600,
"volume": 24
},
{
"date": "2014-01-13T16:00:00.000Z",
"value": 5500,
"volume": 1836
},
{
"date": "2014-01-14T16:00:00.000Z",
"value": 5425,
"volume": 115
},
{
"date": "2014-01-15T16:00:00.000Z",
"value": 5500,
"volume": 200
},
{
"date": "2014-01-16T16:00:00.000Z",
"value": 5500,
"volume": 153
},
{
"date": "2014-01-21T16:00:00.000Z",
"value": 5405,
"volume": 135
},
{
"date": "2014-01-23T16:00:00.000Z",
"value": 5405,
"volume": 23
},
{
"date": "2014-01-26T16:00:00.000Z",
"value": 5450,
"volume": 274
}
]
},
{"MIK":[
{
"date": "2016-01-03T16:00:00.000Z",
"value": 12100,
"volume": 3056
},
{
"date": "2016-01-04T16:00:00.000Z",
"value": 12180,
"volume": 107
},
{
"date": "2016-01-05T16:00:00.000Z",
"value": 12200,
"volume": 1120
},
{
"date": "2016-01-06T16:00:00.000Z",
"value": 12200,
"volume": 2022
},
{
"date": "2016-01-07T16:00:00.000Z",
"value": 12210,
"volume": 35
},
{
"date": "2016-01-10T16:00:00.000Z",
"value": 12220,
"volume": 303
},
{
"date": "2016-01-12T16:00:00.000Z",
"value": 12300,
"volume": 25
},
{
"date": "2016-01-14T16:00:00.000Z",
"value": 12300,
"volume": 369
},
{
"date": "2016-01-18T16:00:00.000Z",
"value": 12500,
"volume": 10
},
{
"date": "2016-01-19T16:00:00.000Z",
"value": 12200,
"volume": 67
}
]}]
korzo
@korzo
Sep 19 2017 14:24
@sorinr You don't have to use functions at all and go with Pyramid of doom :)
My point for 3 functions was that's its easier to structure and reuse code.
@RTFerraz Remove loop from function and ad parameters url, callback to function Request
Renan Teixeira Ferraz
@RTFerraz
Sep 19 2017 14:27
@korzo I should put the loop somewhere else then?
Inside another function?
because it loops through this variable
var playersList = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];
korzo
@korzo
Sep 19 2017 14:30
@RTFerraz You can place loop in main script.
Renan Teixeira Ferraz
@RTFerraz
Sep 19 2017 14:31
hmm
Thanks @korzo I'll try this here
CamperBot
@camperbot
Sep 19 2017 14:32
rtferraz sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 514 | @korzo |http://www.freecodecamp.com/korzo
korzo
@korzo
Sep 19 2017 14:33
@munkhmanlai it's better to post your code on gist.
Sorin Ruse
@sorinr
Sep 19 2017 14:36
@RTFerraz for function will loop no matter u get a response or not. take a look at jquery each() function or forEach vannila https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
Jorge
@OrangeKulture
Sep 19 2017 14:43
hey guys
chat room still dead huh
Renan Teixeira Ferraz
@RTFerraz
Sep 19 2017 14:45
@sorinr ok
Sorin Ruse
@sorinr
Sep 19 2017 14:45
@korzo yes i also prefer to use dif functions to separate concern. thats why i said two are just enough. one for http requests and one for interpreting the results
Ben Hart
@Benjmhart
Sep 19 2017 15:06
does CodePen wrap all of our script in an anon function or something?
tundeiness
@tundeiness
Sep 19 2017 15:07
@Benjmhart sure..i will love too...let's do private chat.
Fredrik Strand Oseberg
@FredrikOseberg
Sep 19 2017 15:21
Anone experienced with React here?
piteto
@piteto
Sep 19 2017 15:22
@Benjmhart if you need to capture the value from your input without using a form:
$('#searchBox').on('change', wikiSearch);

function wikiSearch() {
  var searchTerm = $('#searchBox').val();
  // ... the rest of your ajax code below
Ben Hart
@Benjmhart
Sep 19 2017 15:23
@piteto why wouldn't I use a form?
piteto
@piteto
Sep 19 2017 15:24
I would personally use a form, but everyone has their own preferences and I noticed you are not using one.
by "form", I mean the <form> element
Ben Hart
@Benjmhart
Sep 19 2017 15:28
oh, like how I just have a field that's responding to a keyup
forgive me I just took a 9 month hiatus and I'm catching back up, can you parse the code you gave me a bit - and why it's better than keyup?
piteto
@piteto
Sep 19 2017 15:30
@Benjmhart some browsers use e.keyCode, others use e.which, and others use e.charCode
Ben Hart
@Benjmhart
Sep 19 2017 15:30
oh, so your solution is browser independant?
piteto
@piteto
Sep 19 2017 15:30
so, if you use keyup, you need to account for all of those scenarios for browser compatibility
Ben Hart
@Benjmhart
Sep 19 2017 15:30
ok, noted,
piteto
@piteto
Sep 19 2017 15:31
Yes, on change is supported by all browsers. There's a jquery method you can use to account for the different keycodes, let me find it
Ben Hart
@Benjmhart
Sep 19 2017 15:31
so 'change' - is that triggered instantly on blur/enter?
piteto
@piteto
Sep 19 2017 15:32
One of the frutstrating things about learning how to code is that there are several ways to get from point a to point b :)
Yes, correct. On enter, not sure about blur though
Ben Hart
@Benjmhart
Sep 19 2017 15:32
I actually enjoy the creative problem solving aspect - it's just that I neglected this for so long I need to re-learn a lot of the stuff I got decent with before
piteto
@piteto
Sep 19 2017 15:33
I used a <form> in my project and then ran my search function based on the submit event. Some may disagree with that approach because forms are usually used for submitting data to a server
Ben Hart
@Benjmhart
Sep 19 2017 15:33
ok, I think I see what you have going there, ty @piteto
CamperBot
@camperbot
Sep 19 2017 15:33
:cookie: 121 | @piteto |http://www.freecodecamp.com/piteto
benjmhart sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
Ben Hart
@Benjmhart
Sep 19 2017 15:34
and I just realized my context problem, it wasn't my function, it was my console - Didn't realize codepen stuck everything into a different context
piteto
@piteto
Sep 19 2017 15:34
Yeah, good luck :) main thing with this project I think is to figure out how to get data back from an API, parse it, and display it on the page. Learning how to use the API is also part of it. Enterprise-grade browser compatibility is a nitpick
codepen's console is fairly basic
Ben Hart
@Benjmhart
Sep 19 2017 15:34
yeah, i was trying to use dev tools
and dev tools is definitely better for parsing a json
piteto
@piteto
Sep 19 2017 15:35
Yeah, I agree
Ben Hart
@Benjmhart
Sep 19 2017 15:37
now that I'm getting results I just need to parse the arrays properly into 'results' on the page, link it all up to the search code you gave me, and then design the interface.
Fredrik Strand Oseberg
@FredrikOseberg
Sep 19 2017 15:41
I’m working on an application with React. I have a long list of data that when clicked is added to application state held in the root App component. Whenever something is clicked lower down on this list, React triggers a re-render and scrolls to the top of the page. Is there any way to disable the scrolling to the top of the page?
Jan Shah
@JanShah
Sep 19 2017 15:52
@FredrikOseberg try shouldComponentUpdate()
it takes 2 arguments, previous state and current state, you can use any kind of filter to compare the two states and decide if it should trigger an update
return true or false, it has to return one of the two
Fredrik Strand Oseberg
@FredrikOseberg
Sep 19 2017 16:00
@JanShah So if I had an array in state I could check the length of the array in the two arguments and return false if the next state is longer than the other ?
Jan Shah
@JanShah
Sep 19 2017 16:02
@FredrikOseberg yeah, you can compare any two values in your current and previous state and make the decision based on any parameter you want
or just return false if you never want an update automatically
defeats the object probably :)
Fredrik Strand Oseberg
@FredrikOseberg
Sep 19 2017 16:15
Yeah, thanks for the tip. I’ll see if that solves it :)
rscales02
@rscales02
Sep 19 2017 16:40
Anyone working on the twitch.tv app?
piteto
@piteto
Sep 19 2017 16:47
@rscales02 Yes, people are working on it. Sorry, I should have asked in the other room if you needed help with something or if you were just wondering if anyone had finished the project recently.
Yes, people have finished it recently. Yes, people are working on it. :) I finished it a couple of weeks ago
rscales02
@rscales02
Sep 19 2017 16:48
Has anyone gotten the API to return or are you just using the JSON provided?
replace "freecodecamp" at the end with the user you want
rscales02
@rscales02
Sep 19 2017 16:53
there are 3 end points with this?
I guess I have to look back at the challenge more closely...
Sorin Ruse
@sorinr
Sep 19 2017 17:00
@rscales02 calling the .....twitch-api/streams/.... will return you if the streamer is online or not, if not you would probably want to make another call to one of the other endpoints to get the streamer logo or some other info u need
rscales02
@rscales02
Sep 19 2017 17:01
I was wondering why I was getting a successful return with basically no data...
Sorin Ruse
@sorinr
Sep 19 2017 17:04
you can get back a 200 ok response without not valuable response if u put a syntacticaly right question to the api but wrong question :)
@rscales02 hope it makes sense
rscales02
@rscales02
Sep 19 2017 17:07
Thanks @sorinr and @piteto looks like making the twitch app is my project for the next few days
CamperBot
@camperbot
Sep 19 2017 17:07
rscales02 sends brownie points to @sorinr and @piteto :sparkles: :thumbsup: :sparkles:
imperial-isms
@imperial-isms
Sep 19 2017 17:07
Hey, all!
CamperBot
@camperbot
Sep 19 2017 17:07
:star2: 1336 | @sorinr |http://www.freecodecamp.com/sorinr
api offline
imperial-isms
@imperial-isms
Sep 19 2017 17:08
I did well on the Basic JS algorithms, but I'm struggling with the intermediate stuff. Any suggestions on a resource that will help me bridge the gap? Maybe an alternative set of exercises.
Sorin Ruse
@sorinr
Sep 19 2017 17:09
@rscales02 welcome
Ben Hart
@Benjmhart
Sep 19 2017 17:25
@piteto - so using your search code is working for the first search, but not subsequent searches.
piteto
@piteto
Sep 19 2017 17:27
@Benjmhart Scroll down the page after you make your second search
Ben Hart
@Benjmhart
Sep 19 2017 17:27
bah!
piteto
@piteto
Sep 19 2017 17:27
:)
Ben Hart
@Benjmhart
Sep 19 2017 17:27
thanks, gotta clear that div as part of the function
thanks again @piteto
CamperBot
@camperbot
Sep 19 2017 17:27
benjmhart sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
api offline
Renan Teixeira Ferraz
@RTFerraz
Sep 19 2017 17:47
@korzo I don't know how to fix this
rscales02
@rscales02
Sep 19 2017 18:16
Is there a reason that nothing is updating with this? Status should be replaced with "Free Code Camp is OFFLINE" at the moment... codepen
Ben Hart
@Benjmhart
Sep 19 2017 18:33
having some trouble with the random generator on wikipedia API
can anyone help?
Ben Hart
@Benjmhart
Sep 19 2017 18:38
mostly just need to know what prop to use for the URL of the page returned, it's giving me all the links that appear in the article instead
piteto
@piteto
Sep 19 2017 18:49
@rscales02 A couple of hints: your if statement is inside a function function stream() that never gets called and you seem to be mixing up vanilla js and jquery with this syntax: $.getElementById("#status").html("Free Code Camp is OFFLINE");
@Benjmhart There is a single hyperlink you can use for that - when clicked, it will take you to a random wikipedia page - no need to call the api to get a random page
Ben Hart
@Benjmhart
Sep 19 2017 18:51
@piteto but I'm an overachiever and I just figured it out
Koderkid1936
@Koderkid1936
Sep 19 2017 18:51
Hey guys back again with another site, I got reeeaally lazy tward the end because I was hungry I know this needs A LOT!! of improvement but what do you guys think? the original can be found when you click 'home' on the navigation menu, the original incooprates my one is pure CSS and HTML bootstrap 3 : https://codepen.io/Mr_Evers/pen/wrGzzJ
piteto
@piteto
Sep 19 2017 18:51
Haha, overachiever ftw :)
rscales02
@rscales02
Sep 19 2017 18:56
Looks good @Koderkid1936 ! Needs content, but the design is stellar
Koderkid1936
@Koderkid1936
Sep 19 2017 18:58
@rscales02 its not my design I just coded it, anything design wise doesnt really concern me lol here's the originally: https://blackrockdigital.github.io/startbootstrap-blog-home/ thannks for looking through anyway appreciate it
rscales02
@rscales02
Sep 19 2017 19:00
thanks @piteto got it working! It's hard to keep track of what is jquery vs vanilla js sometimes though. Learn by mistakes is about the only way to do it I guess!
CamperBot
@camperbot
Sep 19 2017 19:00
rscales02 sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 125 | @piteto |http://www.freecodecamp.com/piteto
Richard
@rylew0925
Sep 19 2017 19:26
Would someone please explain "reduce()" in plain English?
I meant what each part of this code is doing?
var singleVal = array.reduce(function(previousVal, currentVal) {
  return previousVal - currentVal;
}, 0);
Or at least what its output would look like?
Richard
@rylew0925
Sep 19 2017 19:31
Are "accumulator", "previousVal", and "currentVal" already default values or are they custom made?
piteto
@piteto
Sep 19 2017 19:42
@rylew0925 they're custom variables to help describe their purpose. You could name them anything you want
hmmmm, reduce() in plain english - take an array and reduce it to a single value
Richard
@rylew0925
Sep 19 2017 19:49
@piteto Thank you!
CamperBot
@camperbot
Sep 19 2017 19:49
rylew0925 sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 126 | @piteto |http://www.freecodecamp.com/piteto
aRtoo
@artoodeeto
Sep 19 2017 19:53
hi guys question. i need help. on this code about the heaps algorithm. i called the function inside the for loop and theres if statement inside the for loop. my question is when it goes inside the loop then calls the generate(n-1) will it exit the loop or change the value of n every time it loops while if statement is being executed? im confuse bros. need help. im trying to trace it on paper and im always stuck on that part i dont know which is to move. thnaks.
function generate(n) {
    if(n===1 && !regex.test(str.join(''))) {
      check.push(str.join(''));
    } else {
      for(var i=0; i<n; i++) {
        generate(n-1);
        if(n % 2 === 0 ) {
          swaper(i,n-1);
        } else {
          swaper(0,n-1);
        }
      }
    }
  }
  generate(3);
Jorge
@OrangeKulture
Sep 19 2017 20:04
hey guys
whats happening
@artoodeeto problem is, you shouldnt call a function inside a loop
aRtoo
@artoodeeto
Sep 19 2017 20:06
@OrangeKulture bro i dont know with heap but his doing it right
piteto
@piteto
Sep 19 2017 20:06
@artoodeeto in your example, you call generate(3) and your for loop calls generate(3-1) which is generate(2). Then you get generate(2-1) which is ends up pushing your joined string to your check array
Jorge
@OrangeKulture
Sep 19 2017 20:06
also im not sure what algo you mean
aRtoo
@artoodeeto
Sep 19 2017 20:06
@OrangeKulture check this pseiudocode bro https://en.wikipedia.org/wiki/Heap%27s_algorithm
piteto
@piteto
Sep 19 2017 20:07
calling a function inside a loop in this case is perfectly fine - a function is just a set of instructions like the rest of code that's already inside the loop
Jorge
@OrangeKulture
Sep 19 2017 20:07
recursion is a bitch dude
on that link u sent me .. theres a non recursive way too
aRtoo
@artoodeeto
Sep 19 2017 20:08
@piteto bro that doesnt make sense so ur telling me it will call generate function first before forloop?
@OrangeKulture hahahaha. bro go to sleep.
piteto
@piteto
Sep 19 2017 20:08

my question is when it goes inside the loop then calls the generate(n-1) will it exit the loop or change the value of n every time it loops

it changes the value of n every time it loops

aRtoo
@artoodeeto
Sep 19 2017 20:09
@piteto basically it will go out the loop when it calls generate function?
Jorge
@OrangeKulture
Sep 19 2017 20:09
it is not perfectly fine .. u have to deal with recursion for sure
piteto
@piteto
Sep 19 2017 20:09
you can only exit a loop with a break or return statement
dealing with recursion does not preclude the use of a function inside a loop though
korzo
@korzo
Sep 19 2017 20:10
@RTFerraz Sorry, I was away. did you fix it?
aRtoo
@artoodeeto
Sep 19 2017 20:10
@piteto bro i can exit the loop when the condition in my for loop is wrong like i<n
piteto
@piteto
Sep 19 2017 20:12
That's the condition for the loop, i guess you could call it an exit, but usually we refer to exiting a loop as ending it prematurely
recursion can be hard to visualize...
korzo
@korzo
Sep 19 2017 20:16
I would say loop is redundant when using recursion
piteto
@piteto
Sep 19 2017 20:16
@artoodeeto maybe easier to see with a simpler example:
function fibonacci(n) {
  if (n <= 1) return 1;
  return fibonacci(n - 1) + fibonacci(n - 2);
}
korzo
@korzo
Sep 19 2017 20:17
@piteto You beat me to it :)
piteto
@piteto
Sep 19 2017 20:17
loops can be redundant when using recursion, functions can be bad inside of loops, all of that is true
haha :)
that simpler example unfortunately is super slow compared to a non-recursive approach
Jorge
@OrangeKulture
Sep 19 2017 20:20
that was my point, if you are aware of all of this, you can definitely do functions and loops .. my point is that, whoever asked, was clearly not .. heaps doesn't really apply because the function called is not complex, but if you are working on something a lot bigger, could lead to some trouble
thats my opinion tho, im not saying is set in stone
aRtoo
@artoodeeto
Sep 19 2017 20:23
@piteto bro i dont know if its bad or not but on heaps algo it worked i just followed the psuedocode but it didnt really explain how it works just the conditions
piteto
@piteto
Sep 19 2017 20:26
@artoodeeto all I can say is that it's recursion - understanding simpler recursive functions may be a good place to start
aRtoo
@artoodeeto
Sep 19 2017 20:26
@OrangeKulture bro i never said i knew the functions and loop. and it doesnt matter if its complex or not it said recursive is more clearer to understand for proffessional maybe
piteto
@piteto
Sep 19 2017 20:28
I think Jorge may be able to help you out better with this - he used the same recursive algorithm in his solution to that challenge
aRtoo
@artoodeeto
Sep 19 2017 20:29
bro i can do simple recursion but this. this recursion inside a loop is damn hard to understand. i dont know if it holds the stack. lets say n=3. goes inside the for loop. then stacks n. so n=2; n=1; n=0 for the first loop. takes out the stack n=2 and loops again and stacks another values.
Jorge
@OrangeKulture
Sep 19 2017 20:29
i tried asking what was the algo called .. cant remember
Engjell Bislimi
@Engjell00
Sep 19 2017 20:30
Hello guys I have a question is there a way I can take 3 picture to size them about the same size !?
Jorge
@OrangeKulture
Sep 19 2017 20:31
what do u mean? @Engjell00 u mean to render in a page?
Engjell Bislimi
@Engjell00
Sep 19 2017 20:32
yes! I think its ugly that my 3 pictures aren't the same size and also they dont have a margin in between because they are taking all the width
so I want them a little smaller but also the same size
Jorge
@OrangeKulture
Sep 19 2017 20:36
yeah u need to use CSS for that dude ..
@Engjell00 ^
oh wow .. the pink they have for a msg not sent is quite intense ..
Engjell Bislimi
@Engjell00
Sep 19 2017 20:37
I already know that. but If I resize one picture with the same weightxheight as the other one. It doesn't looks clean and also it looks ugly
Jorge
@OrangeKulture
Sep 19 2017 20:39
can i see the code?
are you working on codepen?
Michael Oliver
@Michael3353
Sep 19 2017 20:48
@Michael3353
ok. So....
Im ooking for a developer.. front end. and maybe a little php. for a project. It will be unpaid work. But, profits will be shared equally.
im looking*
must have active interest in,
-html5/css3
-PlayStation
-Communities
-Growing a website
if where possible. private message me. as ill be off to bed soon.
Richard
@rylew0925
Sep 19 2017 21:17
How come this code doesn't print out the "val"?
var oldArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

var newArray = oldArray.filter(function(val) {
    return val < 6;
});

console.log(newArray);
monkeyfingerz
@monkeyfingerz
Sep 19 2017 21:20
it prints 1,2,3,4,5 on my console
Richard
@rylew0925
Sep 19 2017 21:20
If I was to write it onto a decoder platform, what would I need to do in order to run it?
The "console.log(newArray)" did not seem to print out anything
piteto
@piteto
Sep 19 2017 21:47
@rylew0925 Click on this link and copy/paste your code into the "JS" window - it will output the results in the "Console" window: https://codepen.io/pen?editors=0012
Richard
@rylew0925
Sep 19 2017 21:59
@piteto Thanks!
CamperBot
@camperbot
Sep 19 2017 21:59
rylew0925 sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 127 | @piteto |http://www.freecodecamp.com/piteto
GabriRa
@GabriRa
Sep 19 2017 22:36
Hey! I have one question. I have one big div inside a little div so there is some overflow
Richard
@rylew0925
Sep 19 2017 22:37
Does the output for splitting a string assigns a comma in its place by default?
GabriRa
@GabriRa
Sep 19 2017 22:37
Its there any way of "scroll" the big div using javascript?
Engjell Bislimi
@Engjell00
Sep 19 2017 22:38
@piteto thank you! sorry for late reply
CamperBot
@camperbot
Sep 19 2017 22:38
engjell00 sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 128 | @piteto |http://www.freecodecamp.com/piteto
Moisés Man
@moigithub
Sep 19 2017 22:41
set position absolute on ur inner div.. then u can play with top bottom left right properties
and set position relative to ur outside div @GabriRa
Engjell Bislimi
@Engjell00
Sep 19 2017 22:44
Hello guys, Is there any way I could show my website? I'm not sure with Codepen since I have 3 html pages
I use Sublime Text !
GabriRa
@GabriRa
Sep 19 2017 22:46
@moigithub yeah, but it makes it a little awful as I can't do a transition on those properties, right?
Moisés Man
@moigithub
Sep 19 2017 22:48
what about using transform:translate? @GabriRa
GabriRa
@GabriRa
Sep 19 2017 22:50
@moigithub You are totally right, this little things that I should know kills me
@moigithub Thanks!
CamperBot
@camperbot
Sep 19 2017 22:50
gabrira sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3635 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Sep 19 2017 22:52
plnkr.co allows u create many files (similarto codepen)
or host on github pages @Engjell00
Engjell Bislimi
@Engjell00
Sep 19 2017 22:54
SO I need to copy past all my code in there?