These are chat archives for FreeCodeCamp/Help

28th
Jul 2018
Manish Giri
@Manish-Giri
Jul 28 2018 00:20
Visual Studio?
manarsalah
@manarsalah
Jul 28 2018 00:26
@Manish-Giri yes:D
Henry
@GitHub-Henry
Jul 28 2018 01:57
@manarsalah with Visual Studio Community Edition you should be able to code C# immediately after installing. You should be able to download and install.
Xarri Jorge
@xarrijorge
Jul 28 2018 02:30
Heya every, I'm trying to redo my quote generator but can't get the data to fetch. I've tried isomorphic fetch and axios, no effect. You can find the code here: https://codesandbox.io/s/nr2xy5y5m. Any help will be needed.
FYI, I'm redoing them using React.
Kyle Holm
@thekholm80
Jul 28 2018 02:31
image.png
gotta keep an eye on your console
Xarri Jorge
@xarrijorge
Jul 28 2018 02:32
Yeah, this CORs thing has been a constant pain. Any pointers? @thekholm80
Kyle Holm
@thekholm80
Jul 28 2018 02:33
you may just have to try a different api
Xarri Jorge
@xarrijorge
Jul 28 2018 02:34
Damn! Okay. thanks @thekholm80
Christopher McCormack
@cmccormack
Jul 28 2018 02:37
@kodinglife some cool guy here wrote one https://thesimpsonsquoteapi.glitch.me/
Xarri Jorge
@xarrijorge
Jul 28 2018 02:39
Thanks, @cmccormack. I'll try that
@thekholm80 @cmccormack I used a bypass using cors-any-where. Not the most elegant but it gets the job done for now.
Kyle Holm
@thekholm80
Jul 28 2018 02:43
oh good idea
Xarri Jorge
@xarrijorge
Jul 28 2018 02:53
@thekholm80 got it working now. Just need to add the button and twitter link
Kyle Holm
@thekholm80
Jul 28 2018 03:00
good job
love codesandbox.io, that environment is so easy to work with
i cringe doing react in codepen now
Christopher McCormack
@cmccormack
Jul 28 2018 03:02
it does look pretty nice, my muscle memory always goes straight to codepen but I may have to force myself to use codesandbox more
Kyle Holm
@thekholm80
Jul 28 2018 03:02
i need to try repl.it's react environment
i do so much in their node & python3 environs, i love it
Xarri Jorge
@xarrijorge
Jul 28 2018 03:58
@thekholm80 I've used repl.it for Python and node as well. It is great, more reliable than stack blitz for me.
Kyle Holm
@thekholm80
Jul 28 2018 03:58
any time i just want to try something out quick, it's my go-to
hxq514
@hxq514
Jul 28 2018 06:08
help
任务:创建一个链接到http://freecatphotoapp.com的a元素,并用cat photos作为其anchor text(锚点文本
who can teach me?
Xarri Jorge
@xarrijorge
Jul 28 2018 06:09
@hxq514 wanna try that with a little less funky characters?
I can't open the link
Henry
@GitHub-Henry
Jul 28 2018 06:14
hxq514
@hxq514
Jul 28 2018 06:19
求帮忙
@GitHub-Henry @GitHub-Henry
@kodinglife OK
Povilas
@povilasraciunas
Jul 28 2018 08:51
Hi. I think I have encountered issue in challenge "Applied Visual Design: Create a Horizontal Line Using the hr Element" - cannot finish, because one test is failing, although everything is done like it has to be according to task. ~And task is really simple.
Is this a right place to report a possible bug ? :)
May Kittens Devour Your Soul
@diomed
Jul 28 2018 08:55
@povilasraciunas link me the task [and your solution]
which test is failing
May Kittens Devour Your Soul
@diomed
Jul 28 2018 08:56
u said task name is create horizontal line
and gave link to some other task
Povilas
@povilasraciunas
Jul 28 2018 08:56
sorry
second test part fails stating: The hr tag should come between the title and the paragraph.
problem is that <hr> is actually in place, and correctly displayed in result view
May Kittens Devour Your Soul
@diomed
Jul 28 2018 08:58
yep that's true
Povilas
@povilasraciunas
Jul 28 2018 08:59
do I need to report it as bug in some bug-tracking-list or what ?
May Kittens Devour Your Soul
@diomed
Jul 28 2018 09:00
u can report in official repo: https://github.com/freeCodeCamp/freeCodeCamp
under issues
Povilas
@povilasraciunas
Jul 28 2018 09:00
ok sure
thanks :)
May Kittens Devour Your Soul
@diomed
Jul 28 2018 09:00
:thumbsup:
Radi Totev
@raditotev
Jul 28 2018 09:14
Did someone done the functional tests challenge in the 'QA and testing with chai module' recently? I am stuck there fo quite some time now and need some help to move forward.
alpox
@alpox
Jul 28 2018 10:26
@raditotev Go sure to remove the assert.fail() calls
And they wrote it a bit bad for the first test there - the names tested should be Cristoforo and Colombo
Radi Totev
@raditotev
Jul 28 2018 11:38
I've done that already
Radi Totev
@raditotev
Jul 28 2018 11:45
@alpox have you done this challenge and if yes is it passing in freecodecamp?
Anand Potukuchi
@anandpotukchi
Jul 28 2018 12:07
I have a problem
I'm working on the mongo challenges
and the problem being tests don't pass
what do i do now
I'm able to create and retrieve records
from db
Aimée
@Aimee-MacDonald
Jul 28 2018 12:11
HAI!
luccifer00
@luccifer00
Jul 28 2018 12:15
hello, it is posible to store data in a var that will be an array? i am using array.prototype.push() but when i try to make loops i figure out that it isnt an array, it is an object....
is there any method like push() to store data in arrays and not to objects?
May Kittens Devour Your Soul
@diomed
Jul 28 2018 12:29
is it possible to store JS questions in https://gitter.im/FreeCodeCamp/HelpJavaScript
Kyle Holm
@thekholm80
Jul 28 2018 13:03
@Aimee-MacDonald :wave:
Xarri Jorge
@xarrijorge
Jul 28 2018 13:05
@luccifer00 just create and empty array var myArr = [] and use myArr.push(value). no need for prototypes here
luccifer00
@luccifer00
Jul 28 2018 13:06
@kodinglife yhea i did it like that, i use array.prototype, to explain with methos i used...
Xarri Jorge
@xarrijorge
Jul 28 2018 13:07
Can I see the code? And what exactly are you trying to accomplish?
alpox
@alpox
Jul 28 2018 13:11
@raditotev i have done it and its passing
Xarri Jorge
@xarrijorge
Jul 28 2018 13:27
@thekholm80 check out the project here: https://codesandbox.io/embed/nr2xy5y5m?codemirror=1&hidenavigation=1&view=preview. worked on it all of last night.
@thekholm80 :wave:
Kyle Holm
@thekholm80
Jul 28 2018 13:28
@kodinglife looks great. i love clean, minimal design
Xarri Jorge
@xarrijorge
Jul 28 2018 13:29
Thanks @thekholm80. Colors inspired by https://github.com/dracula/dracula-theme
Kyle Holm
@thekholm80
Jul 28 2018 13:29
can i offer 2 suggestions?
Xarri Jorge
@xarrijorge
Jul 28 2018 13:29
Of course
Kyle Holm
@thekholm80
Jul 28 2018 13:30
if you use cursor: pointer on the :hover of your button, it will indicate that the element is clickable
i assume most people aren't as dumb as me, but something to think about
Xarri Jorge
@xarrijorge
Jul 28 2018 13:31
Oh! Yeah. Thanks. Make the UI as intuitive as possible, :wink: @thekholm80
Kyle Holm
@thekholm80
Jul 28 2018 13:31
2nd is since your api call takes so long to execute, you might consider some kind of loading indicator so the user knows that something is happening behind the scenes
i read a study that a user will close your page after some ridiculously short amount of time if nothing is happening during loading, but they'll wait something like 5x as long if there's an indicator
Xarri Jorge
@xarrijorge
Jul 28 2018 13:32
Yeah, I've been thinking about that. Need to find a way to speed up the api call or execute that loading function
Kyle Holm
@thekholm80
Jul 28 2018 13:34
this seems to have some good thoughts. i can't find the study
Xarri Jorge
@xarrijorge
Jul 28 2018 13:35
Aye! I've been looking up a few spinners on NPM already. Looking for simple lightweight ones
Kyle Holm
@thekholm80
Jul 28 2018 13:49
@kodinglife you can just make your own
May Kittens Devour Your Soul
@diomed
Jul 28 2018 14:45
CorruptGenuineModels
Xarri Jorge
@xarrijorge
Jul 28 2018 14:53
Hey, thanks. I was thinking the same thing. Will have a look later. Should be better than adding another dependency to the project.
Radi Totev
@raditotev
Jul 28 2018 17:08
@alpox Can you please have a look at this issue I have created in the repo: freeCodeCamp/freeCodeCamp#17744
image.png
The funny thing is, even the example is failing. This is the result from the log
Vignesh Sivarajah
@vSivarajah
Jul 28 2018 17:18
Hello! How do i get the number of objects within an array ?
Radi Totev
@raditotev
Jul 28 2018 17:19
arr.length
Vignesh Sivarajah
@vSivarajah
Jul 28 2018 17:20
that will return 0 because i have objects within the array.
Radi Totev
@raditotev
Jul 28 2018 17:21
give example
Vignesh Sivarajah
@vSivarajah
Jul 28 2018 17:22
Skjermbilde 2018-07-28 kl. 19.21.50.png
this is what is printed when i do console.log(arr). However, i get 0 when i print console.log(arr.length)
Radi Totev
@raditotev
Jul 28 2018 17:25
yes, array.length will give you the number of objects in the array
Vignesh Sivarajah
@vSivarajah
Jul 28 2018 17:27
For some reason it gives me 0 when it should have returned 65. It even says length : 65 when i only print the array itself.
Moisés Man
@moigithub
Jul 28 2018 17:27
u doing anything else.. besides add .length to ur console.log ?
` <-- backtick
Vignesh Sivarajah
@vSivarajah
Jul 28 2018 17:32
thanks :p
async function printCountries(){
    await getCountries();
    console.log(country_names);

}
  function getCountries(){
    var api = "https://api.nifs.no/countries/";
      $.getJSON(api, function(data){
        for (var i = 0; i < data.length; i++){
            //console.log("country name inserted: "+ data[i].name);
            if(data[i].continent == "Europe"){
                country_names.push({
                 id : data[i].id,
                  name : data[i].name
             });
            }
        }
    });

}
Henry
@GitHub-Henry
Jul 28 2018 17:34
If you use Firefox Developer Edition, you may want to verify what FFDE is sending and doing.
image.png
Radi Totev
@raditotev
Jul 28 2018 17:37
It looks like a racing condition. console.log(country_names); gets printed before await getCountries(); is completed
not completely sure though...
Vignesh Sivarajah
@vSivarajah
Jul 28 2018 17:39
Isnt that the reason why we use await? So that it executes the getCountries() before logging the array ?
Radi Totev
@raditotev
Jul 28 2018 17:42
Not sure how await exactly works.
Moisés Man
@moigithub
Jul 28 2018 17:43
me neither.. but from a quick test.. just did...
since ur getCountries function dont return any Promise.. it will immediatelly be resolved to undefined (implicit return)
making ur await resolve... and step to console.log
on the mean time.. ur getJSON didnt get executed
Vignesh Sivarajah
@vSivarajah
Jul 28 2018 17:46
I think the problem lies within how i push the objects into the array. If i just print the array itself, i get all the elements printed. If i print the length of the array i get 0.
Radi Totev
@raditotev
Jul 28 2018 17:47
I think the result from getCountries() should be the array and then in printCountries(): let countries = await getCountries() and then you should have the correct results
Smootimus
@Smootimus
Jul 28 2018 17:48
:)
Radi Totev
@raditotev
Jul 28 2018 17:51
  function getCountries(){
        var country_names = []
    var api = "https://api.nifs.no/countries/";
      $.getJSON(api, function(data){
        for (var i = 0; i < data.length; i++){
            //console.log("country name inserted: "+ data[i].name);
            if(data[i].continent == "Europe"){
                country_names.push({
                 id : data[i].id,
                  name : data[i].name
             });
            }
        }
    });
       return country_names;
}


async function printCountries(){
    let countries = await getCountries();
    console.log(countries );
}
Moisés Man
@moigithub
Jul 28 2018 17:52

test:

function x(){
   console.log("yo"); 
   setTimeout(()=>console.log("data"), 2000)  // simulate async operation
} 

async function  y(){
   let r = await x();
   console.log("from y", r);
}

after executing y()
result:

yo
from y undefined
Promise {<resolved>: undefined}
data
```

as u can see.. "data" gets "printed" at the end.. without "waiting"(await) for the promise to get resolved first (settimeout)

correct order should be

yo
data
from y undefined

Vignesh Sivarajah
@vSivarajah
Jul 28 2018 17:53
I just did that, it gives exact ouput as my solution. I think that my getCountries function pushes all the elements into one object within the array,giving the array 0
length.
The console.log prints all the elements, however all the elements are stored within an object giving the length of the array 0 for some reason .
Moisés Man
@moigithub
Jul 28 2018 17:54
the solution.. should be return a promise from getCountries function
Vignesh Sivarajah
@vSivarajah
Jul 28 2018 17:55
Thanks :)
Moisés Man
@moigithub
Jul 28 2018 17:57
function x(){
   console.log("yo"); 
  return new Promise((resolve, reject)=>   setTimeout(()=>{console.log("data"); resolve("yay!!!") }, 2000)  )// simulate async operation
} 

async function  y(){
   let r = await x();
   console.log("from y", r);
}
and resolve ONCE u get ur array populated
Radi Totev
@raditotev
Jul 28 2018 17:58
@moigithub nice example, i've learned something new
Vignesh Sivarajah
@vSivarajah
Jul 28 2018 18:00
@moigithub Thanks i have actually learned something new myself, but i dont think i have made myself clear with my question. The array country_names DOES get populated, the problem lies in how i get the length of that array, because the way i store it in the array. Does that make sense ? I am sorry, im quite new to javascript and general programming.
Moisés Man
@moigithub
Jul 28 2018 18:00
  function getCountries(){
        var country_names = []
    var api = "https://api.nifs.no/countries/";

return new Promise( (resolve, reject)=>
      $.getJSON(api, function(data){
        for (var i = 0; i < data.length; i++){
            //console.log("country name inserted: "+ data[i].name);
            if(data[i].continent == "Europe"){
                country_names.push({
                 id : data[i].id,
                  name : data[i].name
             });
            }
        }
   resolve(country_names);  ///<<< pass data to await
    });
 });
}


async function printCountries(){
    let countries = await getCountries();
    console.log(countries );
}
when function passed to await is a promise.. await waits till the promise gets resolved before execute next instruction...
since ur function didnt returned a promise (implicit) undefined was passed/returned.. making await execute next function.. sooo country_named wasnt populated yet
Vignesh Sivarajah
@vSivarajah
Jul 28 2018 18:04
Thanks!! It works now :)
@moigithub
Moisés Man
@moigithub
Jul 28 2018 18:06

since $getJSON returns a promise another way could be

  function getCountries(){
    var api = "https://api.nifs.no/countries/";

     return  $.getJSON(api);

}


async function printCountries(){
    let countries = await getCountries();
    console.log(countries );

       // and do ur data procesing here
    let country_names = countries.filter(c => c.continent ==="Europe")
                             .map( c => ( { id: c.id, name: c.name } ))
}

didnt test.. but i think should work too

Vignesh Sivarajah
@vSivarajah
Jul 28 2018 18:08
Yeah that will work aswell.
Moisés Man
@moigithub
Jul 28 2018 19:37
@raditotev using zombie 4.3.0 works ok
if change to v 6.2.1 it fails... soo probably the methods got renamed
Radi Totev
@raditotev
Jul 28 2018 19:46
@moigithub Thanks a lot dude! I've changed the version to your suggestion and it's all good now.
glitz20
@glitz20
Jul 28 2018 22:56
anybody who knows how to make admin account using express and mongo?