Created
August 8, 2015 17:55
-
-
Save celeen/44cc97c305f4a7005637 to your computer and use it in GitHub Desktop.
separate_number refactor for Phil
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def separate_comma(num) | |
string = num.to_s #turn integer into string | |
z = -4 | |
while z > -(string.length+1) | |
string.insert(z, ",") | |
z -= 4 | |
end | |
string | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment