What's wrong with the .env challenge?

I set the environment variable in the secrets section, the key is MESSAGE_STYLE, and the value is uppercase, but it turns out to be wrong in the console, what’s wrong with it, can you help me with this, thanks!

here is my code: boilerplate-express-1 - Replit

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36

Challenge: Use the .env File

Link to the challenge:

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

this is your code, but you don’t have a variable named uppercase, maybe you wanted a string there?

2 Likes

could you tell me how can I set the variable in the secret section of Replit? I set it like this, key: MESSAGE_STYLE, and value:uppercase, is this OK?

If you input your value into the UI’s field it will automatically format them for you:
Screenshot 2022-05-02 9.48.16 AM

However if you put it into the JSON yourself you probably should write both the keys and values as strings:

{
  "key": "value",
}

In either case though, as was previously said, uppercase is not defined in your program so you need to use a string:

if (process.env.key === "value") {

I input “MESSAGE_STYLE” in the key field and input “uppercase” in the value field, is this right?

Are you entering

MESSAGE_STYLE

or

"MESSAGE_STYLE"

In the input field parenthesis are added automatically, so you don’t need to include them. That’s only if you edit the JSON.

However in your code, you do need to include them in your comparison.

1 Like