there is a script:
app.get('/:userId', function(req, res) { var userId = +req.params.userId; users.forEach(function (user) { if (user.user_id === userId) { console.log(1); res.send('<h1>' + user.username + '</h1>' + '<h2> Id: ' + user.user_id + '</h2>'); res.end(); } }); console.log(2); res.send('user with id: ' + userId + ' not found'); res.end(); }); when the request is executed, then 1 and 2 are output to the console, why, because res.end should end the request and work as return; or not?
If the user is found, he will return and 1 will be displayed in the console, and if not, 2 will be displayed.