Description :
Given a string as input, check if it is a valid ordinal number in English or not. If it is valid return truthy value otherwise return falsy value. (Suggested by @Arnauld. Thanks . Also by @JoKing)
For users who want to know about ordinal numbers go here :
https://www.mathsisfun.com/numbers/cardinal-ordinal-chart.html (Suggestion by : qwr)
Possible inputs :
21st ---> true
12nd ---> false
1nd ---> false
....
This is a code golf challenge so shortest code in each language will be the winner.
Examples :
console.log('12th' , true) // This evaluates to true
console.log('1st' , true) // also evaluates to true
console.log('21nd' , false) // returns false
console.log('11st' , false) // returns false
console.log('111199231923819238198231923213123909808th' , true) // true
Since a lot of people asked the question regarding whether input will be only valid strings or not :
All inputs will always be valid. i.e they will be in the form of string and consist of a digit (or number of digits) along with one of the four suffixes :
st
, nd
, rd
, th
1st
, negative ordinals do not exist - english.stackexchange.com/questions/309713/… \$\endgroup\$