Define a method called ordinal
that will return the ordinal of a number.
An Ordinal Number is a number that tells the position of something in a list. The ordinal of 1 is 1st, 2 is 2nd, 3 is 3rd, 4 is 4th, and so on.
The program should work as such:
ordinal(1)
=> "1st"
ordinal(2)
=> "2nd"
ordinal(3)
=> "3rd"
ordinal(4)
=> "4th"
ordinal(105)
=> "105th"
Let's navigate to the ordinal
directory. In the workspace terminal, type in the following command and press enter:
cd ordinal
Next, type in the following command and press enter:
bundle install
This should install a bunch of packages and dependencies.
Next, let's run the following command to run the test suites:
rspec
Since you haven't written any code yet, you will see that all the tests fail.
Open ordinal.rb
. Inside this file, you need to write a method that will return the ordinal of the number that is passed in as an argument.
Your goal is to make every one of these tests pass. Once you finish writing the code, run the rspec
command. Keep rewriting your code until all of the tests pass when you run the rspec
command.