Can someone help me troubleshoot why my endpoint for a GET method to /book with a query parameter named name is not returning the correct book title? When the name parameter is 'scott' or 'SCOTT,' it should return "Cracking the Coding Interview," but it's not working as expected.
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);
});