Finish the function numberToOrdinal, which should take a number and return it as a string with the correct ordinal indicator suffix (in English). That is:
- numberToOrdinal(1) ==> '1st'
- numberToOrdinal(2) ==> '2nd'
- numberToOrdinal(3) ==> '3rd'
- numberToOrdinal(4) ==> '4th'
The goal is to implement simple calculator which uses fluent syntax (pseudo code)
- Calc.new.one.plus.two # Should return 3
- Calc.new.five.minus.six # Should return -1
- Calc.new.seven.times.two # Should return 14
- Calc.new.nine.divided_by.three # Should return 3
In js
- new Calc().one().plus().two()
V1 I'd like an efficient function that can convert a single character string (or just a char if the language supports this type) to an int:
- parse("1") # 1
- parse("d") # doesn't work
- etc...
V2 Can we improve this by supporting multi characters:
- parse("23") # 23
- parse("dd") # doesn't work
V3 Also support negative numbers:
- parse("-23") # -23
- parse("-dd") # doesn't work
V4 Now what about supporting floats:
- parse("23.43") # 23.43
- parse("dd.dd") # still doesn't work