I'm updated my original array to become reactive template for my students array list with selection of name in JS ? when i select the button first time it brings up the filter correct value but if click on second iterative button it shows []. what's wrong with my code ?
handlechange(event)
{
const value = event.target.value;
this.students = this.students.filter(e=>e.name.startsWith(value));
}
<table className="table table-bordered">
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
</tr>
{students.map((student, index) => (
<tr data-index={index}>
<td>{student.id}</td>
<td>{student.name}</td>
<td>{student.email}</td>
</tr>
))}
<button onclick={this.handlechange(student.name)}>click </button>
</table>
Use another array to store (and display) your results. Do not modify your source.
handlechange(event)
{
const value = event.target.value;
this.filteredStudents = this.students.filter(e=>e.name.startsWith(value));
}