我希望能够搜索,过滤和排序对象。下面是对象的代码。我有一个输入字段,可以在其中搜索对象。我也有意图指出我要搜索的内容,然后升序还是降序。
在图片中,您可以看到html的外观。
这是要搜索和排序的代码
const users = [{
id: 1,
name: "Jan",
age: 17,
city: "Dublin",
},
{
id: 2,
name: "Bob",
age: 17,
city: "London",
}
]
<form action="#" method="post" id="filters">
<label for="search">Search</label><input type="search" name="search" id="search" />
<label>Sort items by
<select id="sortby" name="sortby">
</select>
</label>
<select id="direction" name="direction">
<option value="asc">ascending</option>
<option value="desc">descending</option>
</select>
</form>
答案 0 :(得分:0)
if (start == end)