i m just learning express and node js and i was making bmi calculator. every thing is just as the tutorial but my result is getting NaN instead of calculation heres the code
node js
app.get("/bmiCalculator", (req, res) => {
res.sendFile(__dirname + "/bmiCalculator.html")
})
app.post("/bmiCalculator", (req, res) => {
var w = parseFloat(req.body.weight)
var h = parseFloat(req.body.height)
var bmi = w / (h * h);
res.send("your bmi is " + bmi)
})
html
</head>
<h1>bmi cal</h1>
<body>
<form action="/bmiCalculator" method="post">
<input type="text" placeholder="weight">
<input type="text" placeholder="height">
<button type="submit">bmi calculate</button>
</form>
</body>
Isn't it just that your form fields are missing a name attribute?