Hello all,
my code below works properly on Glitch but freecodecamp says “The response of “/json” does not change according to MESSAGE_STYLE”
Here is my code and below it the link for the problem.
pp.get("/json", function(req, res) {
if (process.env.MESSAGE_STYLE === 'upercase'){return res.json({"message": "HELLO JSON"})}
else {return res.json({"message":"Hello Json"})}
})
Hi, my code works properly on the glitch page. but it returns the following error in FCC -:
The response of "/json" does not change according to MESSAGE_STYLE
My code
let messageObject = {"message": "Hello json"};
app.get('/json', function(req, res) {
if (process.env.MESSAGE_STYLE === 'uppercase') {
return res.json(messageObject.message.toUpperCase());
} else {
return res.json(messageObject.message);
}
});
link for glitch app
https://veil-cereal.glitch.me/
Layer
October 11, 2018, 2:31pm
2
Not sure about the FCC challenge, but you have a typo here:
process.env.MESSAGE_STYLE === ‘upercase’ ‘upp ercase’
// This crispy solution is one slice-off
//
app.get("/json", function(req,res){
let obj = {“message”: “Hello json”};
let myobj = {“message”: “Hello json”};
obj.message=obj.message.toUpperCase();
(process.env.MESSAGE_STYLE==“uppercase”)? res.json(obj) : res.json(myobj);
});
That doesn’t work for me though?