I trying to use a loop within Express.js and cannot end it.
My loop always writes "hello" I print after /hello/SomeNumber
(for example /hello/5
) and show me 5 hello's.
I want it to stop after >3
and display the message under "*".
app.get("/repeat/:word/:numbers", function(req, res) {
var word = req.params.word;
var numbers = Number(req.params.numbers);
var lol = ""
for (var i = 1; i <= numbers; i++) {
lol += word + " ";
}
res.send(lol);
});
app.get("*", function(req, res) {
res.send("Sorry, page not found...What are you doing with your life?");
});
app.listen(process.env.PORT, process.env.IP, function() {
console.log("Server has started!!!");
});