File tree 1 file changed +4
-5
lines changed
1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ function everyWithSome(array, test) {
39
39
40
40
console . log ( everyWithSome ( [ 2 , 4 , 16 ] , n => n < 10 ) ) ;
41
41
42
- //dominant writing direction --- characterscript and countBy functions taken from the book
42
+ //dominant writing direction --- characterScript and countBy functions taken from the book
43
43
44
44
function characterScript ( code ) {
45
45
for ( let script of SCRIPTS ) {
@@ -58,7 +58,7 @@ function countBy(items, groupName) {
58
58
let name = groupName ( item ) ;
59
59
let known = counts . findIndex ( c => c . name == name ) ;
60
60
if ( known == - 1 ) {
61
- counts . push ( { name, count : 1 } ) ;
61
+ counts . push ( { name, count : 1 } ) ;
62
62
} else {
63
63
counts [ known ] . count ++ ;
64
64
}
@@ -73,9 +73,8 @@ function dominantDirection(text) {
73
73
return script ? script . direction : 'none' ;
74
74
} )
75
75
76
- return grouping ;
77
-
76
+ return grouping . reduce ( ( a , b ) => a . count > b . count ? a . name : b . name ) ;
78
77
}
79
78
80
-
81
79
console . log ( dominantDirection ( "Hello!" ) ) ;
80
+ console . log ( dominantDirection ( "Hey, مساء الخير" ) ) ;
You can’t perform that action at this time.
0 commit comments