Return the End Letters of Numbers

Published by Matt in

Create a function that takes an integer and returns it as an ordinal number. An Ordinal Number is a number that tells the position of something in a list, such as 1st, 2nd, 3rd, 4th, 5th, etc.

Examples

returnEndOfNumber(553) ➞ "553-RD"

returnEndOfNumber(34) ➞ "34-TH"

returnEndOfNumber(1231) ➞ "1231-ST"

returnEndOfNumber(22) ➞ "22-ND"

returnEndOfNumber(412) ➞ "412-TH"

Notes

Check the Resources tab for more info on ordinal numbers.

Watch a quick demo on how Edabit works.