I want an endpoint that is a GET method to /book with a query parameter called name. If the name is 'scott', I want to return "Cracking the Coding Interview," but if it's 'SCOTT,' I want to do the same thing. Why does this not work?
app.get('/book', function (req, res) {
let result = ''
const name = req.query.name.toString().toLowerCase()
if (name === "scott") {
result = "Cracking the Coding Interview"
} else if (name === "enoch") {
result = "The Pragmatic Programmer"
} else {
result = "Good Old Neon"
}
res.send(result);
});