From 3b06f54bdf699082aed6c4f2ad4d77f6338731c7 Mon Sep 17 00:00:00 2001 From: uvok cheetah Date: Sat, 23 May 2020 15:28:35 +0200 Subject: Use Array.prototype.find --- search.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); }); -- cgit v1.2.3