File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ class AnagramService {
1010 */
1111 constructor ( dictionaryFilePath ) {
1212 this . dictionaryFilePath = dictionaryFilePath ;
13- this . wordsMap = new Map ( ) ;
13+ this . wordsMap = [ ] ;
1414 }
1515
1616 /**
@@ -27,7 +27,7 @@ class AnagramService {
2727 const lines = data . toString ( ) . split ( "\n" ) ;
2828
2929 lines . forEach ( ( line ) => {
30- this . wordsMap . set ( line . toLowerCase ( ) , [ line ] ) ;
30+ this . wordsMap . push ( line . toLowerCase ( ) . trim ( ) ) ;
3131 } ) ;
3232 return resolve ( this ) ;
3333 } ) ;
@@ -40,12 +40,12 @@ class AnagramService {
4040 * @returns A string[] of anagram matches
4141 */
4242 async getAnagrams ( term ) {
43- if ( ! this . wordsMap || this . wordsMap . size === 0 ) {
43+ if ( ! this . wordsMap || this . wordsMap . length === 0 ) {
4444 throw Error ( "Error: Dictionary not initialized" ) ;
4545 }
4646
4747 // TODO: The anagram lookup 🤦♂️
48- return this . wordsMap . get ( term ) ;
48+ return this . wordsMap ;
4949 }
5050}
5151
You can’t perform that action at this time.
0 commit comments