Use the .env File - The response of "/json" does not change according to MESSAGE_STYLE

I have been working on this for hours and read so many forum but can’t figure out why I still get the error message.

Here is my code:


/** 1) Meet the node console. */
console.log("Hello World")

/** 2) A first working Express Server */
// app.get("/", function(req, res) {
// res.send("Hello Express");
  
// });
/** 3) Serve an HTML file */
app.get("/", function(req, res) {
  res.sendFile(__dirname + "/views/index.html");
  
});
/** 4) Serve static assets  */
 app.use(express.static(__dirname + "/public"));
/** 5) serve JSON on a specific route */
  // app.get("/json", function(req, res) {
  //       res.json({"message": "Hello json"});
  // });

/** 6) Use the .env file to configure the app */
  
app.get("/json" , function(req, res) {
  let message = {"message": "Hello json"};
  if (process.env.MESSAGE_STYLE = "uppercase") {
    message.message = message.message.toUpperCase()
    }
  res.json(message)
})
 

glitch: https://elated-eggnog.glitch.me/

it would be great if I can get some advice. I really want to get all the certification but I can’t move forward because of this.

What exactly are you working to achieve?

I am working on this exercise.

https://learn.freecodecamp.org/apis-and-microservices/basic-node-and-express/use-the--env-file

You have an ‘if’ statement without an ‘else/else if’ statement? Maybe that is throwing it off???

I tried this code but still not passing the test. hmm…

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

I was able to pass it finally.

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