If you wish to validate a range of (positive) years for example 1980 to 2020 where the string '+2000' is not accepted.
isNumeric = function(b){
return /^(198\d|200\d|2020)$/.test(b);
}
This will pass the following tests - it's tested here
Function renamed to yearRange
yearRange = function(b){
return /^(198\d|200\d|2020)$/.test(b);
}
test('Year range validation', function() {
equal( yearRange(1979), false, '1979 returns false');
equal( yearRange(1980), true, '1980 returns true');
equal( yearRange('2000'), true, 'The string 2000 returns true');
equal( yearRange(+2000), true, '+2000 returns true' );
equal( yearRange(-2000), false, '-2000 returns false' );
equal( yearRange('+2000'), false, 'The string +2000 returns false');
equal( yearRange('-2000'), false, 'The string -2000 returns false');
});
return /\d{4}/.test(b)/^\d{4}$/.test(b)instead.