JSFiddle - React, Tailwind, and code Playground

JavaScript

function GetNth(theDate) {
    var nth = '';
    if (theDate > 5 && theDate < 21)
        nth = theDate + 'th';
    else if (theDate % 10 == 1)
        nth = theDate + 'st';
    else if (theDate % 10 == 2)
        nth = theDate + 'nd';
    else if (theDate % 10 == 3)
        nth = theDate + 'rd';
    else
        nth = theDate + 'th';
    return nth;
}

for (var theDate = 1; theDate <= 31; theDate++) {
    document.writeln(GetNth(theDate) + "<br />");   
}