My code works, but is failing the tests, I’ve tried re-factoring the code a few different ways, and have shut everything down and loaded it all up again - to no avail.
What is this test looking for?
my code:
if(process.env.MESSAGE_STYLE ==‘uppercase’){
app.get("/json", (req, res) => {
return res.json({
“message”:(“Hello Json”).toUpperCase()
});
});
}
else{
app.get("/json", (req, res) => {
return res.json({
“message”:“Hello Json”
});
});
};
Try using an lower case “j”.
Good idea! I thought that was it, but unfortunately still not passing.
Is there any way to see what thier testing algorithm is?
I did this yesterday and my understanding was that you could only use a specific file path once. Try taking this line out of the if statement and only include the return statements inside. That’s what worked for me.
Hey Guys;
The code works(if I change value in .env file, it goes back to lowercase) but it still can’t pass the test for some reason- here is my revised code:
app.get("/json", (req, res) => {
var data = { message: “Hello Json” };
if (process.env.MESSAGE_STYLE == “uppercase”) {
return res.json(data.message.toUpperCase());
}
else return res.json(data.message);
});
Thanks for the advise, tried that, also just noticed I was returning data.message, should have been data to include the message: part.
BUT still isn’t passing … hmmmm
else return res.json(data.message);
Does this need to be
else {return res.json(data.message)};
Hey Avidler, I fixed the return statement - this is the code that I feel should pass the test - I was returning just the data.message, so fixed that(return data), code works, but still no pass…
app.get("/json", (req, res) => {
var data = { message: “hello json” };
if (process.env.MESSAGE_STYLE == “uppercase”) {
data.message=data.message.toUpperCase();
}
return res.json(data);
});
Try it without the variable, just res.json the object. You can still use toUpperCase on the string if you want.
Hey Thanks for that, but still no dice - here’s what I tried:
app.get("/json", (req, res) => {
var data = { message: "hello json" };
if (process.env.MESSAGE_STYLE == "uppercase") {
return res.json({message: "HELLO JSON"});
}
else return res.json({message: "hello json"});
});
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>
) will also add backticks around text.
Note: Backticks are not single quotes.

You need to uppercase hello, it should Hello
not hello
1 Like
Will do, and Yep - hello world needed to be Hello world.
Passed 
Thanks