-i am new in java script and i have a problem using node js
here is my code
i am using this part to show an input box ,SkyColor
let ourApp = express()
ourApp.use(express.json())
ourApp.get("/", function(req, res) {
res.send(`
<form action='/answer' method='POST'>
<p>What color is the sky on a clear and sunny day?</p>
<input name= "skyColor" autocomplete="off">
<button>Submit Answer</button>
</form>
`)
})
then if i type blue and hit the button to that input box the if statement must chose to show “Congrats! You got the right answer.”
ourApp.post('/answer', function(req, res) {
if(req.body.skyColor == "blue") {
res.send(`
<p>Congrats! You got the right answer.</p>
<a href="/">Back to homepage</a>
`)
console.log(req.body.skyColor)
} else {
res.send(`
<p>Sorry, you got the wrong answer. Please try again</p>
<a href="/">Back to homepage</a>
`)
}
})
ourApp.get('/answer', function(req, res) {
res.send("Are you lost? There is nothing to see here.")
})
ourApp.listen(3000)
but unfortunately every time i enter “blue” the if dont work correctly and show the else part “Sorry, you got the wrong answer. Please try again”