Skip to content

Commit e1d6cc4

Browse files
committed
Changed wordmap into an array or lower case
1 parent 3e2a3ed commit e1d6cc4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/anagram-service.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)