-1

I have the following code but cannot think why it is not working.

I want to capture a user's input range. So in this example, if a user enters an input in-between 1 and 2000 it should go to page1 otherwise it should go to page 2.

router.post('example', function (req, res) {

  var exchangeYear = req.session.data['exchange-year']

  if(exchangeYear > 1) and (exchangeYear < 2000){
    res.redirect('page1');
  }else{
    res.redirect('page2');
  }
});
Adam
  • 1,439
  • 8
  • 29
  • 47

1 Answers1

0

I have done some more testing and can answer my own question

The answer is this

  if(exchangeYear > 1 && exchangeYear < 2000){

I just had to lose the middle brackets and change use && instead of 'and'

Adam
  • 1,439
  • 8
  • 29
  • 47