These are chat archives for FreeCodeCamp/Help

31st
Jan 2018
Matt Hwang
@hwangm
Jan 31 2018 00:02
hey guys - has anybody been working through the FCC beta exercises and noticed it doesn't save your in-progress work unless you complete the challenge?
Darren
@DarrenfJ
Jan 31 2018 01:07
@hwangm i was beta testing it in december and there's a few outstanding issue... it's still being shined up all nice and chrome for release...
@hwangm you can check here to see if it's already logged: https://github.com/FreeCodeCamp/freecodecamp/issues
artbohr
@artbohr
Jan 31 2018 03:13

Hey guys, I uploaded a react+express app to heroku and set a test

app.get('/ping', function (req, res) {
 return res.send('pong');
});

but when I request: herokuUrl.com/ping
I get no response from the api

I'm kinda confused how it works to get an API response in this case?

here is my complete server.js file
const express = require('express');
const bodyParser = require('body-parser')
const cors = require("cors");
const path = require('path');
const app = express();


app.use(express.static(path.join(__dirname, 'build')));
app.use(cors());

app.get('/ping', function (req, res) {
 return res.send('pong');
});

app.get('/', function (req, res) {
  res.sendFile(path.join(__dirname, 'public', 'index.html'));
});

app.listen(process.env.PORT || 8080, () => {
  console.log('Server Started');
});
the response I get is the react page, no matter what I type after the herokuUrl
Alexander Jarman
@HeinousTugboat
Jan 31 2018 03:15
I think because the express.static maybe?
I feel like that should go at the end.
Oh, no.
Nevermind.
curtisadams
@curtisadams
Jan 31 2018 03:24
@hwangm If you go back to previous exercises you have completed and click run text, unlock, they should save.
Claudio Restifo
@Marmiz
Jan 31 2018 03:38
@artbohr do you have a client side navigation (eg: React router?)
artbohr
@artbohr
Jan 31 2018 03:40
@Marmiz I don't, just tried to see how to interact with the server, but react router is for navigating through react pages as a SPA, if I'm not mistaken
Claudio Restifo
@Marmiz
Jan 31 2018 03:41
@artbohr indeed, but could take over your routing so navigating from the client can be picked up by the router instead of the server... but this is not the case
Georgia
@georgiawang5332
Jan 31 2018 03:57
image.png
image.png
Do I practice this right? Or is there a simple way to correct me?
Why es5 sum (50); can call directly = 1275, es6 need console.log (sum (50)); pass value, will be equal to 1275
It is my interpretation of a mistake???
Alexander Jarman
@HeinousTugboat
Jan 31 2018 04:03
I think what you're asking is why doesn't sum(50) show up in the console on the ES6/React one?
Is that right?
Claudio Restifo
@Marmiz
Jan 31 2018 04:04

It doesn't need to console.log, the function will return that value.
so:

sum(50)  // return 1275

The printing in the console is a totally independent functionality

As far as I can tell you are running the first code in a REPL of some kind, so the returned value is showed in the console by default.
While the second example looks more like codepen, where the returning value of function won't be printed in the console.
Georgia
@georgiawang5332
Jan 31 2018 04:06
@HeinousTugboat right
Alexander Jarman
@HeinousTugboat
Jan 31 2018 04:06
That's my thought, yeah. I would suggest running the ES5 version in the ES6 UI.
If you want to verify things like that, you should generally wrap it in a console.log. You won't generally see it return a number like that.
Georgia
@georgiawang5332
Jan 31 2018 04:08
thank u that me think about your explanation
@Marmiz i think (((thank u
Manish Giri
@Manish-Giri
Jan 31 2018 05:02
anyone here active on codewars
Claudio Restifo
@Marmiz
Jan 31 2018 05:03
@Manish-Giri is "i did a couple of challenges once" counts as active?
Xavier Artot
@xavierartot
Jan 31 2018 05:03
I did some
Claudio Restifo
@Marmiz
Jan 31 2018 05:03
never get the hang of those small challenges/taks
I prefer doing projects :)
Manish Giri
@Manish-Giri
Jan 31 2018 05:04
lol
have you written translations for any kata
Claudio Restifo
@Marmiz
Jan 31 2018 05:05
Nope, but must not be simple
need a hand?
Manish Giri
@Manish-Giri
Jan 31 2018 05:06
yeah kind of
I've no idea where to begin, actually
like what's the process
Claudio Restifo
@Marmiz
Jan 31 2018 05:06
well, what language to what. I think that already play a good role
Manish Giri
@Manish-Giri
Jan 31 2018 05:07
Python to Java and JS
maybe to Swift too
Claudio Restifo
@Marmiz
Jan 31 2018 05:07
o.o
well that's how I'd tackle:
1- understand the challenge requirements
2- convert data types (eg the Cpp expects a struct as return - make it expect an object in js)
???
more ????
Manish Giri
@Manish-Giri
Jan 31 2018 05:15
um
okay
lemme give it a shot
@Marmiz thanks
CamperBot
@camperbot
Jan 31 2018 05:15
manish-giri sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1139 | @marmiz |http://www.freecodecamp.org/marmiz
Claudio Restifo
@Marmiz
Jan 31 2018 05:16
@Manish-Giri Well, I was not very useful :)
gl with that :+1:
DM if you need a beta tester later on :)
Manish Giri
@Manish-Giri
Jan 31 2018 05:20
cool will do :smile:
artbohr
@artbohr
Jan 31 2018 05:46
is it ok to run two package.json files like this heroku boilerplate for heroku full stack deployment is suggesting?
also in this case where should I install the packages :D
kinda strange
Matt Hwang
@hwangm
Jan 31 2018 06:44
@DarrenfJ thanks :) I looked on the fcc github and there is an issue logged that is pretty similar
CamperBot
@camperbot
Jan 31 2018 06:44
hwangm sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2368 | @darrenfj |http://www.freecodecamp.org/darrenfj
Sweet Coding :)
@SweetCodingInc
Jan 31 2018 07:46
@artbohr what do you mean to run two package.json files?
Darren
@DarrenfJ
Jan 31 2018 08:06
@hwangm ah cool.. good to know
thanks @hwangm for checking
CamperBot
@camperbot
Jan 31 2018 08:06
darrenfj sends brownie points to @hwangm :sparkles: :thumbsup: :sparkles:
:cookie: 87 | @hwangm |http://www.freecodecamp.org/hwangm
Eric Miller
@ericmiller777
Jan 31 2018 08:07
hey guys
class DisplayMessages extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      input: '',
      messages: []
    };
    this.handleChange = this.handlechange.bind(this);
    this.submitMessage = this.submitMessage.bind(this);
  }
  // add handleChange() and submitMessage() methods here
  handleChange(event){
    this.setState({input: event.target.value});
  };
  submitMessage(){
    this.setState({messages: messages.push(this.state.input),
                  input: ""});
  };
  render() {
    return (
      <div>
        <h2>Type in a new Message:</h2>
        { /* render an input, button, and ul here */ }
        <input type="text" value={this.state.input} onChange={this.handleChange}></input>
        <button onClick={this.submitMessage}></button>
        <ul></ul>
        { /* change code above this line */ }
      </div>
    );
  }
}
can not read property "bind" of undefined
id rather figure out other issue myself, but
that one error is driving me crazy
Claudio Restifo
@Marmiz
Jan 31 2018 08:13
you misspelled handlechange (lowercase C)
    this.handleChange = this.handlechange.bind(this);
Eric Miller
@ericmiller777
Jan 31 2018 08:14
wow
@Marmiz I looked over that so many times....
@Marmiz thanks
CamperBot
@camperbot
Jan 31 2018 08:15
ericmiller777 sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1140 | @marmiz |http://www.freecodecamp.org/marmiz
Yossi Fisch
@yoizfefisch
Jan 31 2018 11:42
Does it make sense to nest an <img> in an <li>?
The <img> visualizes the points made in the preceeding <li>s.
Albert Cardona II
@daddycardona
Jan 31 2018 11:48
sorry I have not been here lately I have been taking up a mini bootcamp but the only thing I am learning so far from it is the github section unfortunately soon I will have to leave again
Lunogen
@Lunogen
Jan 31 2018 12:43
Hello. I have a problem with a this binding
Could someone give me insight ? It's somewhat peculiar
function foo() {
    console.log( this.a );
}

var a = 2;
var o = { a: 3, foo: foo };
var p = { a: 4 };

o.foo(); // 3
(p.foo = o.foo)(); //  Why 2 ?
This is the code i'm having trouble understanding, it's from the YDKJS series by kyle simpson. The last line in particular is what i fail to grasp
Stephen James
@sjames1958gm
Jan 31 2018 13:02
@Lunogen The result of that last assignment is simply a function with no context.
So when you call the function, it assigns the global object as this which has a = 2
@Lunogen That last line results in nothing different than foo()
mayurnagdev123
@mayurnagdev123
Jan 31 2018 13:09

i have started working on simon project and the first major problem that i am facing is getting back the color of the button after it has been randomly selected by the computer…
I guess the problem is with setTimeout() but i have placed it in a function that is outside the for loop…still i havent progressed…

Here is my pen: https://codepen.io/mayurnagdev123/pen/gvpgRW
Any help would be greatly appreciated

Lunogen
@Lunogen
Jan 31 2018 13:19
@sjames1958gm Yes indeed. It all comes from that assignment result being a RHS rather than a LHS, because it's effectively an IIFE. In other words(p.foo = o.foo)() will become (p.foo)(), but because it's an RHS reference, the p.foo reference will get replaced by its value, which is plain foo
Originally, i was confused because i thought it will resort to implicit binding since in my head, the call-site was p.foo. But i was dead wrong
Thank you for your input and your time on this :smile:
CamperBot
@camperbot
Jan 31 2018 13:19
lunogen sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8921 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Jan 31 2018 13:25
@Lunogen :+1: It took me a bit to realize what was going on.
mayurnagdev123
@mayurnagdev123
Jan 31 2018 13:35
did anyone get a solution to the problem that i posted above??i seriously need help or else i would unable to proceed with my project
Bashir Harrell
@bookofbash
Jan 31 2018 14:57
Hey Yall
I am struggling a bit with Everything must be true
for some reason I am getting false
function truthCheck(collection, pre) {
  var i = 0;
  while ( i < collection.length){
      if (collection[i].hasOwnProperty(pre)){
        i+=1;
      }
      if (i !== collection.length){
        return false;
      }
  }
  return true;
}

truthCheck([{"user": "Tinky-Winky", "sex": "male"}, 
            {"user": "Dipsy", "sex": "male"}, 
            {"user": "Laa-Laa", "sex": "female"}, 
            {"user": "Po", "sex": "female"}], "sex");
Can anyone help?
Check if the predicate (second argument) is truthy on all elements of a collection (first argument).
Ken Haduch
@khaduch
Jan 31 2018 15:00
@bookofbash - for the majority of runs, i will not equal collection.length, so you will return false most of the time. I think that if you put else if for the i !== collection.length it will work better.
Kyle Holm
@thekholm80
Jan 31 2018 15:02
also, returning ends function execution
so on the first loop you'll return false and that's the end of it
Ken Haduch
@khaduch
Jan 31 2018 15:02
@mayurnagdev123 - are you still stuck on your exercise that you posted about here: :point_up: January 31, 2018 8:35 AM
Kyle Holm
@thekholm80
Jan 31 2018 15:04
and good morning @khaduch
Ken Haduch
@khaduch
Jan 31 2018 15:04
@thekholm80 - hello there, Kyle - good morning to you, too! :sun_with_face:
Kyle Holm
@thekholm80
Jan 31 2018 15:04
are things getting back to normal in your world?
Ken Haduch
@khaduch
Jan 31 2018 15:07
@bookofbash - and actually, the else if is not really going to help. There has to be another condition that you test for there...
@thekholm80 - somewhat normal, thanks for asking. Still a very warped sense of time and digesting all of the events from the last couple weeks. Good to be back in the position of having a little bit of normalcy, just working on it!
CamperBot
@camperbot
Jan 31 2018 15:08
khaduch sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1681 | @thekholm80 |http://www.freecodecamp.org/thekholm80
Kyle Holm
@thekholm80
Jan 31 2018 15:09
@khaduch hang in there friend
Ken Haduch
@khaduch
Jan 31 2018 15:14
thanks! Just a day at a time....
@bookofbash - working on your basic method of solving this, a couple simple changes will make it work. The condition that you are testing for is that the object (the collection[i] that you are currently looking at) has the property that is named in the variable pre, and that the value is truthy. As long as that condition is true, you can keep going with your loop, so if you determine that the condition is not true, you can just return false, otherwise increment i and the loop condition test will stop the loop when it reaches the end of the array. If you get through the whole loop without finding a false condition, then return true;
Ken Haduch
@khaduch
Jan 31 2018 15:24

@bookofbash - just to put what I was trying to explain into some pseudocode:

var i = 0;
while (i < collection.length) {
    if ( the_test_condition_is_false ) {
        return false;   // because you found something that doesn't match
        // return false  --- this ends the function and thus the loop
    );
    i++;
}
return true;  // because you didn't find a false condition, everything was true

as @thekholm80 pointed out - any return will end what the function was doing, so you can end it immediately if you find a false condition, and if you don't find a false condition, you will get through the entire loop, and then return true; will be the correct return value.

Bashir Harrell
@bookofbash
Jan 31 2018 15:26
@khaduch Let me see
Bashir Harrell
@bookofbash
Jan 31 2018 15:36
@khaduch I feel like maybe using hasOwnProperty may not be the way to go about it. I think I may be even more confused
if (collection[i].hasOwnProperty(pre) == false)
Kyle Holm
@thekholm80
Jan 31 2018 15:38
or just if (!collection[i].hasOwnProperty(pre))
Ken Haduch
@khaduch
Jan 31 2018 15:39
@bookofbash - using .hasOwnProperty tells you that the object actually has the property, so that is one good thing to know. If it has the property, then you have to determine if the value that the property holds is true or false - you want truthy. So there is one way to do this simply, but to go along with your attempt to use .hasOwnProperty, if you have the property, then check the truthiness of the value. If you don't have the property, then you have a false condition.
Bashir Harrell
@bookofbash
Jan 31 2018 16:06
@khaduch Thanks for your help @thekholm80 Thank you too. Looks like my internet is about to cut out. I guess I need to go to bed and look at this again tomorrow
CamperBot
@camperbot
Jan 31 2018 16:06
bookofbash sends brownie points to @khaduch and @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1682 | @thekholm80 |http://www.freecodecamp.org/thekholm80
:star2: 3705 | @khaduch |http://www.freecodecamp.org/khaduch
Darren
@DarrenfJ
Jan 31 2018 16:14
morning fCC
sayin hi before off to the nether regions to test
Ken Haduch
@khaduch
Jan 31 2018 16:15
@DarrenfJ - good morning Darren!
Stephen James
@sjames1958gm
Jan 31 2018 16:16
@DarrenfJ @khaduch :wave:
Kyle Holm
@thekholm80
Jan 31 2018 16:23
@DarrenfJ :wave:
Ken Haduch
@khaduch
Jan 31 2018 16:29
@sjames1958gm :wavy_dash: :wave: :wavy_dash:
ahmed-issa-mohd
@ahmed-issa-mohd
Jan 31 2018 17:13
why web worker does not work on google chrome ?
Henry
@GitHub-Henry
Jan 31 2018 18:52
If anyone has interest in writing async code in a synchronous fashion here's an example https://codepen.io/anon/pen/LQVmJO. It is a wrapper around a generator. Inside the generator it kinda looks like 1. get url data, 2. convert to json, 3. write out, on error write error. It uses a library called co.
Kaz Baig
@kbaig
Jan 31 2018 19:36
@GitHub-Henry how is this different from async/await?
Henry
@GitHub-Henry
Jan 31 2018 19:42
@kbaig actually, they look similar
(async () => {
  try {
    let response = await fetch(url);
    let data = await response.json();
    render(data);
  }
  catch (err) {
    error(err);
  }
})();
artbohr
@artbohr
Jan 31 2018 20:52
@SweetCodingInc if you check the repo I linked you can see that there is one package.json for the backend and another for the frontend
Sweet Coding :)
@SweetCodingInc
Jan 31 2018 20:53
@artbohr right..
artbohr
@artbohr
Jan 31 2018 20:58
@SweetCodingInc so, I don't understand what is the point of that ^^
Alexander Jarman
@HeinousTugboat
Jan 31 2018 23:13
I've got two implementations of a class that runs through an IterableIterator using both promises and async/await.
..in TypeScript, though. :-|