Use the .env File challenge. If condition to print uppercase not working in repl

Tell us what’s happening:
I am trying to get response from if condition but only else block is getting executed.

Your project link(s)

solution: https://replit.com/@tejansingh1/boilerplate-express#myApp.js

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0.

Challenge: Use the .env File

Link to the challenge:

Welcome there,

This is similar to:

Essentially, you are not following this part of the instructions:

Then, in the /json GET route handler…

Hope this helps

1 Like

I tried making the changes but its still ignoring the if condition and giving me the else condition. Can you please check for once where exactly I am wrong please.

This has to be “in the /json GET route handler”:

const mySecret = process.env['MESSAGE_STYLE']

Think about when the script runs…

  1. Script is executed from top to bottom
  2. mySecret is defined as being 'uppercase'
  3. app is defined with what to do when certain requests are made

If I make a request, it does not matter when or how, the value of mySecret has been set in stone, because const mySecret = ... only runs once (on initial start-up). No matter how many times I make a request which causes the callback function to run in the route handler, the if condition will always be true.

Hope this clarifies

1 Like

Thank you soo much for helping and taking time to explain me things. I have passed the test and completed the module.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.