@@ -14,42 +14,46 @@ const Real = {
1414
1515const Proxy = {
1616 drawLetters ( ) {
17- const defaultLetters = [ "H" , "E" , "L" , "L" , "O" , "W" , "O" , "R" , "L" , "D" ] ;
18-
19- if ( typeof Real . drawLetters === "function" ) {
20- return Real . drawLetters ( ) || defaultLetters ;
17+ const real = Real . drawLetters ( ) ;
18+ if ( typeof real === 'undefined' ) {
19+ return [ "H" , "E" , "L" , "L" , "O" , "W" , "O" , "R" , "L" , "D" ] ;
2120 }
2221
23- return defaultLetters ;
22+ return real ;
2423 } ,
2524
2625 usesAvailableLetters ( input , lettersInHand ) {
27- if ( typeof Real . usesAvailableLetters === "function" ) {
28- return Real . usesAvailableLetters ( input , lettersInHand ) ;
26+ const real = Real . usesAvailableLetters ( input , lettersInHand ) ;
27+ if ( typeof real === 'undefined' ) {
28+ return true ;
2929 }
3030
31- return true ;
31+ return real ;
3232 } ,
3333
3434 scoreWord ( word ) {
35- if ( typeof Real . scoreWord === "function" ) {
36- return Real . scoreWord ( word ) ;
35+ const real = Real . scoreWord ( word ) ;
36+ if ( typeof real === 'undefined' ) {
37+ return 1 ;
3738 }
3839
39- return 1 ;
40+ return real ;
4041 } ,
4142
4243 highestScoreFrom ( words ) {
43- if ( typeof Real . highestScoreFrom === "function" ) {
44- return Real . highestScoreFrom ( words ) ;
44+ const real = Real . highestScoreFrom ( words ) ;
45+ if ( typeof real === 'undefined' ) {
46+ if ( words . length < 1 ) {
47+ return { } ;
48+ }
49+
50+ return {
51+ word : words [ 0 ] ,
52+ score : Proxy . scoreWord ( words [ 0 ] ) ,
53+ } ;
4554 }
4655
47- if ( words . length < 1 ) return null ;
48-
49- return {
50- word : words [ 0 ] ,
51- score : Proxy . scoreWord ( words [ 0 ] ) ,
52- } ;
56+ return real ;
5357 } ,
5458} ;
5559
0 commit comments