These are chat archives for FreeCodeCamp/Help

10th
May 2018
idris
@idris12
May 10 2018 00:28
can someone explain what that return value >1 means
_
function isPrime(value) {
for(var i = 2; i < value; i++) {
if(value % i === 0) {
return false;
}
}
return value > 1;
}
Kyle Holm
@thekholm80
May 10 2018 00:29
it will evaluate value > 1 and return either true or false
so basically it says return true if value > 1 else false
idris
@idris12
May 10 2018 00:30
also another question
Can you correct my logic on how i am reading that code cause its confusing to me
does it mean for example lets say value=4;
if(value%2===0) return false
if(value%3==0) return true
so its picks the last one and returns the statement am i right or wrong
Stephen James
@sjames1958gm
May 10 2018 00:35
@idris12 the first one is true 4%2 === 0 so it returns false;
Kyle Holm
@thekholm80
May 10 2018 00:35
for every iteration of the loop, it's going to try dividing value by i. if the result divides evenly (no remainder) then the number isn't prime so it will return false. if it loops through every number without being able to divide without a remainder, then the number is prime so it will return true
idris
@idris12
May 10 2018 00:36
@thekholm80 so it doesnt keep on looping after the first one why?
Kyle Holm
@thekholm80
May 10 2018 00:36
if you've discovered the number isn't prime, why keep testing?
idris
@idris12
May 10 2018 00:37
@thekholm80 i see i guess i see seing it the wrong way i taught it would keep un testing but now i remember that return breaks out the of the loop when the condition is met
Kyle Holm
@thekholm80
May 10 2018 00:38
exactly - once you return the function stops execution
idris
@idris12
May 10 2018 00:46
@thekholm80 how did you become so good at javascript?
Ken Haduch
@khaduch
May 10 2018 00:55
@mehdiamlal - I don't know if anyone answered your question from here :point_up: May 9, 2018 4:52 PM, perhaps in another room, but you can use any CSS with a react project, as long as you can put the classes in the places where they should be, and you include the bootstrap.css, go for it!
Kyle Holm
@thekholm80
May 10 2018 01:01
@idris12 the only way anyone can: practice, practice, practice
idris
@idris12
May 10 2018 01:03
j.PNG
why doesn't this work when am calling the index of the age?
Kyle Holm
@thekholm80
May 10 2018 01:05
var friends = [ this is an array, you want {
you can't access members of an array with dot notation so friends.age won't work
idris
@idris12
May 10 2018 01:09
thanks now i got it
friends[0].drink=friends[0].age[0] >=21 ? "Yes" : "No";
Rakshit Sinha
@sinharaksh1t
May 10 2018 03:25
Hello all, I've found a small typo in one of freeCodeCamp's challenges in the API section. I thought maybe I can contribute by pointing out that so that the dev team at fcc can fix it. However, I have no knowledge of how to go about doing that. Can someone help me with that?
Any help would be greatly appreciated.
Claudio Restifo
@Marmiz
May 10 2018 03:31

@m1anas :scream: mine was pseudo-code. Of course you shouldn't have implemented straight like that.

I'll try to explain in more details so perhaps it's more clear.

In your situation you have 2 functions that does pretti much the same:
1 - fetch some data from a url
2 - get the result and update the state
3 - handle any error that may come.

Instead of having two separate function, you could have written a method that accept a url, and a callback:

const getData = (url, {process, onSuccess, onError}) => fetch(url)
    .then(process)
      .then(onSuccess)
        .catch(onError)

Then I can consume it in my app as (this is a working example that will fetch my repo info from github)

getData('https://api.github.com/users/marmiz/repos', {
  // simple parser for fetch
  process: response => {
    if(response.ok) return response.json();
    else return Promise.reject('something went wrong')
  },
  // now I can do whatever I want specifically for this data
  onSuccess: data => console.log(data),
 // same goes for error
  onError: e => alert(e)
})

the advantage is that I have a generic method that I can re use across the entire app. More reusability, easier to maintain and update as the project goes on.
Length is not important as usability, maintainability and readability.

Hope is more clear now :)

Claudio Restifo
@Marmiz
May 10 2018 03:42
@sinharaksh1t you can search on Github issues if it's already been reported. If not open a new issue, and maybe you can even open a PR and fix it yourself :)
Rakshit Sinha
@sinharaksh1t
May 10 2018 03:44
THank you @Marmiz
CamperBot
@camperbot
May 10 2018 03:44
sinharaksh1t sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1223 | @marmiz |http://www.freecodecamp.org/marmiz
Claudio Restifo
@Marmiz
May 10 2018 03:45
@sinharaksh1t :+1: happy coding :sparkles:
Nazar
@IsaakNazar
May 10 2018 04:59
hey everybody
Claudio Restifo
@Marmiz
May 10 2018 05:34
hey @IsaakNazar :wave:
Nazar
@IsaakNazar
May 10 2018 05:36
@Marmiz hi Claudio, I have DOM quesion
@Marmiz
when you resize window width, and double click on hamburger, and resize back to (>650px) size my top menu disappearing,
codepen
Claudio Restifo
@Marmiz
May 10 2018 05:44
@IsaakNazar that's because you don't remove the 'display: none'
small size: toggle on/off -> gives display none
resize -> still have display:none
Nazar
@IsaakNazar
May 10 2018 05:46
@Marmiz and I need smth like if window.innerWidth > 650 then display block?
or just @media?
Claudio Restifo
@Marmiz
May 10 2018 05:47
@IsaakNazar you can do it with media, or with JS. up to you
Nazar
@IsaakNazar
May 10 2018 05:52
@Marmiz still doesnt work, gotta try via JS
@media screen and (min-width: 651px) {
  .nav_positionfixed {
    display: block;
  }

}
anthonygallina1
@anthonygallina1
May 10 2018 06:12
Is the JS way better on phones?
I think it might be but cant remember why.
Marco Ramos
@TheMarco77
May 10 2018 06:38
Hello all, here with my freeCodeCamp's 1st project and they demostrate to use http://gdurl.com/ for tiny links. I have been working on my project and noticed my image on the website stopped showing so I checked various points and noticed the website is down! ANyone have any other recomendations for tiny links?
Claudio Restifo
@Marmiz
May 10 2018 07:00
@TheMarco77 google has a url shortener https://goo.gl/
lol nope! They will discontinue the service :)
Marco Ramos
@TheMarco77
May 10 2018 07:00
I tried that one
didn't work
I'm hosting from my gDrive
So the link works but it doesn't work from codePen
any ideas?
Claudio Restifo
@Marmiz
May 10 2018 07:05
@TheMarco77 codepen has some restricting policies for images. You're probably better using a plain image hosting service (imgur, flickr, or whatever)
or just use a placeholder image instead of your own :)
Marco Ramos
@TheMarco77
May 10 2018 07:06
that stinks!
This is for my 1st project so has to be hosted
does github have a different way to host images when creating contect on there?
Claudio Restifo
@Marmiz
May 10 2018 07:08
@TheMarco77 I meant: move your image to a hosting service and use that instead of gDrive.
I remember that you cannot use dropbox as well
Marco Ramos
@TheMarco77
May 10 2018 07:09
@Marmiz what about github
Claudio Restifo
@Marmiz
May 10 2018 07:09

does github have a different way to host images when creating contect on there?

you can add them as static asset to your project and then will be served when deployed.

Marco Ramos
@TheMarco77
May 10 2018 07:09
I jave to learn it anyway!
Claudio Restifo
@Marmiz
May 10 2018 07:10
But in all honesty it's your 1st project, don't spend too much time on hostim images. Grab a link from unsplash and use that...
at least that is my 2cents
Marco Ramos
@TheMarco77
May 10 2018 07:11
it's a tribute page
and it means alot to me the message of the page
Claudio Restifo
@Marmiz
May 10 2018 07:12
@TheMarco77 your call. Anyway how's the original link of the gDrive image?
Marco Ramos
@TheMarco77
May 10 2018 07:13
doesn't work and it did yesterday @Marmiz
Claudio Restifo
@Marmiz
May 10 2018 07:14
then something has changed :thought_balloon:
Marco Ramos
@TheMarco77
May 10 2018 07:14
I agree 100%
Claudio Restifo
@Marmiz
May 10 2018 07:14
pen link? and possibly link to the original gDrive image?
Marco Ramos
@TheMarco77
May 10 2018 07:14
stinks
Claudio Restifo
@Marmiz
May 10 2018 07:16
@TheMarco77 you have to change the preferences of the gDrive file. The file points to a /file/ esxtension. It should point to a host/ one at least used to be like that :)
Marco Ramos
@TheMarco77
May 10 2018 07:18
where would I do that?
brb @Marmiz
Claudio Restifo
@Marmiz
May 10 2018 07:21

In settings you should mark that as public. (I dunno if you can do it straight for a single file or you need a folder to be public) and the use that as your img url.

I'm sure a "hosting images from google drive" search will help as well

Marco Ramos
@TheMarco77
May 10 2018 07:21
oh I did that
was working and it just stoped
Vivek Ranjan
@vivekranjan92
May 10 2018 10:46
Hi every one... I need a help..
freecodecamp.PNG
I have created this slider now I want to map some video to it so that user can see the thumbnail and on click it should be able to play the video
can any one help me out?? Any suggestion will be appreciated
Olga
@OStefani
May 10 2018 11:11
@vivekranjan92 you can use video tag
Vivek Ranjan
@vivekranjan92
May 10 2018 12:28
@OStefani thanks but i need to fetch data from cloud and display it dynamically
CamperBot
@camperbot
May 10 2018 12:28
vivekranjan92 sends brownie points to @ostefani :sparkles: :thumbsup: :sparkles:
:cookie: 255 | @ostefani |http://www.freecodecamp.org/ostefani
Olga
@OStefani
May 10 2018 12:37
@vivekranjan92 you can use fetch api for example
Vivek Ranjan
@vivekranjan92
May 10 2018 12:37
yes I have gone through few tutorials and they are suggesting me to use restful api
using which we can fetch the data and display it on to the client site
Olga
@OStefani
May 10 2018 12:39
ok, if you use backend you can use get or request functions if you use node. What exactly help do you need?
Vivek Ranjan
@vivekranjan92
May 10 2018 12:40
Actually I wanted to know how do i connect my div in such a way that it should display the appropriate data
And now I have understood... I will have to use the rest api to get data from the server/cloud and that data I will have to parse and show it on the client site
Olga
@OStefani
May 10 2018 12:42
you can use document.getElementById for example and use fetch api
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
Vivek Ranjan
@vivekranjan92
May 10 2018 12:42
for which i will have to make use of JS, I guess
@OStefani that's great and I appreciate your help. Thanks :smile:
CamperBot
@camperbot
May 10 2018 12:43
vivekranjan92 sends brownie points to @ostefani :sparkles: :thumbsup: :sparkles:
api offline
Vivek Ranjan
@vivekranjan92
May 10 2018 12:43
I will go through this link as well
Charlie
@charlie-magill
May 10 2018 12:45
Hey y'all. Why does bootstrap put so much space between inline elements? Column spacing seems a little excessive doesn't it?
Ken Haduch
@khaduch
May 10 2018 12:57
@charlie-magill - do you have an example that you are looking at?
Ken Haduch
@khaduch
May 10 2018 13:35
@charlie-magill - I'd be interested to see an example of what you are asking about. I think that the spacing usually looks fine?
Aymen
@AymenAlSalem_gitlab
May 10 2018 14:01
Hi everyone :) , I read little about Js/CSS/HTML Preprocessor but i can't figure out the difference between Preprocessor and external script like jquery.min.js. i mean when to use this or this or both specially that i just start working on Quote Machine project .
Ken Haduch
@khaduch
May 10 2018 14:13
@AymenAlSalem_gitlab - I would say that a preprocessor is something (a script, another executable program) that runs once and generates some output that is then more-or-less "static" on the page. For example, there are HTML preprocessors like Pug that use a defined language and syntax that will run and generate HTML that the browser can then use. Something like jQuery is a JavaScript script in itself that runs any time you use a jQuery selector, method, etc. so that is not a preprocessor but a script that runs as you need to use it. For the quote machine, any type of preprocessor probably is not necessary, jQuery is handy for doing the DOM manipulations, but again, not necessary because you can do what you need with "vanilla" JavaScript. OF course, as you get to know more of the interrelated pieces and packages like React, you can come back and make changes to your quote machine as you see fit.
JS
@24KPureHandSome
May 10 2018 14:28
image.png
Aymen
@AymenAlSalem_gitlab
May 10 2018 14:28
thank you so much @khaduch
CamperBot
@camperbot
May 10 2018 14:28
:star2: 3916 | @khaduch |http://www.freecodecamp.org/khaduch
aymenalsalem_gitlab sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
ChamiManal
@ChamiManal
May 10 2018 14:29
I am beginner in jhipster, I generate a program in microservice architecture, I want to integrate authentication by google but I have no idea on how to do that, I already generate uaa and the gateway, any suggest :smile:
JS
@24KPureHandSome
May 10 2018 14:29
how can i hold this special
sign
image.png
i cant find the special sign
how should i deal with it ?
Aita Kane
@aita-kane
May 10 2018 15:18
:pizza: are you talking about htat ?@24KPureHandSome
Muhammad Anas Qasmi
@m1anas
May 10 2018 16:37
@Marmiz Hmm a bit more clear now. But how was my implementation of your code wrong? Or is it right (as my code seems more usable and maintainable now)?
nathan005
@nathan005
May 10 2018 18:12

Looking at the Express.js challenge on the backend

  • fresh IDE ran git command - expressworks returns "command not found" - any help?

seems like this warning may be issue?
npm WARN uninstall not installed in /home/ec2-user/environment/node_modules: "express"

These are the only other issues with install
npm WARN deprecated jade@1.11.0: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated constantinople@3.0.2: Please update to at least constantinople 3.1.1
npm WARN deprecated transformers@2.1.0: Deprecated, use jstransformer
npm WARN deprecated sprintf@0.1.5: The sprintf package is deprecated in favor of sprintf-js.
npm WARN deprecated colors-tmpl@0.1.1: no longer maintained
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

Kyle Holm
@thekholm80
May 10 2018 18:59
hello, /help
Ken Haduch
@khaduch
May 10 2018 19:14
@thekholm80 - hello to you, and everyone who stops by!
Christopher McCormack
@cmccormack
May 10 2018 19:17
@nathan005 not exactly sure what command you ran - that caused your issue
nathan005
@nathan005
May 10 2018 19:34

@cmccormack Step #10 on Build Web Apps with Expressjs

git clone https://github.com/FreeCodeCamp/fcc-expressworks.git && chmod 744 fcc-expressworks/setup.sh && fcc-expressworks/setup.sh && source ~/.profile

Christopher McCormack
@cmccormack
May 10 2018 19:35
@nathan005 try breaking apart each step and entering them manually (split the string on the &&), see which line is causing it
nathan005
@nathan005
May 10 2018 19:43

@cmccormack seems like the last command doesn't work.
source ~/.profile

also step #7 can't be completed as that field doesn't exsist
Think this is related to using AWS Colud9 (what I'm using)

Christopher McCormack
@cmccormack
May 10 2018 19:44
@nathan005 do you have a file ~/.profile?
do a cat ~/.profile and see if you get any text
nathan005
@nathan005
May 10 2018 19:45
@cmccormack nope
Christopher McCormack
@cmccormack
May 10 2018 19:46
alright first make sure when you clone the repo that it shows up where you cloned it. Then make sure there is a setup.sh in the repo
if so you can view the setup.sh file and see what it's doing - it's probably adding some new lines to the .profile file in your home dir
it's possible that it requires the .profile to already exist, maybe try touch ~/.profile then run the setup again
nathan005
@nathan005
May 10 2018 19:50

@cmccormack don't see any ref to profile, but found this - it is definitely the issue.

fcc-expressworks/setup.sh: line 25: cd: /home/ec2-user/workspace: No such file or directory

in the AWS C9 they renamed workspace to environment

Christopher McCormack
@cmccormack
May 10 2018 19:52
:thumbsup:
nathan005
@nathan005
May 10 2018 19:52
@cmccormack should I create a workspace file and let it install there?
Christopher McCormack
@cmccormack
May 10 2018 19:53
just correct it in the setup.sh file
nathan005
@nathan005
May 10 2018 19:59
@cmccormack passed that error, but still doesn't function
Christopher McCormack
@cmccormack
May 10 2018 20:02
@nathan005 that looks good to me
That's pretty much how that all goes, as long as you don't get errors you're probably good to move on
not sure what && source ~/.profile was supposed to do unless there were other steps I can't see
nathan005
@nathan005
May 10 2018 20:05
@cmccormack me either, but it still doesn't work
maybe its something like . ~/.bashrc for Cloud9?
Christopher McCormack
@cmccormack
May 10 2018 20:05
what isn't working?
nathan005
@nathan005
May 10 2018 20:06
the expressworks command
it still returns "bash: expressworks: command not found"
Christopher McCormack
@cmccormack
May 10 2018 20:07
@nathan005 what is the command?
I have all the files, but the script doesn't seem to be registered
Christopher McCormack
@cmccormack
May 10 2018 20:08
try which expressworks
oh sorry
it's a node app
nathan005
@nathan005
May 10 2018 20:09
yeah it returned not in nvm
Christopher McCormack
@cmccormack
May 10 2018 20:11
@nathan005 validate it was installed in /home/ec2-user/.nvm/versions/node/v4.1.2/lib/node_modules/expressworks/expressworks.js
nathan005
@nathan005
May 10 2018 20:12
yeah its there
Christopher McCormack
@cmccormack
May 10 2018 20:12
try running it from there, see if it works
nathan005
@nathan005
May 10 2018 20:14
@cmccormack how would I do that?
I tried running the expressworks.js
and cd to /home/ec2-user/.nvm/versions/node/v4.1.2/lib/node_modules/expressworks/
and running expressworks
is node not installed maybe?
Christopher McCormack
@cmccormack
May 10 2018 20:17
from your logs it looks like it is
try node --version
nathan005
@nathan005
May 10 2018 20:18
v6.14.1
I thought that nvm is node - but it should make the .js file a program and that is what is not happening
Christopher McCormack
@cmccormack
May 10 2018 20:19
hmm I just installed it myself with no issues
try npm install -g expressworks
it should have already done it but try again
all that setup.sh file should have been doing is making sure you're on node > v4
nathan005
@nathan005
May 10 2018 20:20
perfect - that worked,
Thanks
Christopher McCormack
@cmccormack
May 10 2018 20:20
hah np
nathan005
@nathan005
May 10 2018 20:21
should that be added to the instructions on FCC?
Christopher McCormack
@cmccormack
May 10 2018 20:23
they really should have just put the setup.sh as instructions in the exercise instead of making things so opaque
nathan005
@nathan005
May 10 2018 20:25
ok, thanks again