February 17th 2018
Hello! I have been working on this exercise in Express by Colt Steele. I have been working on http requests and params.
app.get("/speak/:animalName", function(req, res) {
var animal = req.params.animalName;
if (animal === "pig"){
res.send("The " + animal + " says 'Oink'");
}
Is someone writes /speak/pig they will get The pig says ‘Oink’.
This is fine, however I am bit stuck in the next one.
app.get("/repeat/:comments/:id", function(req,res){
var words = req.params.comments;
var count = req.params.id;
var number = Number(count);
res.send("Write " + words + " " + number + " times!");
});
When someone writes /repeat/hello/5 it should repeat the given word that many times. I am trying to figure out how to tackle this. It is hard, but that’s the fun about it.
Cheers!