1
var WordDictionary = function () {9
WordDictionary.prototype.addWord = function (word) {10
this.aryWordList.push(word);14
* @param {string} word17
WordDictionary.prototype.search = function (word) {18
const isWordsMatch = (first, second) => {19
if (first.length !== second.length) return false;21
if (first.length == 0 && second.length == 0) return true; // Exit case for recursion23
if (first[0] === second[0] || first[0] === "." || second[0] === ".")24
return isWordsMatch(first.substring(1), second.substring(1));29
const isWordFound = () => {31
for (var indexI = 0; indexI < this.aryWordList.length; indexI++) {32
if (isWordsMatch(this.aryWordList[indexI], word)) {41
return word.indexOf(".") === -142
? this.aryWordList.includes(word)47
* Your WordDictionary object will be instantiated and called as such:48
* var obj = new WordDictionary()50
* var param_2 = obj.search(word)