1
をループしようと、私はこのようになりますJSON辞書にロードされています:私が反応中に辞書アプリを作成していJSONファイル
{
"DIPLOBLASTIC": "Characterizing the ovum when it has two primary germinallayers.",
"DEFIGURE": "To delineate. [Obs.]These two stones as they are here defigured. Weever.",
"LOMBARD": "Of or pertaining to Lombardy, or the inhabitants of Lombardy.",
"BAHAISM": "The religious tenets or practices of the Bahais.",
"FUMERELL": "See Femerell."
}
ユーザーが入力フィールドに単語を入力し、値が次の関数に渡され、JSONで一致するキーが検索されます。一致する単語は、それぞれの値を持つ結果の配列にプッシュされます。
handleSearch: function(term) {
var term = term;
var results = [];
for (var key in Dictionary) {
if (Dictionary.hasOwnProperty(key)) {
if (term == Dictionary[key]) {
results.push(Dictionary[key])
}
}
}
console.log(results)
},
しかし、私は結果を得るためにそれをループするうまい方法を見つけるのに苦労しています。コンソールは空の配列を記録しています。
誰かが間違っている場所を教えてください。
用語の価値は? –