File tree Expand file tree Collapse file tree
exercises/practice/line-up/.meta Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- export const format = ( name , ordinal ) => {
2- const suffix = getSuffix ( ordinal ) ;
3-
4- return `${ name } , you are the ${ ordinal } ${ suffix } customer we serve today. Thank you!` ;
5- } ;
6-
71const getSuffix = ( number ) => {
82 const lastTwoDigits = number % 100 ;
9- const lastOneDigit = number % 10 ;
3+ const lastDigit = number % 10 ;
104
115 if ( lastTwoDigits >= 11 && lastTwoDigits <= 13 ) {
126 return 'th' ;
137 }
148
15- if ( lastOneDigit === 1 ) {
9+ if ( lastDigit === 1 ) {
1610 return 'st' ;
1711 }
1812
19- if ( lastOneDigit === 2 ) {
13+ if ( lastDigit === 2 ) {
2014 return 'nd' ;
2115 }
2216
23- if ( lastOneDigit === 3 ) {
17+ if ( lastDigit === 3 ) {
2418 return 'rd' ;
2519 }
2620
2721 return 'th' ;
2822} ;
23+
24+ export const format = ( name , number ) =>
25+ `${ name } , you are the ${ number } ${ getSuffix ( number ) } customer we serve today. Thank you!` ;
You can’t perform that action at this time.
0 commit comments