These are chat archives for FreeCodeCamp/Help

14th
Mar 2019
nsonhouse
@nsonhouse
Mar 14 00:01
@bjorno43 Do you create the table header rows first, then create the populated rows dynamically in the loop?
Bjorn van de Peut
@bjorno43
Mar 14 00:02
@nsonhouse Yes exactly. You only need to create the table once. It's the rows that you need to create dynamicly as you have no idea how many there are at the beginning.
nsonhouse
@nsonhouse
Mar 14 00:03
@bjorno43 And then you can overload a string?
Bjorn van de Peut
@bjorno43
Mar 14 00:03
No you're adding to the string
nsonhouse
@nsonhouse
Mar 14 00:03
@bjorno43 Gotch
@bjorno43 Thanks, im gonna give it a shot. I really appreciate it.
Bjorn van de Peut
@bjorno43
Mar 14 00:04
+= = <table><tbody><tr> ... </tr><tr> ... </tr> etc etc </tbody></table>';
nsonhouse
@nsonhouse
Mar 14 00:04
Gotcha
Bjorn van de Peut
@bjorno43
Mar 14 00:05
Overloading is something completely different and much, much more complicated than what you're doing now. So don't use that name for it unless you know what you're talking about. Other programmers will look very strangely at you, haha

This is overloading:

Class Overloader {
    public function __construct(){
        // something 
    }

    public function __construct(param1){
        // something 
    }

    public function __construct(param1, param2){
        // something 
    }
}

new Overloader();
new Overloader(param);

As you can see, it's something completely different :P

Bjorn van de Peut
@bjorno43
Mar 14 00:11
Basicly it allowes you to instantiate objects with or without a variable amount of parameters
So more easily explained: It allowes you to create the same function multiple times with different amounts of parameters. Depending on the amount of parameters passed along to the function, the matching function will be called. That's called overloading
nsonhouse
@nsonhouse
Mar 14 00:24
@bjorno43 A few years ago, I took a c++ class, and I'm pretty sure the += was used for operator overloading. If I am wrong please correct me.
Bjorn van de Peut
@bjorno43
Mar 14 00:30
@nsonhouse I honestly don't fully understand that concept, but += is the operator here. It'd be my guess that overloading it is something extra you do with that. Don't quote me on it though. The only type of overloading I understand is the one I just explained
nsonhouse
@nsonhouse
Mar 14 00:33
@bjorno43 What is your recommendation with document.createElement to create the table rows, and document.createTextNode for the data?
Bjorn van de Peut
@bjorno43
Mar 14 00:35
I honestly wouldn't use createElement or createTextNode for this. Aside from maybe looking more fancy, it has 0 benefits opposed to just writing the strings out. It's even much more of a hassle as you would have to append each node to the parent constantly
minggege666
@minggege666
Mar 14 02:39
hello
kibablu
@kibablu
Mar 14 07:51
@pdurbin Thanks buddy
Oburusule Dunstan
@alsong
Mar 14 10:39
i am try to change my php code to use mssql from mysql below is the code if ($query->rowCount() > 0) { it works for mysql and when i change to $count = count($query->fetchAll()); i get an error Fatal error: Uncaught PDOException: SQLSTATE[IMSSP]: There are no more rows in the active result set. Since this result set is not scrollable, no more data may be retrieved. so how do i get the row number from mssql query in php
tundeiness
@tundeiness
Mar 14 12:25
Hi guys I need help please. I have 3 task which I solved and was told I passed the sample test cases and I failed the other test cases I cannot see. In one of the tasks this is the data type I was told to work with [73,67,32,30] with constraint that the items in the array should be between 0 and 100 and array length should not be more than 60. That is between 1 and 60. Now I made provisions for these constraints as well as testing if the element are not numbers etc and yet the test mechanism still says I failed it. For now I don't know what else to test for and so I am laying down my complaints here and hoping to hear suggestions as to preparing a better test conditions apart from the one I stated above. Looking forward to your help please. thanks. @Blauelf please help out.
Bjorn van de Peut
@bjorno43
Mar 14 20:37
@alsong $query->rowCount() returns you the number of rows in your resultset after you've already fetched it with fetch() or fetchAll(). So that error is correct. You cannot fetch the rows again if they're already in there. It's up to you to check which row you're processing while looping through the resultset:
$rows = $query->fetchAll(); // The $rows variable here is now an array like any other. Each array index contains 1 row

foreach($rows as $index => $row){
    echo 'This is row: '. $index; // Index here contains the current index of the array, starting with 0
}
Bjorn van de Peut
@bjorno43
Mar 14 20:43
@tundeiness There are a couple of tests you need to do here:
1) Make sure each array element is of integer data type
2) Make sure each integer is BETWEEN 0 and 100 (between does NOT include 0 or 100)
3) Make sure the array length itself is between 1 and 60 (number of array elements). Again, between does not include 1 or 60