"Use the .env File": why doesn't pass?

The challenge is this.

My solution is:

app.get('/json', (req, res) => {
  str = "Hello Json"
  if (process.env.MESSAGE_STYLE === 'uppercase') {
      str = str.toUpperCase();
    }
  res.json({"message": str})
})

To me the code seems correct.

The response on replit is as one expects.

But the challenge’s tests don’t pass.

Can you please tell me why?

when the environment variable is not set to uppercase the message should not change

from previous challenge

Serve the object {"message": "Hello json"} as a response

I can’t understand: is the style of coding the problem?

Even this code:

app.get('/json', (req, res) => {
  if (process.env.MESSAGE_STYLE === 'uppercase') {
      res.json({"message": "Hello Json".toUpperCase()});
    } else {
      res.json({"message": "Hello Json"});
    }
})

doesn’t pass.

I’ll just point this out… the J should be in lower case

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