Skip to content

Commit

Permalink
refactor englishify
Browse files Browse the repository at this point in the history
  • Loading branch information
bgates authored Apr 11, 2017
1 parent 3c1c541 commit e3a5434
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions englishify.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ let numbers = {
}

function englishify(num) {
if ((num.toString().length == 2) && (num.toString().split("")[1]!= 0)) {
if (num.toString().split("")[0] == 2){
return "twenty-" + numbers[num.toString().split("")[1]] ;
let ones = num % 10;
if ((num >= 10) && (ones !== 0)) {
if (num < 30){
return "twenty-" + numbers[ones] ;
}
if (num.toString().split("")[0] == 3){
return "thirty-" + numbers[num.toString().split("")[1]] ;
if (num < 40){
return "thirty-" + numbers[ones] ;
}
}
return numbers[num];
Expand Down

0 comments on commit e3a5434

Please sign in to comment.