diff options
author | uvok cheetah | 2020-05-23 15:28:35 +0200 |
---|---|---|
committer | uvok cheetah | 2020-05-23 15:28:35 +0200 |
commit | 3b06f54bdf699082aed6c4f2ad4d77f6338731c7 (patch) | |
tree | 0e792320f6764f9527370ce4dd1cfa3c0f9df30f | |
parent | 19d0278400cbe1459b95554a1d0e616e13d3d485 (diff) |
Use Array.prototype.find
-rw-r--r-- | search.html | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/search.html b/search.html index fb31595..001facd 100644 --- a/search.html +++ b/search.html @@ -42,11 +42,13 @@ layout: page result.forEach(r => { - var p = pages.filter(p => p.id == r.ref)[0]; + const p = pages.find(p => p.id == r.ref); var li = document.createElement("li") var el = li.appendChild(document.createElement("a")); el.textContent = p.title; el.href = p.url; + el = li.appendChild(document.createElement("span")); + el.textContent = " [score: " + r.score.toString() + "]"; root.appendChild(li); }); |