These are chat archives for FreeCodeCamp/Help

11th
Mar 2018
Kyle Holm
@thekholm80
Mar 11 2018 00:00
that's a bit beyond me, sorry. it looks like you have two functions, one is adding the column slugs and the other is removing it, but i'm not sure how those functions are being utilized
if you call up() while slugs exists as a column on table tags you will get that error
Sorin Ruse
@sorinr
Mar 11 2018 02:02
@julicheng "Before modifying a column, be sure to add the doctrine/dbal dependency to your composer.json file." this is what laravel docs say. see their docs here
da8963
@da8963
Mar 11 2018 03:19
Hi, looking for some guidance. I am starting up and learning code. My goal/project I want to do is a workflow management software (like Workfront & Kissflow). This would be a SaaS. What I would like some guidance on is how and where would it be a good place to start a workflow management software?
Ken Haduch
@khaduch
Mar 11 2018 05:12
Hey all - especially for those U.S. based folks - don't forget that Daylight Savings Time starts this weekend - set your clocks ahead an hour if your location makes the switch to DST! I hope that helps...
Norvin Burrus
@ndburrus
Mar 11 2018 10:55
Zentriks
@Zentriks
Mar 11 2018 13:38
Hello i am new to JavaScript learning maybe for 3 months now with some pause. I am practicing functions and objects now and i have some ideas for cars and model of cars so i am little lost how would i declare the var for car object? ty for help
Stephen James
@sjames1958gm
Mar 11 2018 13:45
@Zentriks If Car is a constructor functionl
var car = new Car();
Zentriks
@Zentriks
Mar 11 2018 13:45
yes constructor function! that's it are those ok for beginner to pratice them?
var myCar = new Object();
myCar.make = 'Ford';
myCar.model = 'Mustang';
myCar.year = 1969; like this can i use it also with functions?
Stephen James
@sjames1958gm
Mar 11 2018 14:13
@Zentriks You mean
myCar.start = function() { console.log("vroom"); }
yes it is ok for beginners to practice
Adel
@AdelMahjoub
Mar 11 2018 14:21

@Zentriks the second syntax is supported by almost all modern browsers,

/**
     * @param {string} brand 
     */
    function Car(brand) {
        this.brand = brand;
    }
    Car.prototype.getBrand = function() {
        return this.brand;
    }

    /**
     * SportCar extends Car
     * @param {string} brand 
     * @param {string} engine 
     */
    function SportCar(brand, engine) {
        Car.call(this, brand);
        this.engine = engine;
    }
    SportCar.prototype = Object.create(Car.prototype);
    SportCar.prototype.constructor = SportCar;
    SportCar.prototype.getEngine = function() {
        return this.engine;
    }

Can be written

 class Car {
        constructor(brand) {
            this.brand = brand;
        }

        getBrand() {
            return this.brand
        }
    }

    class SportCar extends Car {
        constructor(brand, engine) {
            super(brand); // Call the parent class constructor
            this.engine = engine;
        }

        getEngine() {
            return this.engine;
        }
    }
@Zentriks the instantiation is the same
 var myCar = new SportCar('bmw', 'V8');
 var hisCar = new SportCar('Shelby', 'V12');

    console.log(myCar.getBrand(), myCar.getEngine(), hisCar.getBrand(), hisCar.getEngine());
Zentriks
@Zentriks
Mar 11 2018 17:14
Ty very much guys, this will help me a lot!
i am learning JS vanila as i want to learn JQuery later or ES6
Adel
@AdelMahjoub
Mar 11 2018 17:16
@Zentriks have you tried js chocolate ?
Kyle Holm
@thekholm80
Mar 11 2018 17:16
lol
Adel
@AdelMahjoub
Mar 11 2018 17:16
@Zentriks haha, just joking
Zentriks
@Zentriks
Mar 11 2018 17:17
Nop :P
alpox
@alpox
Mar 11 2018 17:17
@AdelMahjoub only good with vanille
Adel
@AdelMahjoub
Mar 11 2018 17:17
:smile:
Zentriks
@Zentriks
Mar 11 2018 17:17
I am serious about it :P
Nikola Babanic
@babanic_nikola_twitter
Mar 11 2018 19:44
Hey guys. I am getting some problem with freezing tab on "sum-all-odd-fibonacci-numbers" challenge. First of all, i have noticed that even some simple loop for example for (var i = 0; i < 10; i++) takes to long to finish. When i write some more code while working on a solution, tab getting completely freezed. When i reload page, page getting freezed after 2seconds after reload. I have cleared cache and other stuff on chrome browser.
When i somehow succede to reset code, i skip over on next challenge, and have no problem with freezing or taking too long to respond on simple loops.
Ananiy Vasyura
@avasyura
Mar 11 2018 19:49
Hey guys. Does anyone know if there is a way to link github and FreeCodeCamp to show github contribution squares when you work on FreeCodeCamp challenges?
Aditya
@ezioda004
Mar 11 2018 19:51
@avasyura I dont think so, but if you really want those green square, make an fcc solution repo and add your solutions to it perhaps.
Ananiy Vasyura
@avasyura
Mar 11 2018 19:53
@ezioda004 Thanks!
CamperBot
@camperbot
Mar 11 2018 19:53
avasyura sends brownie points to @ezioda004 :sparkles: :thumbsup: :sparkles:
:cookie: 501 | @ezioda004 |http://www.freecodecamp.org/ezioda004
Norvin Burrus
@ndburrus
Mar 11 2018 19:59
@avasyura This may be helpful: :sparkles:
artbohr
@artbohr
Mar 11 2018 20:30
Hey guys need your help here
this is my code, the problem is, instead of getting a list of users, I get an [object object] "error"
const express = require('express')
const app = express()
const bodyParser = require('body-parser')

const cors = require('cors')

const mongoose = require('mongoose')
mongoose.connect(process.env.MONGO_URI, {useMongoClient: true});

app.use(cors())

app.use(bodyParser.urlencoded({extended: false}))
app.use(bodyParser.json())


app.use(express.static('public'))
app.get('/', (req, res) => {
  res.sendFile(__dirname + '/views/index.html')
});

const userSchema = mongoose.Schema({
  username: {
    type: String,
    required: true
  },
  exercises: [{
    description: String,
    duration: Number
  }] 
});

const User = mongoose.model("User", userSchema);

//routes
app.post('/api/exercise/new-user', (req, res) =>{

  const userForm = new User({username: req.body.username});
  userForm.save();

  res.send({"username": userForm.username, "id" : userForm._id})
});

app.get('/api/exercise/users', (req, res) => {
  User.find({})
    .then(doc=>console.log(doc)
    ).catch(err=> res.send({message: err}))
});

// Not found middleware
app.use((req, res, next) => {
  return next({status: 404, message: 'not found'})
})

const listener = app.listen(process.env.PORT || 3000, () => {
  console.log('Your app is listening on port ' + listener.address().port)
})
da8963
@da8963
Mar 11 2018 20:31
@ndburrus thanks for your help with this, appreciate it
CamperBot
@camperbot
Mar 11 2018 20:31
da8963 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star2: 2182 | @ndburrus |http://www.freecodecamp.org/ndburrus
Norvin Burrus
@ndburrus
Mar 11 2018 20:32
@da8963 you're welcome! enjoy :+1:
artbohr
@artbohr
Mar 11 2018 20:33
users saves in to the database without a problem, but can't find them via the "users" route
Kyle Holm
@thekholm80
Mar 11 2018 20:34
@artbohr it looks like your db call will return all users, is that what you inteneded?
artbohr
@artbohr
Mar 11 2018 20:34
@thekholm80 yes, but it returns [object object] and nothing else

@thekholm80 Your app is listening on port 3000

[object Object]

Kyle Holm
@thekholm80
Mar 11 2018 20:35
have you tried hitting your api endpoint in something like postman or cURL?
postman is my favorite way to debug apis
you'd have to modify your code to send a response, though
artbohr
@artbohr
Mar 11 2018 20:36
@thekholm80 yes, just tried it with postman, it works. but in the browser it doesn't work
Kyle Holm
@thekholm80
Mar 11 2018 20:38
you're talking about /api/exercise/users this route, right? what response are you sending?
artbohr
@artbohr
Mar 11 2018 20:38
@thekholm80 now it works, no idea what happened, ty for the help :D
CamperBot
@camperbot
Mar 11 2018 20:38
artbohr sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1719 | @thekholm80 |http://www.freecodecamp.org/thekholm80
artbohr
@artbohr
Mar 11 2018 20:39
@thekholm80 weird stuff lol
Kyle Holm
@thekholm80
Mar 11 2018 20:39
lol glad you figured it out
artbohr
@artbohr
Mar 11 2018 20:40
@thekholm80 not really, no idea what was it, because I triple checked all the stuff and It should have worked before, but w/e, at least it works now xD
Kyle Holm
@thekholm80
Mar 11 2018 20:40
i can see how that would be frustrating
Stephen James
@sjames1958gm
Mar 11 2018 20:40
@artbohr If you are sending an object that you want as json, use JSON.stringify on it and make sure you set the content type to application/json
Kyle Holm
@thekholm80
Mar 11 2018 20:41
@sjames1958gm help me understand something
while you're here
Stephen James
@sjames1958gm
Mar 11 2018 20:41
    res.setHeader('Content-Type', 'application/json');
    res.send(JSON.stringify({ a: 1 }));
@thekholm80 Sure
Kyle Holm
@thekholm80
Mar 11 2018 20:42
i'm playing with python, and I wrote a class filled with static methods and it made me wonder if I can just use functional programming in python and skip all the oop crap?
i saw something in the docs suggesting they want to make python FP friendly, but most people think of it as an OOP language
Stephen James
@sjames1958gm
Mar 11 2018 20:42
@thekholm80 I am pretty sure you can, I have used few classes in my python programming. Mostly just the ones from the standard libraries
Johnny
@JohnnyBizzel
Mar 11 2018 20:43
@thekholm80 Python has a lambda function
Kyle Holm
@thekholm80
Mar 11 2018 20:43
@JohnnyBizzel that's a bit beyond me at the moment
Stephen James
@sjames1958gm
Mar 11 2018 20:43
functions are first class values in python
Johnny
@JohnnyBizzel
Mar 11 2018 20:44
@thekholm80 nah. You have done () => { code } in JS haven't you?
Kyle Holm
@thekholm80
Mar 11 2018 20:44
yep
oh, lambda = anonymous
?
artbohr
@artbohr
Mar 11 2018 20:46
@thekholm80 yes
Kyle Holm
@thekholm80
Mar 11 2018 20:46

Here’s an example. You can build a function in the normal way, using def, like this:

def square_root(x): return math.sqrt(x)

or you can use lambda:

square_root = lambda x: math.sqrt(x)
interesting
so it has implicit return like an arrow function
Johnny
@JohnnyBizzel
Mar 11 2018 20:47
Yep, that's the one
artbohr
@artbohr
Mar 11 2018 20:47
@sjames1958gm ty for additional tips
CamperBot
@camperbot
Mar 11 2018 20:47
artbohr sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9087 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Kyle Holm
@thekholm80
Mar 11 2018 20:47
@JohnnyBizzel @sjames1958gm thanks
CamperBot
@camperbot
Mar 11 2018 20:47
thekholm80 sends brownie points to @johnnybizzel and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1806 | @johnnybizzel |http://www.freecodecamp.org/johnnybizzel
:star2: 9088 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Johnny
@JohnnyBizzel
Mar 11 2018 20:51
:+1:
Stephen James
@sjames1958gm
Mar 11 2018 20:54
@thekholm80 :100:
Kyle Holm
@thekholm80
Mar 11 2018 20:55
i'm having a hard time with python simply because I keep thinking "this would be so much easier in Node"
Stephen James
@sjames1958gm
Mar 11 2018 20:57
@thekholm80 I get you, node seems much easier to understand, but maybe because I have used it more.
I can never recall the various python APIs
Kyle Holm
@thekholm80
Mar 11 2018 20:57
I'm sure that's the same reason for me. familiarity and experience
Jacob French
@Wingcraftian
Mar 11 2018 22:21
Can anyone help me with arrow functions? I'm suppose to use arrow notation to take in a parameter and return true if the parameter is greater than 20. But I'm suppose to do it all in one line.
Kyle Holm
@thekholm80
Mar 11 2018 22:22
what have you tried?
Jacob French
@Wingcraftian
Mar 11 2018 22:24
isGreaterThanTwenty((<= 20) => true
var isGreaterThanTwenty = (<= 20) =>true
isGreaterThanTwenty >= 20 => true;
with other variations of those
Kyle Holm
@thekholm80
Mar 11 2018 22:24
so the function will be named isGreaterThanTwenty?
Jacob French
@Wingcraftian
Mar 11 2018 22:24
yeah
Kyle Holm
@thekholm80
Mar 11 2018 22:25
the syntax is const funcName = args => valToReturn
or if you're doing a code block
const funcName = args => {
  return valToReturn;
}
if you have more than one argument, you wrap them in ()
eeflores
@eeflores
Mar 11 2018 22:26
args will be the value you'd test to be greater than 20
Kyle Holm
@thekholm80
Mar 11 2018 22:26
const funcName = (argA, argB) => {
  return valToReturn;
}
since you need to do this one line, you'd want the implicit return const isGreaterThanTwenty = x => // figure out if x is greater than 20
remember that comparison operators return a boolean (true/false) value, so your return can simply be x > 20
Jacob French
@Wingcraftian
Mar 11 2018 22:31
Oh ok that last part helped alot forgot the part about comparisons being boolean in themselves
Kyle Holm
@thekholm80
Mar 11 2018 22:31
:+1:
Jacob French
@Wingcraftian
Mar 11 2018 22:31
Thank you
Daniel
@dkapexhiu
Mar 11 2018 22:58
hello! someone online? i have this line of code: location: map.center.lat()+','+map.center.lng()
translated like this in url: location=41.3275459%2C19.8186981999999
actually the , is being translated as %2C.. what can i do to recognize it as ,?
Abdullah
@AbdullahChaudhry
Mar 11 2018 23:46
@dkapexhiu You could use replace
var location ="41.3275459%2C19.8186981999999"
location.replace('%2C', ',')
Daniel
@dkapexhiu
Mar 11 2018 23:52
the problem is that the variable is like this defined: location: map.center.lat()+','+map.center.lng()
how to replace it?