File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- const isCorrectLength = function ( string , maxLength ) {
2- return string . length <= maxLength ;
3- } ;
1+ const checkStringLength = ( string , maxLength ) => string . length <= maxLength ;
42
5- const isPalindrome = function ( string ) {
3+ const checkForPalindrome = ( string ) => {
64 const normalizeString = string . replaceAll ( ' ' , '' ) . toLowerCase ( ) ;
7- let reversedString = '' ;
5+ let index = normalizeString . length - 1 ;
86
9- for ( let i = normalizeString . length - 1 ; i >= 0 ; i -- ) {
10- reversedString += normalizeString [ i ] ;
7+ for ( const char of normalizeString ) {
8+ if ( char !== normalizeString [ index ] ) {
9+ return false ;
10+ }
11+ index -- ;
1112 }
1213
13- return normalizeString === reversedString ;
14+ return true ;
1415} ;
1516
16- const getNumbers = function ( argument ) {
17+ const parseNumbers = ( argument ) => {
1718 const string = Number . isFinite ( argument ) ? argument . toString ( ) : argument ;
1819 let numbers = '' ;
1920
20- for ( let i = 0 ; i < string . length ; i ++ ) {
21- const number = parseInt ( string [ i ] ) ;
21+ for ( const char of string ) {
22+ const number = parseInt ( char ) ;
2223
2324 if ( ! Number . isNaN ( number ) ) {
24- numbers += string [ i ] ;
25+ numbers += char ;
2526 }
2627 }
2728
You can’t perform that action at this time.
0 commit comments