These are chat archives for FreeCodeCamp/HelpFrontEnd

30th
Oct 2018
Geoff George
@geoffdgeorge
Oct 30 2018 01:39
Desperate for some help, y'all. I'm at 15/16 requirements for my product landing page, but when I run the test, it doesn't seem to recognize that my nav links link to the corresponding parts of the page. Does anyone have a moment to take a look and let me know if I've somehow set up my .nav-link class wrong? https://codepen.io/geoffdgeorge/pen/QZZxJK?editors=1000
Christopher McCormack
@cmccormack
Oct 30 2018 02:27
@geoffdgeorge the nav-link class should be on the link not the list item
Geoff George
@geoffdgeorge
Oct 30 2018 03:40
@cmccormack THANK you. That was driving me nuts.
Christopher McCormack
@cmccormack
Oct 30 2018 03:40
@geoffdgeorge :thumbsup: np
it's not well worded and many people make that same exact mistake
Stevegolden12
@Stevegolden12
Oct 30 2018 05:57
@bradley1492 I am not an expert at Git but what you want to do have the git init on the app folder. Also I highly recommend that you change the the name of the app folder to something more relevant on what the project is to make it easier to identify it. If you are going to use git on a more regular basis, take a look at github desktop (there is one for Windows and mac).
@siliconchild Hey Alwin, I have used chart.js before. What is the question?
yozhikvtumane
@yozhikvtumane
Oct 30 2018 07:43
@flyfishingbarbara example just shows you how it should look like, it's not the code example
Dany Din
@danydin
Oct 30 2018 10:37
someone is here?
ehutchllew
@ehutchllew
Oct 30 2018 11:00
@bradley1492 you would git init your root directory, then to add everything use git add . then you'll need to commit with git commit -m "Some message" finally you can push remotely like git push but you'll need to set the upstream branch the first time like git branch push -u origin <Branch Name>
I'm not a git expert either, but that'll cover most of your bases for committing and pushing.
yozhikvtumane
@yozhikvtumane
Oct 30 2018 14:27
app.get('/json' , (req, res) => {

  let response = "Hello Json"; 
  if (process.env.MESSAGE_STYLE === 'uppercase') {
      response = response.toUpperCase()
      res.json({"message": response});
    }
    res.json({"message": response});

});
I can't pass tests with this, what's the problem?
Basic Node and Express challenges
.env
# Environment Config

# store your secrets and config variables in here
# only invited collaborators will be able to see your .env values

# reference these in your code with process.env.SECRET

SECRET=
MADE_WITH=
MESSAGE_STYLE=uppercase
# note: .env is a shell file so there can't be spaces around =
Nicolas Ramirez
@kamatheuska
Oct 30 2018 14:30
@yozhikvtumane can you post a link to your full code and the challenge?
abraham anak agung
@padunk
Oct 30 2018 14:31
message_style value must be string
Nicolas Ramirez
@kamatheuska
Oct 30 2018 14:32
yeap, that looks like it
is the issue
yozhikvtumane
@yozhikvtumane
Oct 30 2018 14:34
you mean in .env?
Nicolas Ramirez
@kamatheuska
Oct 30 2018 14:34
yeah
yozhikvtumane
@yozhikvtumane
Oct 30 2018 14:34
it says it's a string
$ node -e "console.log(typeof(process.env.MESSAGE_STYLE))"
string
Nicolas Ramirez
@kamatheuska
Oct 30 2018 14:35
try MESSAGE_STYLE="uppercase"
stil, I wouldn't declare such a environment variable anyways for that config options
yozhikvtumane
@yozhikvtumane
Oct 30 2018 14:40
no, doesn't work
yozhikvtumane
@yozhikvtumane
Oct 30 2018 14:52
yes
Nicolas Ramirez
@kamatheuska
Oct 30 2018 14:52
@yozhikvtumane ok...
yozhikvtumane
@yozhikvtumane
Oct 30 2018 14:53
The response of "/json" does not change according to MESSAGE_STYLE
Nicolas Ramirez
@kamatheuska
Oct 30 2018 14:53
you have to put your response and the if statement inside your route
inside app.get('/json')
yozhikvtumane
@yozhikvtumane
Oct 30 2018 14:59
to transform the response object’s message
Does it mean the response itself ? not only the value inside the object?
Nicolas Ramirez
@kamatheuska
Oct 30 2018 15:01
?
the object IS the response object
look
yozhikvtumane
@yozhikvtumane
Oct 30 2018 15:04
doesn't work in any way
Nicolas Ramirez
@kamatheuska
Oct 30 2018 15:05

this:


var response = "Hello Json";  

if (process.env.MESSAGE_STYLE === 'uppercase')

must be inside this:

app.get('/json' , (req, res) => {
    // response = response.toUpperCase();
    res.json({"message": "Hello Json".toUpperCase()}); 
  });
}
not the other way around
because
yozhikvtumane
@yozhikvtumane
Oct 30 2018 15:06
I tried both ways
Nicolas Ramirez
@kamatheuska
Oct 30 2018 15:06
when you send a get request to your route, only the code INSIDE your route will get executed
also, you are not responding nothing in the case when MESSAGE_STYLE is NOT uppercase
you can to repond with UPPERCASE in one case, and else with the original respne
response
yozhikvtumane
@yozhikvtumane
Oct 30 2018 15:12
like this?
app.get('/json' , (req, res) => {

  let response = "Hello Json"; 
  if (process.env.MESSAGE_STYLE === 'uppercase') {
      response = response.toUpperCase()
      res.json({"message": response});
    }
    res.json({"message": response});

});
Nicolas Ramirez
@kamatheuska
Oct 30 2018 15:13
yes! almost
yozhikvtumane
@yozhikvtumane
Oct 30 2018 15:14
what's wrong?
Nicolas Ramirez
@kamatheuska
Oct 30 2018 15:14
still, you have to stop the execution of your function after sending your response
I wouldn't call your messsage like that. response makes reference to the response object orres in tthis case.
try avoiding that
yozhikvtumane
@yozhikvtumane
Oct 30 2018 15:24
how do I stop execution? sending response will stop execution, isn't it?
Nicolas Ramirez
@kamatheuska
Oct 30 2018 15:31
a simple return would do the trick
you can do also if (uppercase) { /* send response*/} else { /* send default response */}
yozhikvtumane
@yozhikvtumane
Oct 30 2018 15:41
it works just fine
but doesn't pass the tests
yozhikvtumane
@yozhikvtumane
Oct 30 2018 17:42
I found solution
String should be "Hello json" not "Hello Json"
Christopher
@bradley1492
Oct 30 2018 20:19
@Stevegolden12 Thanks for the tips on git and github desktop yesterday.
I'll for sure change the name of the folder from app, to something else, that's a good idea.
As for github desktop, wouldn't you recommend using git, as that's what's used in most professional situations I think?
@ehutchllew Thanks for the response on my git question yesterday. This pretty much sums up everything I wanted to know.
:)