Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

oridnal suffix

export const oridinal_suffix = ( i: number): string => {
	i = +i + 1
    const j = i % 10,
    	k = i % 100
    if (j == 2 && k !== 12) {
    	return i + "nd"
    }
    if (j == 3 && k !== 13) {
    	return i + "rd"
    }
    return i + "th"
}
 
PREVIOUS NEXT
Tagged: #oridnal #suffix
ADD COMMENT
Topic
Name
4+1 =