diff --git a/main.js b/main.js index abb5e99..5ddb190 100644 --- a/main.js +++ b/main.js @@ -226,8 +226,26 @@ function search(word) { for (let key in searchDictionary) { for (let value in searchDictionary[key]) { if (searchDictionary[key][value].includes(word)) { - result.push(key); - break; //???? + if (value == 0) { + result.push(key); + break; + } else { + //if its a description (i.e: includes a space) + //do startsWith or something instead to prevent + //false positive search results + let t = false; + let d = searchDictionary[key][value].split(" ") + for (let w in d) { + if (d[w].startsWith(word)) { + t = true; + console.log(searchDictionary[key][value] + " " + d[w]); + } + } + if (t) { + result.push(key); + break; + } + } } } }