File tree Expand file tree Collapse file tree 1 file changed +9
-15
lines changed
Expand file tree Collapse file tree 1 file changed +9
-15
lines changed Original file line number Diff line number Diff line change 11function isValidAlphaAbbreviation ( word : string , abbr : string ) : boolean {
2- if ( word . length < 1 || word . length > 25 || abbr . length < 1 || abbr . length > 15 ) {
3- return false ;
4- }
2+ let wordlength = word . length ;
3+ let abbrlength = abbr . length ;
54
6- const hasNumbers = ( str : string ) : boolean => / \d / . test ( str ) ;
7- if ( hasNumbers ( word ) || hasNumbers ( abbr ) ) {
8- return false ;
9- }
10-
11- let wordIndex = 0 ;
12- let abbrIndex = 0 ;
13-
14- const letterToNumber = ( char : string ) : number => {
15- return char . charCodeAt ( 0 ) - 'a' . charCodeAt ( 0 ) + 1 ;
16- } ;
5+ if ( wordlength < abbrlength ) return false ;
6+ if ( word . length < 1 || word . length > 25 ) return false ;
7+ if ( abbr . length < 1 || abbr . length > 15 ) return false ;
8+ if ( ! / ^ [ a - z ] + $ / . test ( word ) ) return false ;
9+ if ( ! / ^ [ a - z ] + $ / . test ( abbr ) ) return false ;
1710
1811
19- }
2012
13+ return true ;
14+ }
You can’t perform that action at this time.
0 commit comments