From da6481698ee883db22d91bc2567ffe90dc4be95c Mon Sep 17 00:00:00 2001 From: yarocruz Date: Sat, 23 May 2020 18:22:27 -0400 Subject: [PATCH] fix typo in handleSort function --- src/App.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/App.js b/src/App.js index f5c3f88..39c7fd1 100644 --- a/src/App.js +++ b/src/App.js @@ -12,12 +12,10 @@ function App() { const [ data, setEmployees ] = useState(employees); function handleSearchTerm(event) { - event.preventDefault(); setSearchTerm(event.target.value) } - function handleSortByName(event) { - event.preventDefault(); + function handleSortByName() { // sort array ascending or descending by first name if (!sorted) { setEmployees(data.sort((a, b) => (a.name > b.name) ? 1 : -1)); @@ -28,14 +26,13 @@ function App() { } } - function handleSortByDept(event) { - event.preventDefault(); + function handleSortByDept() { // sort array ascending or descending by dept name if (!sorted) { setEmployees(data.sort((a, b) => (a.department > b.department) ? 1 : -1)); setSorted(true); } else { - setEmployees(data.sort((a, b) => (a.department > b.department) ? -11 : 1)); + setEmployees(data.sort((a, b) => (a.department > b.department) ? -1 : 1)); setSorted(false); } }