Early Exit JS

if(page > pages) {
    return res.redirect('?page='+encodeURIComponent(pages)); // <- early exit
} else if(page < 1) {
    return res.redirect('?page='+encodeURIComponent('1')); // <- early exit
}
Embarrassed Elephant