Ok, so what your code does is assign the value of your environment variable (i.e. ‘uppercase’) to the variable response.
Then your conditional statement effectively reads:
if (response === 'UPPERCASE')
Then you will return the following object, in either case:
this way it should go to else condition and return ‘uppercase’…
I also tried this:
let express = require(“express”);
let app = express();
app.get(“/json”, function (req, res) {
if (process.env.MESSAGE_STYLE === “allCaps”) {
res.json({message: process.env.MESSAGE_STYLE.toUpperCase()});
} else if (process.env.MESSAGE_STYLE !== “allCaps”) {
res.json({message: process.env.MESSAGE_STYLE});
}
})
All your code is doing is returning the value of your environment variable.
The text ‘Hello json’ is nowhere to be seen. That’s what you should be returning in your response object. You make it uppercase or not depending on the value of your environment variable.
Ok, I’d start by assigning the text ‘Hello json’ to something.
Then I’d use a conditional statement to check the value of MESSAGE_STYLE.
Then, depending on the outcome of the conditional statement, return a response object containing the text, in uppercase if necessary.